<s> import unittest <EOL> import os <EOL> import sys <EOL> import json <EOL> sys . path . append ( os . path . dirname ( os . path . realpath ( __file__ ) . rsplit ( '<STR_LIT:/>' , <NUM_LIT:2> ) [ <NUM_LIT:0> ] ) ) <EOL> from app import create_app <EOL> app = create_app ( '<STR_LIT>' ) <EOL> add_data = """<STR_LIT>""" <EOL> update_data = """<STR_LIT>""" <EOL> class TestUsers ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . app = app . test_client ( ) <EOL> def test_01_add ( self ) : <EOL> rv = self . app . post ( '<STR_LIT>' , data = add_data , <EOL> content_type = "<STR_LIT:application/json>" ) <EOL> assert rv . status_code == <NUM_LIT> <EOL> def test_02_read_update ( self ) : <EOL> request = self . app . get ( '<STR_LIT>' ) <EOL> dict = json . loads ( request . data . decode ( '<STR_LIT:utf-8>' ) ) <EOL> id = dict [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] <EOL> rv = self . app . patch ( '<STR_LIT>' . format ( id ) , <EOL> data = update_data , content_type = "<STR_LIT:application/json>" ) <EOL> assert rv . status_code == <NUM_LIT:200> <EOL> def test_03_delete ( self ) : <EOL> request = self . app . get ( '<STR_LIT>' ) <EOL> dict = json . loads ( request . data . decode ( '<STR_LIT:utf-8>' ) ) <EOL> id = dict [ '<STR_LIT:data>' ] [ <NUM_LIT:0> ] [ '<STR_LIT:id>' ] <EOL> rv = self . app . delete ( '<STR_LIT>' . format ( id ) ) <EOL> assert rv . status_code == <NUM_LIT> <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
