Best Python code snippet using avocado_python
test_edit_profile.py
Source:test_edit_profile.py  
1from django.test import TestCase2from django.urls import reverse3from accounts.models import User4from rest_framework.test import APIClient5import json6from rest_framework import status7import io8from PIL import Image9from django.core.files.uploadedfile import SimpleUploadedFile10# Create your tests here.11class TestUserProfile(TestCase):12    13    def setUp(self):14        self.client = APIClient()15        self.user = User.objects.create(username="morteza", email="morteza@gmail.com")16        self.user.set_password("mo1234")17        self.user.save()18        19    def login(self, username, password):20        # print(username, password)21        url = reverse('accounts:accounts-jwt-create')22        data = json.dumps({'username': username, 'password': password})23        response = self.client.post(url, data, content_type='application/json')24        if response.status_code == status.HTTP_200_OK:25            access_token = response.data['access']26            return access_token27        else:28            return "incorrect"29        30    def temporary_image(self):31        bts = io.BytesIO()32        img = Image.new("RGB", (100, 100))33        img.save(bts, 'jpeg')34        return SimpleUploadedFile("test.jpg", bts.getvalue())35        36    def test_incorrect_login_incorrect_email(self):37        38        #uncorrect username39        url = reverse('accounts:accounts-jwt-create')40        response = self.client.post(url, {"username":"morteza2","password":"mo1234"}, format='json')41        self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)42        43    def test_incorrect_login_incorrect_email(self):44        #uncorrect email45        url = reverse('accounts:accounts-jwt-create')46        response = self.client.post(url, {"username":"morteza2@gmail.com","password":"mo1234"}, format='json')47        self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)48        49    def test_incorrect_login_incorrect_password(self):50        #uncorrect password51        url = reverse('accounts:accounts-jwt-create')52        response = self.client.post(url, {"username":"morteza","password":"mo12342"}, format='json')53        self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)54        55    def test_incorrect_login_no_password(self):56        #no password57        url = reverse('accounts:accounts-jwt-create')58        response = self.client.post(url, {"username":"morteza"}, format='json')59        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)60        61    def test_incorrect_login_no_usernname(self):62        #no username63        url = reverse('accounts:accounts-jwt-create')64        response = self.client.post(url, {"password":"mo12342"}, format='json')65        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)66        67    def test_correct_login_with_username(self):68        #correct login with username69        url = reverse('accounts:accounts-jwt-create')70        response = self.client.post(url, {"username":"morteza","password":"mo1234"}, format='json')71        self.assertEqual(response.status_code, status.HTTP_200_OK)72        self.assertTrue('refresh' in response.data)73        self.assertTrue('access' in response.data)74        75    def test_correct_login_with_email(self):76        #correct login with email77        url = reverse('accounts:accounts-jwt-create')78        response = self.client.post(url, {"username":"morteza@gmail.com","password":"mo1234"}, format='json')79        self.assertEqual(response.status_code, status.HTTP_200_OK)80        self.assertTrue('refresh' in response.data)81        self.assertTrue('access' in response.data)82        83    def test_getProfile_fail(self):84        85        #fail response86        self.uncorrect_username = "Hello"87        response = self.client.get(reverse('accounts:user-profile', args=(self.uncorrect_username,)))88        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)89        90    def test_getProfile_success(self):91        #ok response92        response = self.client.get(reverse('accounts:user-profile', args=(self.user.username,)))93        self.assertEqual(response.status_code, status.HTTP_200_OK)94        95    def test_correct_putProfile(self):96        97        #correct login with username98        access_token = self.login("morteza", "mo1234")99        image_file = self.temporary_image()100        101        put_data = {102            "username":"morteza", 103            "image": image_file,104            "about_me":"I'm Morteza Shahrabi Farahani. Backend developer at Irangard.",105            "is_special": True,106            "full_name": "Morteza Shahrabi Farahani",107        }108        109        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)110        111        url = reverse('accounts:user-profile', args=(self.user.username,))112        response = self.client.put(url, data=put_data)113        self.assertEqual(response.status_code, status.HTTP_200_OK)114        115    def test_incorrect_putProfile_incorrect_token(self):116        117        #correct login with username but incorrect token118        access_token = self.login("morteza", "mo1234")119        new_access_token = access_token + "a"120        image_file = self.temporary_image()121    122        put_data = {123            "username":"morteza", 124            "image": image_file,125            "about_me":"I'm Morteza Shahrabi Farahani. Backend developer at Irangard.",126            "is_special": True,127            "full_name": "Morteza Shahrabi Farahani",128            129        }130        131        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + new_access_token)132        133        url = reverse('accounts:user-profile', args=(self.user.username,))134        response = self.client.put(url, data=put_data)135        self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)136        137    def test_incorrect_putProfile_without_token(self):138    139        put_data = {140            "username":"morteza", 141            "about_me":"I'm Morteza Shahrabi Farahani. Backend developer at Irangard.",142            "is_special": True,143            "full_name": "Morteza Shahrabi Farahani",144            145        }146        147        self.client.credentials(HTTP_AUTHORIZATION='JWT ')148        149        url = reverse('accounts:user-profile', args=(self.user.username,))150        response = self.client.put(url, data=put_data, format='json')151        self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)152        153    def test_incorrect_putProfile_without_token_2(self):154    155        put_data = {156            "username":"morteza", 157            "about_me":"I'm Morteza Shahrabi Farahani. Backend developer at Irangard.",158            "is_special": True,159            "full_name": "Morteza Shahrabi Farahani",160            161        }162        163        url = reverse('accounts:user-profile', args=(self.user.username,))164        response = self.client.put(url, data=put_data, format='json')165        self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)166        167    def test_correct_putProfile_change_username(self):168        169        #correct login with username170        access_token = self.login("morteza", "mo1234")171        image_file = self.temporary_image()172        173        put_data = {174            "username":"morteza1", 175            "image": image_file,176            "about_me":"I'm Morteza Shahrabi Farahani. Backend developer at Irangard.",177            "is_special": True,178            "full_name": "Morteza Shahrabi Farahani",179        }180        181        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)182        183        url = reverse('accounts:user-profile', args=(self.user.username,))184        response = self.client.put(url, data=put_data)185        # print(response.data)186        self.assertEqual(response.status_code, status.HTTP_200_OK)187        self.assertEqual(response.data['username'], "morteza1")188        189    def test_correct_putProfile_change_about_me(self):190        191        #correct login with username192        access_token = self.login("morteza", "mo1234")193        image_file = self.temporary_image()194        195        put_data = {196            "username":"morteza", 197            "image": image_file,198            "about_me":"I'm Morteza Shahrabi Farahani. Backend developer at Irangard. Computer enginering student at IUST",199            "is_special": True,200            "full_name": "Morteza Shahrabi Farahani",201        }202        203        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)204        205        url = reverse('accounts:user-profile', args=(self.user.username,))206        response = self.client.put(url, data=put_data)207        self.assertEqual(response.status_code, status.HTTP_200_OK)208        self.assertEqual(response.data['about_me'], "I'm Morteza Shahrabi Farahani. Backend developer at Irangard. Computer enginering student at IUST")209        210    def test_correct_putProfile_change_is_special(self):211        212        #correct login with username213        access_token = self.login("morteza", "mo1234")214        image_file = self.temporary_image()215        216        put_data = {217            "username":"morteza1", 218            "image": image_file,219            "about_me":"I'm Morteza Shahrabi Farahani. Backend developer at Irangard.",220            "is_special": False,221            "full_name": "Morteza Shahrabi Farahani",222        }223        224        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)225        226        url = reverse('accounts:user-profile', args=(self.user.username,))227        response = self.client.put(url, data=put_data)228        # print(response.data)229        self.assertEqual(response.status_code, status.HTTP_200_OK)230        self.assertEqual(response.data['is_special'], False)231        232    def test_correct_putProfile_change_full_name(self):233        234        #correct login with username235        access_token = self.login("morteza", "mo1234")236        image_file = self.temporary_image()237        238        put_data = {239            "username":"morteza1", 240            "image": image_file,241            "about_me":"I'm Morteza Shahrabi Farahani. Backend developer at Irangard.",242            "is_special": False,243            "full_name": "Morteza Shahrabi Farahani test",244        }245        246        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)247        248        url = reverse('accounts:user-profile', args=(self.user.username,))249        response = self.client.put(url, data=put_data)250        # print(response.data)251        self.assertEqual(response.status_code, status.HTTP_200_OK)252        self.assertEqual(response.data['full_name'], "Morteza Shahrabi Farahani test")253        254        255    def test_correct_putProfile_change_image(self):256        257        #correct login with username258        access_token = self.login("morteza", "mo1234")259        image_file = self.temporary_image()260        # print("image type is: ",type(image_file))261        262        put_data = {263            "username":"morteza1", 264            "image": image_file,265            "about_me":"I'm Morteza Shahrabi Farahani. Backend developer at Irangard.",266            "is_special": False,267            "full_name": "Morteza Shahrabi Farahani test",268        }269        270        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)271        272        url = reverse('accounts:user-profile', args=(self.user.username,))273        response = self.client.put(url, data=put_data)274        # print(response.data)275        self.assertEqual(response.status_code, status.HTTP_200_OK)276        # self.assertEqual(response.data['image'].startswith("https://res.cloudinary.com/dgwbbbisy/image/upload/v1/media/images"), True)277        278    def test_correct_putProfile_all(self):279        280        #correct login with username281        access_token = self.login("morteza", "mo1234")282        image_file = self.temporary_image()283        284        put_data = {285            "username":"morteza1", 286            "image": image_file,287            "about_me":"I'm Morteza Shahrabi Farahani. Backend developer at Irangard. 1",288            "is_special": False,289            "full_name": "Morteza Shahrabi Farahani test",290        }291        292        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)293        294        url = reverse('accounts:user-profile', args=(self.user.username,))295        response = self.client.put(url, data=put_data)296        # print(response.data)297        self.assertEqual(response.status_code, status.HTTP_200_OK)298        self.assertEqual(response.data['full_name'], "Morteza Shahrabi Farahani test")299        self.assertEqual(response.data['is_special'], False)300        self.assertEqual(response.data['about_me'], "I'm Morteza Shahrabi Farahani. Backend developer at Irangard. 1")301        self.assertEqual(response.data['username'], "morteza1")302        # self.assertEqual(response.data['image'].startswith("https://res.cloudinary.com/dgwbbbisy/image/upload/v1/media/images"), True)303        304        305    def test_incorrect_putProfile_incorrect_data(self):306        307        #correct login with username308        access_token = self.login("morteza", "mo1234")309        310        put_data = {311            "about_me":"I'm Morteza Shahrabi Farahani. Backend developer at Irangard.",312            "is_special": False,313            "full_name": "Morteza Shahrabi Farahani test",314        }315        316        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)317        318        url = reverse('accounts:user-profile', args=(self.user.username,))319        response = self.client.put(url, data=put_data, format='json')320        # print(response.data)321        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) 322        323        324    def test_correct_putProfile_without_about_me(self):325        326        #correct login with username327        access_token = self.login("morteza", "mo1234")328        329        put_data = {330            "username":"morteza", 331            "is_special": True,332            "full_name": "Morteza Shahrabi Farahani",333            334        }335        336        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)337        338        url = reverse('accounts:user-profile', args=(self.user.username,))339        response = self.client.put(url, data=put_data, format='json')340        self.assertEqual(response.status_code, status.HTTP_200_OK)341        342    def test_correct_putProfile_without_is_special(self):343        344        #correct login with username345        access_token = self.login("morteza", "mo1234")346        347        put_data = {348            "username":"morteza", 349            "full_name": "Morteza Shahrabi Farahani",350        }351        352        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)353        354        url = reverse('accounts:user-profile', args=(self.user.username,))355        response = self.client.put(url, data=put_data, format='json')356        self.assertEqual(response.status_code, status.HTTP_200_OK)357        358    def test_correct_putProfile_without_full_name(self):359        360        #correct login with username361        access_token = self.login("morteza", "mo1234")362        363        put_data = {364            "username":"morteza", 365        }366        367        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)368        369        url = reverse('accounts:user-profile', args=(self.user.username,))370        response = self.client.put(url, data=put_data, format='json')371        self.assertEqual(response.status_code, status.HTTP_200_OK)372        373    def test_correct_putProfile_without_image(self):374        375        #correct login with username376        access_token = self.login("morteza", "mo1234")377        378        put_data = {379            "username":"morteza", 380        }381        382        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)383        384        url = reverse('accounts:user-profile', args=(self.user.username,))385        response = self.client.put(url, data=put_data, format='json')386        self.assertEqual(response.status_code, status.HTTP_200_OK)387      388    def test_incorrect_putProfile_bad_username(self):389        390        #correct login with username391        access_token = self.login("morteza", "mo1234")392        393        put_data = {394            "username123": "morteza", 395            "about_me":"I'm Morteza Shahrabi Farahani. Backend developer at Irangard.",396            "is_special": True,397            "full_name": "Morteza Shahrabi Farahani",398            399        }400        401        self.client.credentials(HTTP_AUTHORIZATION='JWT ' + access_token)402        403        url = reverse('accounts:user-profile', args=(self.user.username,))404        response = self.client.put(url, data=put_data, format='json')405        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)...test_put.py
Source:test_put.py  
1import pytest2from application.models import FoodTruck3from test_data import test_data, test_name, test_item, test_location, test_radius4import json5@pytest.mark.usefixtures('create_db', 'populate_user_db', 'populate_food_truck_db')6class TestPut():7    """8    Test cases for validating the PUT endpoint of the application.9    Prior to running the test cases, the following procedure is run:10    1. Initialize application11    2. Create database table12    4. Populate user database with predefined elements13    3. Populate food truck database with predefined elements14    """15    def test_update_truck(self, client, token):16        """17        Test PUT request to update existing FoodTruck with valid authentication.18        1. Login to acquire token19        2. Send PUT request to foodtrucks with valid parameters20        3. Verify the status code as successful21        4. Verify the attributes of the object returned in the response22        5. Verify the element in the database23        """24        uuid = 125        mimetype = 'application/json'26        headers = {'Authorization': 'Bearer ' + token,27                    'Content-Type': mimetype,28                    'Accept': mimetype}29        put_data = {'name':'Food Truck 1',30                    'latitude':37.7201,31                    'longitude':-122.3886,32                    'days_hours':'Mon-Fri:8AM-2PM',33                    'food_items':'sandwiches'}34        35        ret = client.put('/foodtrucks/{}'.format(uuid), data=json.dumps(put_data), headers=headers)36        ret_data = ret.get_json()37        38        # validate response39        assert ret.status_code == 20040        assert ret_data['uuid'] == uuid41        assert ret_data['name'] == put_data['name']42        assert ret_data['latitude'] == put_data['latitude']43        assert ret_data['longitude'] == put_data['longitude']44        assert ret_data['days_hours'] == put_data['days_hours']45        assert ret_data['food_items'] == put_data['food_items']46        # validate database47        truck = FoodTruck.query.filter_by(uuid=uuid).first()48        assert truck.name == put_data['name']49        assert truck.latitude == put_data['latitude']50        assert truck.longitude == put_data['longitude']51        assert truck.days_hours == put_data['days_hours']52        assert truck.food_items == put_data['food_items']53        assert truck.user_id == 254    def test_update_truck_unauthorized(self, client):55        """56        Test PUT request to update existing FoodTruck without authnetication.57        1. Send PUT request to foodtrucks without authentication58        2. Verify the status code as unauthorized59        """60        uuid = 161        mimetype = 'application/json'62        headers = {'Content-Type': mimetype,63                    'Accept': mimetype}64        put_data = {'name':'Food Truck 1',65                    'latitude':37.7201,66                    'longitude':-122.3886,67                    'days_hours':'Mon-Fri:8AM-2PM',68                    'food_items':'sandwiches'}69        70        ret = client.put('/foodtrucks/{}'.format(uuid), data=json.dumps(put_data), headers=headers)71        ret_data = ret.get_json()72        73        # validate response74        assert ret.status_code == 40175    def test_create_truck(self, client, token):76        """77        Test authenticated PUT request to create new FoodTruck with specific.78        1. Login to acquire token79        2. Send authenticated PUT request to foodtrucks with valid parameters and specific id80        3. Verify the status code as successful81        4. Verify the attributes of the object returned in the response82        5. Verify the element in the database83        """84        uuid = len(test_data)+185        mimetype = 'application/json'86        headers = {'Authorization': 'Bearer ' + token,87                    'Content-Type': mimetype,88                    'Accept': mimetype}89        put_data = {'name':'Food Truck 2',90                    'latitude':37.7201,91                    'longitude':-122.3886,92                    'days_hours':'Mon-Fri:8AM-2PM',93                    'food_items':'sandwiches'}94        95        ret = client.put('/foodtrucks/{}'.format(uuid), data=json.dumps(put_data), headers=headers)96        ret_data = ret.get_json()97        98        # validate response99        assert ret.status_code == 200100        assert ret_data['uuid'] == uuid101        assert ret_data['name'] == put_data['name']102        assert ret_data['latitude'] == put_data['latitude']103        assert ret_data['longitude'] == put_data['longitude']104        assert ret_data['days_hours'] == put_data['days_hours']105        assert ret_data['food_items'] == put_data['food_items']106        # validate database107        truck = FoodTruck.query.filter_by(uuid=uuid).first()108        assert truck.name == put_data['name']109        assert truck.latitude == put_data['latitude']110        assert truck.longitude == put_data['longitude']111        assert truck.days_hours == put_data['days_hours']112        assert truck.food_items == put_data['food_items']113        assert truck.user_id == 2114    def test_create_truck_unauthorized(self, client):115        """116        Test PUT request without authentication to create new FoodTruck with specific id.117        1. Send PUT request without authentication to foodtrucks with valid parameters and specific id118        2. Verify the status code as unauthorized119        """120        uuid = len(test_data)+1121        mimetype = 'application/json'122        headers = {'Content-Type': mimetype,123                    'Accept': mimetype}124        put_data = {'name':'Food Truck 2',125                    'latitude':37.7201,126                    'longitude':-122.3886,127                    'days_hours':'Mon-Fri:8AM-2PM',128                    'food_items':'sandwiches'}129        130        ret = client.put('/foodtrucks/{}'.format(uuid), data=json.dumps(put_data), headers=headers)131        ret_data = ret.get_json()132        133        # validate response134        assert ret.status_code == 401135    def test_update_truck_bad_request(self, client, token):136        """137        Test PUT request to create new FoodTruck with different invalid parameters.138        1. Login to acquire token139        2. Send PUT request to foodtrucks with missing field in parameters140        3. Verify the status code as bad request141        4. Send PUT request to foodtrucks with wrong datatype for longitude142        5. Verify the status code as bad request143        6. Send PUT request to foodtrucks with wring mimetype in header144        7. Verify the status code as bad request145        """146        uuid = 1147        url = '/foodtrucks/{}'.format(uuid)148        mimetype = 'application/json'149        headers = {'Authorization': 'Bearer ' + token,150                    'Content-Type': mimetype,151                    'Accept': mimetype}152        # missing field in data153        put_data = {'name':'Food Truck 1',154                    'latitude':37.7201,155                    #longitude missing156                    'days_hours':'Mon-Fri:8AM-2PM',157                    'food_items':'sandwiches'}158        ret = client.put(url, data=json.dumps(put_data), headers=headers)159        assert ret.status_code == 400160        # wrong data type in field161        put_data['longitude'] = 'abc'162        ret = client.put(url, data=json.dumps(put_data), headers=headers)163        assert ret.status_code == 400        164        # wrong mimetype in header165        put_data['longitude'] = -122.3886166        mimetype = 'text/html'167        headers = {'Authorization': 'Bearer ' + token,168                    'Content-Type': mimetype,169                    'Accept': mimetype}170        ret = client.put(url, data=json.dumps(put_data), headers=headers)...TestAppData.py
Source:TestAppData.py  
2from core.models import AppData3class TestBoolType:4    @pytest.mark.django_db5    def test_default_value(self):6        AppData.put_data("test", "test", type_=bool)7        data = AppData.get_data("test", "test")8        assert data == False9    @pytest.mark.django_db10    def test_false_value(self):11        AppData.put_data("test", "test", False, bool)12        data = AppData.get_data("test", "test")13        assert data == False14    @pytest.mark.django_db15    def test_true_value(self):16        AppData.put_data("test", "test", True, bool)17        data = AppData.get_data("test", "test")18        assert data == True19    @pytest.mark.django_db20    def test_invalid_value(self):21        AppData.put_data("test", "test", "invalid", bool)22        data = AppData.get_data("test", "test")23        assert data == False24class TestDictType:25    @pytest.mark.django_db26    def test_default_value(self):27        AppData.put_data("test", "test", type_=dict)28        data = AppData.get_data("test", "test")29        assert data == {}30    @pytest.mark.django_db31    def test_valid_value(self):32        AppData.put_data("test", "test", {"test": "test"}, dict)33        data = AppData.get_data("test", "test")34        assert data == {"test": "test"}35    @pytest.mark.django_db36    def test_invalid_value(self):37        AppData.put_data("test", "test", "invalid", dict)38        data = AppData.get_data("test", "test")39        assert data == {}40class TestFloatType:41    @pytest.mark.django_db42    def test_default_value(self):43        AppData.put_data("test", "test", type_=float)44        data = AppData.get_data("test", "test")45        assert data == 0.046    @pytest.mark.django_db47    def test_valid_value(self):48        AppData.put_data("test", "test", 1.5, float)49        data = AppData.get_data("test", "test")50        assert data == 1.551    @pytest.mark.django_db52    def test_invalid_value(self):53        AppData.put_data("test", "test", "invalid", float)54        data = AppData.get_data("test", "test")55        assert data == 0.056class TestIntType:57    @pytest.mark.django_db58    def test_default_value(self):59        AppData.put_data("test", "test", type_=int)60        data = AppData.get_data("test", "test")61        assert data == 062    @pytest.mark.django_db63    def test_valid_value(self):64        AppData.put_data("test", "test", 1, int)65        data = AppData.get_data("test", "test")66        assert data == 167    @pytest.mark.django_db68    def test_invalid_value(self):69        AppData.put_data("test", "test", "invalid", int)70        data = AppData.get_data("test", "test")71        assert data == 072class TestListType:73    @pytest.mark.django_db74    def test_default_value(self):75        AppData.put_data("test", "test", type_=list)76        data = AppData.get_data("test", "test")77        assert data == []78    @pytest.mark.django_db79    def test_valid_value(self):80        AppData.put_data("test", "test", [1, 2, 3], list)81        data = AppData.get_data("test", "test")82        assert data == [1, 2, 3]83    @pytest.mark.django_db84    def test_invalid_value(self):85        AppData.put_data("test", "test", "invalid", list)86        data = AppData.get_data("test", "test")87        assert data == []88class TestStrType:89    @pytest.mark.django_db90    def test_default_value(self):91        AppData.put_data("test", "test")92        data = AppData.get_data("test", "test")93        assert data == "None"94    @pytest.mark.django_db95    def test_valid_value(self):96        AppData.put_data("test", "test", "test")97        data = AppData.get_data("test", "test")98        assert data == "test"99    @pytest.mark.django_db100    def test_invalid_value(self):101        AppData.put_data("test", "test", 1.5, TestStrType)102        data = AppData.get_data("test", "test")103        assert data == "1.5"104class TestReadAndUpdateMultipleRecords:105    @pytest.mark.django_db106    def test_valid(self):107        AppData.put_data("test.component", "key_1", "abc")108        AppData.put_data("test.component", "key_2", False, bool)109        AppData.put_data("other.component", "key_1", 0, int)110        components = AppData.get_components()111        assert components == {112            "test.component": {113                "key_1": {114                    "id": 1,115                    "data": "abc",116                    "description": "",117                    "type": "str",118                },119                "key_2": {120                    "id": 2,121                    "data": False,122                    "description": "",123                    "type": "bool",...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
