
Problem: the old test suite was extremely inflexible This meant that making new tests took way too much time. + This new rework makes the new client's backend much thinner and less "magical" With less magic going on we can pass way more data more easily to the actual http-request engine making the convenience wrapper over top it much more flexible Translating old tests to the new engine might take a while but for now the old client codebase is completely deprecated and will no longer be used+updated
43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
import subprocess
|
|
import os
|
|
import json
|
|
|
|
class Server:
|
|
def __init__(self, meta: dict):
|
|
self.url = meta.get('url')
|
|
self.wsurl = meta.get('wsurl')
|
|
self.serv_name = meta.get('name')
|
|
|
|
class Admin:
|
|
def __init__(self, user: dict, server: dict):
|
|
self.id = user.get('id')
|
|
self.name = user.get('name')
|
|
self.permissions = user.get('permissions')
|
|
self.secret = user.get('secret')
|
|
self.status = user.get('status')
|
|
self.jwt = None
|
|
|
|
self.server = Server(server)
|
|
|
|
def __str__(self) -> str:
|
|
return f'{self.name}#{self.id}'
|
|
|
|
def create_admin() -> Admin :
|
|
CARGO_BIN = os.getenv('CARGO_BIN')
|
|
|
|
proc = subprocess.run(
|
|
f'cargo run --release -- -c python-tester'.split(),
|
|
text=True, capture_output=True
|
|
)
|
|
try:
|
|
raw = json.loads(proc.stdout)
|
|
user = raw.get('user')
|
|
server = raw.get('server')
|
|
if user is None or server is None:
|
|
return None
|
|
else:
|
|
return Admin(user, server)
|
|
except:
|
|
return None
|
|
|