def test_predict(self): response = client.post( url='/predict', json={ 'model': 'vit', 'images': [ { 'url': urls.get('bad_url'), }, { 'url': urls.get('not_found'), }, { 'url': urls.get('correct'), }, ] }, ) self.check_response(response) for image in response.json().get('images'): url = image.get('url') if url == urls.get('bad_url'): self.is_response_image_400(image) if url == urls.get('not_found'): self.is_response_image_404(image) if url == urls.get('correct'): self.is_response_image_predicted(image)
def test_register_user(client): header = get_access_token_header() data = { "username": "******", "password": "******", "email": "*****@*****.**", "role": "Administrator", "confirm_password": "******" } resp = client.post("auth/users/", json=data, headers=header) assert resp.status == INSERTED
def test_register_user_email_missmatch(client): header = get_access_token_header() data = { "username": "******", "password": "******", "email": "mail", "role": "Administrator", "confirm_password": "******" } resp = client.post("auth/users/", json=data, headers=header) assert resp.status == BADPARAMETER and resp.get_json( )['msg'] == EMAIL_MISSMATCH
def test_register_user_user_missmatch(client): header = get_access_token_header() data = { "username": "******", "password": "******", "email": "mail", "role": "Administrator", "confirm_password": "******" } resp = client.post("auth/users/", json=data, headers=header) assert resp.status == DUPLICATE and resp.get_json( )['msg'] == USERNAME_ALREADY_EXISTS
def test_login(client): create_user() creds = {"username": "******", "password": "******"} resp = client.post("/auth/login/", json=creds) assert resp.status == OK
def test_login_change_password(client): create_user(password_change=True) creds = {"username": "******", "password": "******"} resp = client.post("/auth/login/", json=creds) assert resp.status == FORBIDDEN
def test_login_wrong_password(client): create_user() creds = {"username": "******", "password": "******"} resp = client.post("/auth/login/", json=creds) assert resp.status == WRONG_DATA
def test_login_missing_password(client): resp = client.post("/auth/login/", json={"username": "******"}) assert resp.status == BADPARAMETER
def test_register_user_one_missing(client): header = get_access_token_header() data = {"username": "******", "password": "******", "email": "mail"} assert client.post("auth/users/", json=data, headers=header).status == BADPARAMETER
def test_register_user_empty(client): header = get_access_token_header() assert client.post("auth/users/", json=dict(), headers=header).status == BADPARAMETER
def test_login_badparameter(client): resp = client.post("/auth/login/", json=dict()) assert resp.status == BADPARAMETER