Beispiel #1
0
    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)
Beispiel #2
0
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
Beispiel #3
0
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
Beispiel #4
0
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
Beispiel #5
0
def test_login(client):
    create_user()
    creds = {"username": "******", "password": "******"}
    resp = client.post("/auth/login/", json=creds)
    assert resp.status == OK
Beispiel #6
0
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
Beispiel #7
0
def test_login_wrong_password(client):
    create_user()
    creds = {"username": "******", "password": "******"}
    resp = client.post("/auth/login/", json=creds)
    assert resp.status == WRONG_DATA
Beispiel #8
0
def test_login_missing_password(client):
    resp = client.post("/auth/login/", json={"username": "******"})
    assert resp.status == BADPARAMETER
Beispiel #9
0
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
Beispiel #10
0
def test_register_user_empty(client):
    header = get_access_token_header()
    assert client.post("auth/users/", json=dict(),
                       headers=header).status == BADPARAMETER
Beispiel #11
0
def test_login_badparameter(client):
    resp = client.post("/auth/login/", json=dict())
    assert resp.status == BADPARAMETER