refactor
This commit is contained in:
parent
debed67c68
commit
217518c00e
|
@ -2,6 +2,7 @@ from flask import url_for
|
||||||
|
|
||||||
from app.db import Session
|
from app.db import Session
|
||||||
from app.models import User, ApiKey, AliasUsedOn, Alias
|
from app.models import User, ApiKey, AliasUsedOn, Alias
|
||||||
|
from tests.utils import login
|
||||||
|
|
||||||
|
|
||||||
def test_different_scenarios_v4(flask_client):
|
def test_different_scenarios_v4(flask_client):
|
||||||
|
@ -98,18 +99,11 @@ def test_different_scenarios_v4_2(flask_client):
|
||||||
|
|
||||||
|
|
||||||
def test_different_scenarios_v5(flask_client):
|
def test_different_scenarios_v5(flask_client):
|
||||||
user = User.create(
|
user = login(flask_client)
|
||||||
email="a@b.c", password="password", name="Test User", activated=True
|
|
||||||
)
|
|
||||||
Session.commit()
|
|
||||||
|
|
||||||
# create api_key
|
|
||||||
api_key = ApiKey.create(user.id, "for test")
|
|
||||||
Session.commit()
|
|
||||||
|
|
||||||
# <<< without hostname >>>
|
# <<< without hostname >>>
|
||||||
r = flask_client.get(
|
r = flask_client.get(
|
||||||
"/api/v5/alias/options", headers={"Authentication": api_key.code}
|
"/api/v5/alias/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
|
@ -129,15 +123,13 @@ def test_different_scenarios_v5(flask_client):
|
||||||
|
|
||||||
# <<< with hostname >>>
|
# <<< with hostname >>>
|
||||||
r = flask_client.get(
|
r = flask_client.get(
|
||||||
"/api/v5/alias/options?hostname=www.test.com",
|
"/api/v5/alias/options?hostname=www.test.com"
|
||||||
headers={"Authentication": api_key.code},
|
|
||||||
)
|
)
|
||||||
assert r.json["prefix_suggestion"] == "test"
|
assert r.json["prefix_suggestion"] == "test"
|
||||||
|
|
||||||
# <<< with hostname with 2 parts TLD, for example wwww.numberoneshoes.co.nz >>>
|
# <<< with hostname with 2 parts TLD, for example wwww.numberoneshoes.co.nz >>>
|
||||||
r = flask_client.get(
|
r = flask_client.get(
|
||||||
"/api/v5/alias/options?hostname=wwww.numberoneshoes.co.nz",
|
"/api/v5/alias/options?hostname=wwww.numberoneshoes.co.nz"
|
||||||
headers={"Authentication": api_key.code},
|
|
||||||
)
|
)
|
||||||
assert r.json["prefix_suggestion"] == "numberoneshoes"
|
assert r.json["prefix_suggestion"] == "numberoneshoes"
|
||||||
|
|
||||||
|
@ -150,8 +142,7 @@ def test_different_scenarios_v5(flask_client):
|
||||||
Session.commit()
|
Session.commit()
|
||||||
|
|
||||||
r = flask_client.get(
|
r = flask_client.get(
|
||||||
url_for("api.options_v4", hostname="www.test.com"),
|
url_for("api.options_v4", hostname="www.test.com")
|
||||||
headers={"Authentication": api_key.code},
|
|
||||||
)
|
)
|
||||||
assert r.json["recommendation"]["alias"] == alias.email
|
assert r.json["recommendation"]["alias"] == alias.email
|
||||||
assert r.json["recommendation"]["hostname"] == "www.test.com"
|
assert r.json["recommendation"]["hostname"] == "www.test.com"
|
||||||
|
|
Loading…
Reference in a new issue