+ More qol like better __str__ methods everywhere

+ More error handling in case shit goes wrong
Basically handling more cases where some initial test could result in the whole
script exiting with code(1)
Not really that big of a deal since most tests after _that_ point will fail anyway
but the fix has revealed issues in the auth code magically so I'm keeping up with the new idea
that initial tests should have every resultant case validated to avoid weird behavior

> good code results in good results
who would have guessed
This commit is contained in:
shockrah 2021-05-08 02:07:32 -07:00
parent cdb956a85c
commit e8348918c4
3 changed files with 17 additions and 3 deletions

View File

@ -30,7 +30,15 @@ class Admin:
self.server = Server(server)
def __str__(self) -> str:
return f'{self.name}#{self.id}'
acc = {
'id': self.id,
'name': self.name,
'permissions': self.permissions,
'secret': self.secret,
'jwt': self.jwt,
}
container = {'user': acc, 'server': str(server)}
return str(container)
def create_admin() -> Admin :
CARGO_BIN = os.getenv('CARGO_BIN')

View File

@ -8,7 +8,7 @@ VOICE_CHAN = 1
TEXT_CHAN = 2
def login(admin: Admin) -> (Request, str):
print(f'Provided admin account {admin.server}')
print(f'Provided admin account {admin}')
req = Request(
admin.server.url + '/login',
'post',
@ -68,9 +68,12 @@ def make_and_receive_invite(admin: Admin) -> (Request, Request):
make_inv_req.fire()
if make_inv_req.response is None:
return (make_inv_req, user_inv_req)
elif make_inv_req.response.status_code >= 400:
print('Params used ', make_inv_req)
return (make_inv_req, None)
# Setup to fire the second request, .fire() is safe to blindly use at this point
print('Response text from /join ', make_inv_req.response.text)
print('Response text from /join ', make_inv_req.response.status_code, ' ', make_inv_req.response.text)
new_invite_body = make_inv_req.response.json()['invite']
code = new_invite_body['id']
user_inv_req = req(admin , 'get' , '/join', {'code': code}, 200, verbose=True)

View File

@ -22,6 +22,9 @@ class Request:
self.verbose = verbose
def __str__(self):
return str(self.qs)
@property
def passing(self):
if self.response is None: