Exemplo n.º 1
0
 def test_retrive_users_empty_list(self, m):
     m.register_uri('POST',
                    f'http://127.0.0.1:8000/api/authentication/users/',
                    json=[],
                    status_code=200)
     response = UserInteractor.retrive_users_list(
         queryset=User.objects.none())
     self.assertEquals(len(response), 0)
Exemplo n.º 2
0
 def test_create_user_fail_connection_error(self, m):
     m.register_uri('POST',
                    'http://127.0.0.1:5732/api/authentication/signup/',
                    exc=ConnectionError)
     created, app_user, remote_response = UserInteractor.create_user(
         **self.valid_data)
     self.assertFalse(created)
     self.assertIsNone(app_user)
Exemplo n.º 3
0
 def test_convert_queryset_to_list(self, m):
     user1 = self.make_user(username='******')
     user2 = self.make_user(username='******')
     uuid_list = UserInteractor.convert_user_queryset_to_list_uuid(
         User.objects.all())
     self.assertEquals(len(uuid_list), 2)
     self.assertIn(str(user1.uuid), uuid_list)
     self.assertIn(str(user2.uuid), uuid_list)
Exemplo n.º 4
0
 def test_create_user_success(self, m):
     fake_uuid = str(uuid.uuid1())
     m.register_uri('POST',
                    'http://127.0.0.1:8000/api/authentication/signup/',
                    json={'uuid': fake_uuid},
                    status_code=201)
     created, app_user, remote_response = UserInteractor.create_user(
         **self.valid_data)
     self.assertTrue(created)
Exemplo n.º 5
0
 def test_create_user_fail_404(self, m):
     m.register_uri(
         'POST',
         'http://127.0.0.1:8000/random_404/authentication/signup/',
         json={},
         status_code=404)
     created, app_user, remote_response = UserInteractor.create_user(
         **self.valid_data)
     self.assertFalse(created)
     self.assertIsNone(app_user)
Exemplo n.º 6
0
 def test_create_user_fail_already_exist(self, m):
     m.register_uri('POST',
                    'http://127.0.0.1:8000/api/authentication/signup/',
                    json={
                        'username':
                        ['El nombre de usuario ya está en uso.'],
                        'email': ['El correo ya está en uso.']
                    },
                    status_code=400)
     UserInteractor.create_user(**self.valid_data)
     created, app_user, remote_response = UserInteractor.create_user(
         **self.valid_data)
     self.assertFalse(created)
     self.assertIsNone(app_user)
     self.assertEquals(
         remote_response, {
             'username': ['El nombre de usuario ya está en uso.'],
             'email': ['El correo ya está en uso.']
         })
Exemplo n.º 7
0
 def test_retrive_user_info_fail_when_server_handle_404(self, m):
     user = self.make_user(username=self.valid_data['username'])
     user_id = str(user.uuid)
     m.register_uri(
         'POST',
         f'http://127.0.0.1:8000/random_404/authentication/users/{user_id}',
         json={},
         status_code=404)
     found, remote_response = UserInteractor.retrive_user_info(user=user)
     self.assertFalse(found)
     self.assertEquals(len(remote_response), 0)
Exemplo n.º 8
0
 def test_retrive_users_list(self, m):
     user = self.make_user(username=self.valid_data['username'])
     m.register_uri('POST',
                    f'http://127.0.0.1:8000/api/authentication/users/',
                    json=[{
                        'uuid': str(user.uuid)
                    }],
                    status_code=200)
     response = UserInteractor.retrive_users_list(
         queryset=User.objects.all())
     self.assertEquals(len(response), 1)
     self.assertEquals(response[0]['uuid'], str(user.uuid))
Exemplo n.º 9
0
 def test_retrive_user_info(self, m):
     user = self.make_user(username=self.valid_data['username'])
     user_id = str(user.uuid)
     m.register_uri(
         'GET',
         f'http://127.0.0.1:8000/api/authentication/users/{user_id}',
         json={
             'username': user.username,
             'email': user.email,
             'uuid': user_id
         },
         status_code=200)
     found, remote_response = UserInteractor.retrive_user_info(user=user)
     self.assertEquals(remote_response['username'],
                       self.valid_data['username'])
Exemplo n.º 10
0
 def test_create_user_fail_without_valid_data(self, m):
     m.register_uri('POST',
                    'http://127.0.0.1:8000/api/authentication/signup/',
                    json={},
                    status_code=400)
     data = {
         'first_name': '',
         'last_name': '',
         'email': '',
         'username': '',
         'password': '',
         'password_confirmation': ''
     }
     created, app_user, remote_response = UserInteractor.create_user(**data)
     self.assertFalse(created)
     self.assertIsNone(app_user)
Exemplo n.º 11
0
 def test_convert_empty_queryset_to_list(self, m):
     uuid_list = UserInteractor.convert_user_queryset_to_list_uuid(
         User.objects.all())
     self.assertEqual(len(uuid_list), 0)