Ejemplo n.º 1
0
    def test_authenticate_with_invalid_credentials(self, client):
        invalid_email = {'email': '*****@*****.**', 'password': '******'}
        response = post(client, '/auth', invalid_email)
        assert response.status_code == 400

        invalid_password = {'email': '*****@*****.**', 'password': '******'}
        response = post(client, '/auth', invalid_password)
        assert response.status_code == 400
Ejemplo n.º 2
0
 def test_create_user_with_missing_field(self, client):
     body = {
         'email': '*****@*****.**',
         'password': '******',
     }
     response = post(client, '/users', body)
     assert response.status_code == 400
Ejemplo n.º 3
0
 def test_create_item_with_invalid_length(self, client):
     access_token = get_access_token(client)
     long_name = {
         'description': 'g' * 201,
         'image_url': f'https://googl{"e" * 200}.com',
     }
     response = post(client, '/categories/1/items', long_name, access_token)
     assert response.status_code == 400
Ejemplo n.º 4
0
 def test_create_user_with_duplicate_email(self, client):
     body = {
         'email': '*****@*****.**',
         'password': '******',
         'name': 'Duong'
     }
     response = post(client, '/users', body)
     assert response.status_code == 400
Ejemplo n.º 5
0
 def test_authenticate_with_unknown_field(self, client):
     body = {
         'email': '*****@*****.**',
         'password': '******',
         'name': 'Duong'
     }
     response = post(client, '/auth', body)
     assert response.status_code == 400
Ejemplo n.º 6
0
 def test_create_user_with_valid_body(self, client):
     body = {
         'email': '*****@*****.**',
         'password': '******',
         'name': 'Huong'
     }
     response = post(client, '/users', body)
     assert response.status_code == 201
Ejemplo n.º 7
0
 def test_create_user_with_invalid_length(self, client):
     body = {
         'email': f'huon{"g" * 30}@gmail.com',
         'password': '******',
         'name': f'Huon{"g" * 30}'
     }
     response = post(client, '/users', body)
     assert response.status_code == 400
Ejemplo n.º 8
0
 def test_create_user_with_unknown_field(self, client):
     body = {
         'email': '*****@*****.**',
         'password': '******',
         'name': 'Huong',
         'user_name': 'huong'
     }
     response = post(client, '/users', body)
     assert response.status_code == 400
Ejemplo n.º 9
0
 def test_create_item_with_invalid_category_id(self, client):
     access_token = get_access_token(client)
     body = {
         'description':
         'Countryside',
         'image_url':
         'https://upload.wikimedia.org/wikipedia/commons/3/35/Neckertal_20150527-6384.jpg',
     }
     response = post(client, '/categories/5/items', body, access_token)
     assert response.status_code == 404
Ejemplo n.º 10
0
 def test_create_item_with_invalid_type(self, client):
     access_token = get_access_token(client)
     body = {
         'description':
         1234567,
         'image_url':
         'upload.wikimedia.org/wikipedia/commons/3/35/Neckertal_20150527-6384.jpg',
     }
     response = post(client, '/categories/1/items', body, access_token)
     assert response.status_code == 400
Ejemplo n.º 11
0
 def test_create_category_with_unknown_field(self, client):
     access_token = get_access_token(client)
     body = {
         'name': 'Landscape',
         'description': 'Countryside',
         'image_url':
         'https://upload.wikimedia.org/wikipedia/commons/3/35/Neckertal_20150527-6384.jpg',
         'title': 'Beautiful countryside'
     }
     response = post(client, '/categories', body, access_token)
     assert response.status_code == 400
Ejemplo n.º 12
0
 def test_create_category_with_empty_field(self, client):
     access_token = get_access_token(client)
     body = {
         'name':
         '',
         'description':
         '',
         'image_url':
         'https://upload.wikimedia.org/wikipedia/commons/3/35/Neckertal_20150527-6384.jpg',
     }
     response = post(client, '/categories', body, access_token)
     assert response.status_code == 400
Ejemplo n.º 13
0
 def test_create_category_with_valid_body(self, client):
     access_token = get_access_token(client)
     body = {
         'name':
         'Landscape',
         'description':
         'Countryside',
         'image_url':
         'https://upload.wikimedia.org/wikipedia/commons/3/35/Neckertal_20150527-6384.jpg',
     }
     response = post(client, '/categories', body, access_token)
     assert response.status_code == 201
     assert response.get_json()['name'] == body['name']
     assert response.get_json()['description'] == body['description']
     assert response.get_json()['image_url'] == body['image_url']
Ejemplo n.º 14
0
 def test_create_user_with_invalid_type(self, client):
     body = {'email': 'duong', 'password': 123456, 'name': 1234567}
     response = post(client, '/users', body)
     assert response.status_code == 400
Ejemplo n.º 15
0
 def test_authenticate_with_invalid_type(self, client):
     body = {'email': 'duong', 'password': 123456}
     response = post(client, '/auth', body)
     assert response.status_code == 400
Ejemplo n.º 16
0
 def test_create_category_with_missing_field(self, client):
     access_token = get_access_token(client)
     body = {'name': 'Landscape', 'description': 'Countryside'}
     response = post(client, '/categories', body, access_token)
     assert response.status_code == 400
Ejemplo n.º 17
0
    def test_authenticate_with_missing_field(self, client):
        response = post(client, '/auth', {'email': '*****@*****.**'})
        assert response.status_code == 400

        response = post(client, '/auth', {'password': '******'})
        assert response.status_code == 400
Ejemplo n.º 18
0
 def test_authenticate_with_valid_credentials(self, client):
     credential = {'email': '*****@*****.**', 'password': '******'}
     response = post(client, '/auth', credential)
     assert response.status_code == 200