예제 #1
0
 def test_del_not_existing_user_by_uuid(self):
     uuid = getuuid("Any", "Name")
     resp = self.client.get('/users/' + uuid,
                            data=json.dumps({}),
                            content_type='application/json')
     assert resp.status_code == 200
     assert '"code": 1004' in resp.data
예제 #2
0
 def test_updt_not_existed_user(self):
     contact = {"country": "Canada", "city": "Ottava", "street": "NewStreet",
                "home_phone" : "54334353"}
     uuid = getuuid("Unknown", "Person")
     resp = self.client.put('/contacts/' + uuid, data=json.dumps(contact), content_type='application/json')
     assert resp.status_code == 200
     assert '"code": 1004' in resp.data
예제 #3
0
 def test_get_all_users_with_absent_offset(self):
     contacts = ({
         "name": "Andrew",
         "surname": "Kembel",
         "country": "USA",
         "city": "Boston",
         "street": "Good",
         "cell_phone": "123212345",
         "home_phone": "67544545890"
     }, {
         "name": "Ivan",
         "surname": "Ivanov",
         "country": "Russia",
         "city": "Ivanovo",
         "street": "Lenina",
         "cell_phone": "123212345",
         "home_phone": "67544545890"
     })
     for contact in contacts:
         uuid = getuuid(contact['name'], contact['surname'])
         resp = self.client.post('/contacts',
                                 data=json.dumps(contact),
                                 content_type='application/json')
         assert resp.status_code == 200
     resp = self.client.get('/users',
                            data=json.dumps({"limit": 2}),
                            content_type='application/json')
     assert resp.status_code == 200
     decoded = json.loads(resp.data)
     assert resp.status_code == 200
     assert len(decoded) == 2
     assert 'Ivanovo' in resp.data
     assert 'Boston' in resp.data
예제 #4
0
 def test_updt_user_with_field_duplication(self):
     contact = {
         "name": "Andrew",
         "surname": "Kembel",
         "country": "USA",
         "city": "Boston",
         "street": "Good",
         "cell_phone": "123212345",
         "home_phone": "67544545890"
     }
     resp = self.client.post('/contacts',
                             data=json.dumps(contact),
                             content_type='application/json')
     uuid = getuuid(contact['name'], contact['surname'])
     contact = {
         "surname": "Kovtun",
         "surname": "Kovtun2",
         "home_phone": "66666666666"
     }
     resp = self.client.put('/contacts/' + uuid,
                            data=json.dumps(contact),
                            content_type='application/json')
     assert resp.status_code == 200
     assert 'uuid' in resp.data
     assert uuid in resp.data
예제 #5
0
 def test_get_all_users(self):
     contact = {"name": "Andrew", "surname": "Kembel",
                "country": "USA", "city": "Boston", "street": "Good",
                "cell_phone": "123212345", "home_phone": "67544545890"}
     resp = self.client.post('/contacts', data=json.dumps(contact), content_type='application/json')
     uuid = getuuid(contact['name'], contact['surname'])
     resp = self.client.get('/users', data=json.dumps({"limit": 4}), content_type='application/json')
     assert resp.status_code == 200
     assert 'Kembel' in resp.data
예제 #6
0
 def test_del_user_with_not_empty_json_request(self):
     contact = {"name": "Andrew", "surname": "Kembel",
                "country": "USA", "city": "Boston", "street": "Good",
                "cell_phone": "123212345", "home_phone": "67544545890"}
     resp = self.client.post('/contacts', data=json.dumps(contact), content_type='application/json')
     uuid = getuuid(contact['name'], contact['surname'])
     resp = self.client.get('/users/' + uuid, data=json.dumps({"name": "Andrew"}), content_type='application/json')
     assert resp.status_code == 200
     assert '"code": 1012' in resp.data
예제 #7
0
 def test_updt_user_with_unknown_field(self):
     contact = {"name": "Andrew", "surname": "Kembel",
                "country": "USA", "city": "Boston", "street": "Good",
                "cell_phone": "123212345", "home_phone": "67544545890"}
     resp = self.client.post('/contacts', data=json.dumps(contact), content_type='application/json')
     uuid = getuuid(contact['name'], contact['surname'])
     contact = {"surname": "Kovtun", "unknown": "Unknown", "home_phone": "66666666666"}
     resp = self.client.put('/contacts/' + uuid, data=json.dumps(contact), content_type='application/json')
     assert resp.status_code == 200
     assert '"code": 1010' in resp.data
예제 #8
0
 def test_updt_users(self):
     contact = {"name": "Andrew", "surname": "Kembel",
                "country": "USA", "city": "Boston", "street": "Good",
                "cell_phone": "123212345", "home_phone": "67544545890"}
     resp = self.client.post('/contacts', data=json.dumps(contact), content_type='application/json')
     uuid = getuuid(contact['name'], contact['surname'])
     contact = {"country": "Canada", "city": "New Yourk", "street": "Unknown",
                "home_phone": "88888888888"}
     resp = self.client.put('/contacts/' + uuid, data=json.dumps(contact), content_type='application/json')
     assert resp.status_code == 200
     assert 'uuid' in resp.data
     assert uuid in resp.data
