test(config): set up tests with local server

This commit is contained in:
izzy lyseggen
2021-01-18 11:45:01 +00:00
parent 3f986fced3
commit 50c6e2c840
2 changed files with 47 additions and 0 deletions
View File
+47
View File
@@ -0,0 +1,47 @@
import uuid
import pytest
import requests
from speckle.api.client import SpeckleClient
@pytest.fixture(scope="session")
def host():
return "127.0.0.1:3000"
@pytest.fixture(scope="session")
def seed_user(host):
seed = uuid.uuid4().hex
user_dict = {
"email": f"{seed[0:7]}@spockle.com",
"password": "$uper$3cr3tP@ss",
"name": f"{seed[0:7]} Name",
"company": "test spockle",
}
r = requests.post(
url=f"http://{host}/auth/local/register?challenge=pyspeckletests",
data=user_dict,
)
access_code = r.url.split("access_code=")[1]
r_tokens = requests.post(
url=f"http://{host}/auth/token",
json={
"appSecret": "spklwebapp",
"appId": "spklwebapp",
"accessCode": access_code,
"challenge": "pyspeckletests",
},
)
user_dict["token"] = r_tokens.json()["token"]
return user_dict
@pytest.fixture(scope="session")
def client(host, seed_user):
client = SpeckleClient(host=host, use_ssl=False)
client.authenticate(seed_user["token"])
return client