예제 #9
0
 def test_updt_not_existed_user(self):
     contact = {
         "country": "Canada",
         "city": "Ottava",
         "street": "NewStreet",
         "home_phone": "54334353"
     }
     uuid = getuuid("Unknown", "Person")
     resp = self.client.put('/contacts/' + uuid,
                            data=json.dumps(contact),
                            content_type='application/json')
     assert resp.status_code == 200
     assert '"code": 1004' in resp.data
예제 #10
0
 def test_get_all_users_with_non_zero_offset(self):
     contacts = (
              {"name": "Andrew", "surname": "Kembel",
               "country": "USA", "city": "Boston", "street": "Good",
               "cell_phone": "123212345", "home_phone": "67544545890"},
              {"name": "Ivan", "surname": "Ivanov",
               "country": "Russia", "city": "Ivanovo", "street": "Lenina",
               "cell_phone": "77777777", "home_phone": "999999999999"})
     for contact in contacts:
         uuid = getuuid(contact['name'], contact['surname'])
         resp = self.client.post('/contacts', data=json.dumps(contact), content_type='application/json')
         assert resp.status_code == 200
     resp = self.client.get('/users', data=json.dumps({"limit": 2, "offset": 1}), content_type='application/json')
     decoded = json.loads(resp.data)
     assert resp.status_code == 200
     assert len(decoded) == 1
     assert 'Ivanovo' in resp.data
예제 #11
0
 def test_add_users(self):
     contacts = ({
         "name": "Andrew",
         "surname": "Kembel",
         "country": "USA",
         "city": "Boston",
         "street": "Good",
         "cell_phone": "123212345",
         "home_phone": "67544545890"
     }, {
         "name": "Ivan",
         "surname": "Ivanov",
         "country": "Russia",
         "city": "Ivanovo",
         "street": "Lenina",
         "cell_phone": "77777777",
         "home_phone": "999999999999"
     }, {
         "name": "Petro",
         "surname": "Kyrychenko",
         "country": "Ukraine",
         "city": "Lviv",
         "street": "Mazepy",
         "cell_phone": "53454335",
         "home_phone": "5634854387543"
     }, {
         "name": "Carlos",
         "surname": "Rego",
         "country": "France",
         "city": "Lion",
         "cell_phone": "123212345"
     }, {
         "name": "Andrew",
         "surname": "Kovtun",
         "country": "USA",
         "home_phone": "423423423234"
     })
     for contact in contacts:
         uuid = getuuid(contact['name'], contact['surname'])
         resp = self.client.post('/contacts',
                                 data=json.dumps(contact),
                                 content_type='application/json')
         assert resp.status_code == 200
         assert 'uuid' in resp.data
         assert uuid in resp.data
예제 #12
0
 def test_get_all_users(self):
     contact = {
         "name": "Andrew",
         "surname": "Kembel",
         "country": "USA",
         "city": "Boston",
         "street": "Good",
         "cell_phone": "123212345",
         "home_phone": "67544545890"
     }
     resp = self.client.post('/contacts',
                             data=json.dumps(contact),
                             content_type='application/json')
     uuid = getuuid(contact['name'], contact['surname'])
     resp = self.client.get('/users',
                            data=json.dumps({"limit": 4}),
                            content_type='application/json')
     assert resp.status_code == 200
     assert 'Kembel' in resp.data
예제 #13
0
 def test_del_user_with_not_empty_json_request(self):
     contact = {
         "name": "Andrew",
         "surname": "Kembel",
         "country": "USA",
         "city": "Boston",
         "street": "Good",
         "cell_phone": "123212345",
         "home_phone": "67544545890"
     }
     resp = self.client.post('/contacts',
                             data=json.dumps(contact),
                             content_type='application/json')
     uuid = getuuid(contact['name'], contact['surname'])
     resp = self.client.get('/users/' + uuid,
                            data=json.dumps({"name": "Andrew"}),
                            content_type='application/json')
     assert resp.status_code == 200
     assert '"code": 1012' in resp.data
예제 #14
0
 def test_add_users(self):
     contacts = (
              {"name": "Andrew", "surname": "Kembel",
               "country": "USA", "city": "Boston", "street": "Good",
               "cell_phone": "123212345", "home_phone": "67544545890"},
              {"name": "Ivan", "surname": "Ivanov",
               "country": "Russia", "city": "Ivanovo", "street": "Lenina",
               "cell_phone": "77777777", "home_phone": "999999999999"},
              {"name" : "Petro", "surname": "Kyrychenko",
               "country": "Ukraine", "city": "Lviv", "street": "Mazepy",
               "cell_phone": "53454335", "home_phone": "5634854387543"},
              {"name": "Carlos", "surname": "Rego",
               "country": "France", "city": "Lion",
               "cell_phone": "123212345"},
              {"name": "Andrew", "surname": "Kovtun",
               "country": "USA",
               "home_phone" : "423423423234"}
             )
     for contact in contacts:
         uuid = getuuid(contact['name'], contact['surname'])
         resp = self.client.post('/contacts', data=json.dumps(contact), content_type='application/json')
         assert resp.status_code == 200
         assert 'uuid' in resp.data
         assert uuid in resp.data
예제 #15
0
 def test_del_not_existing_user_by_uuid(self):
     uuid = getuuid("Any", "Name")
     resp = self.client.get('/users/' + uuid, data=json.dumps({}), content_type='application/json')
     assert resp.status_code == 200
     assert '"code": 1004' in resp.data