split test
This commit is contained in:
parent
a17f09e04b
commit
617b67df24
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
35
tests/accounts.py
Normal file
35
tests/accounts.py
Normal file
@ -0,0 +1,35 @@
|
||||
from uuid import uuid4
|
||||
|
||||
from tests.utils import test
|
||||
|
||||
def test_accounts_register(client, username, password):
|
||||
print ("REGISTER")
|
||||
|
||||
test(client.accounts.create(username, password), b'ok: user added', 'normal', None)
|
||||
|
||||
print()
|
||||
|
||||
def test_accounts_login(client, username, password):
|
||||
|
||||
print ("LOGIN")
|
||||
|
||||
test(client.login(username, password), b'ok: account valid', "normal", None)
|
||||
|
||||
print()
|
||||
|
||||
def test_accounts_delete(client):
|
||||
|
||||
print ("DELETE")
|
||||
|
||||
test(client.accounts.delete(), b'ok: account has been deleted', 'normal')
|
||||
|
||||
print()
|
||||
|
||||
def test_accounts(client):
|
||||
|
||||
username = uuid4()
|
||||
password = uuid4()
|
||||
|
||||
test_accounts_register(client, username, password)
|
||||
test_accounts_login(client, username, password)
|
||||
test_accounts_delete(client)
|
19
tests/profiles.py
Normal file
19
tests/profiles.py
Normal file
@ -0,0 +1,19 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..')) # Add parent directory to system path
|
||||
|
||||
from tests.utils import test
|
||||
|
||||
from src.profile import Profile
|
||||
|
||||
def test_profiles_get(client):
|
||||
|
||||
print ("GET")
|
||||
|
||||
test(client.profiles.get(1), Profile(username="997e13f5-474d-4fea-b55a-ad8a27b9534b", title=""), "normal")
|
||||
|
||||
print()
|
||||
|
||||
def test_profiles(client):
|
||||
|
||||
test_profiles_get(client)
|
22
tests/test.py
Normal file
22
tests/test.py
Normal file
@ -0,0 +1,22 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..')) # Add parent directory to system path
|
||||
|
||||
from src.client import Client
|
||||
from src import urls
|
||||
|
||||
from tests.accounts import test_accounts
|
||||
from tests.profiles import test_profiles
|
||||
|
||||
def tests():
|
||||
|
||||
client = Client("http://0.0.0.0:8000/")
|
||||
|
||||
print("ACCOUNTS".center(os.get_terminal_size()[0], '-'))
|
||||
test_accounts(client)
|
||||
|
||||
print("PROFILES".center(os.get_terminal_size()[0], '-'))
|
||||
test_profiles(client)
|
||||
|
||||
if __name__ == "__main__":
|
||||
tests()
|
@ -1,70 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..')) # Add parent directory to system path
|
||||
|
||||
from src.client import Client
|
||||
from src.profiles import Profiles
|
||||
from src.profile import Profile
|
||||
from src import urls
|
||||
|
||||
from uuid import uuid4
|
||||
import os
|
||||
|
||||
def test(value, expected_value, title, description = None):
|
||||
print(title, end=" ")
|
||||
if (value == expected_value):
|
||||
print("[OK]")
|
||||
return
|
||||
print ("[ERROR]")
|
||||
print ("expected", expected_value, ", got", value)
|
||||
if not description is None:
|
||||
print (description)
|
||||
|
||||
def test_accounts_register(client, username, password):
|
||||
print ("REGISTER")
|
||||
|
||||
test(client.accounts.create(username, password), b'ok: user added', 'normal', None)
|
||||
|
||||
print()
|
||||
|
||||
def test_accounts_login(client, username, password):
|
||||
|
||||
print ("LOGIN")
|
||||
|
||||
test(client.login(username, password), b'ok: account valid', "normal", None)
|
||||
|
||||
print()
|
||||
|
||||
def test_accounts_delete(client):
|
||||
|
||||
print ("DELETE")
|
||||
|
||||
test(client.accounts.delete(), b'ok: account has been deleted', 'normal')
|
||||
|
||||
print()
|
||||
|
||||
def test_profile_get(client):
|
||||
|
||||
print ("GET")
|
||||
|
||||
test(client.profiles.get(1), Profile(username="997e13f5-474d-4fea-b55a-ad8a27b9534b", title=""), "normal")
|
||||
|
||||
print()
|
||||
|
||||
def tests():
|
||||
|
||||
username = uuid4()
|
||||
password = uuid4()
|
||||
|
||||
client = Client("http://0.0.0.0:8000/")
|
||||
|
||||
print("ACCOUNTS".center(os.get_terminal_size()[0], '-'))
|
||||
test_accounts_register(client, username, password)
|
||||
test_accounts_login(client, username, password)
|
||||
test_accounts_delete(client)
|
||||
|
||||
print("ACCOUNTS".center(os.get_terminal_size()[0], '-'))
|
||||
test_profile_get(client)
|
||||
|
||||
if __name__ == "__main__":
|
||||
tests()
|
9
tests/utils.py
Normal file
9
tests/utils.py
Normal file
@ -0,0 +1,9 @@
|
||||
def test(value, expected_value, title, description = None):
|
||||
print(title, end=" ")
|
||||
if (value == expected_value):
|
||||
print("[OK]")
|
||||
return
|
||||
print ("[ERROR]")
|
||||
print ("expected", expected_value, ", got", value)
|
||||
if not description is None:
|
||||
print (description)
|
Loading…
Reference in New Issue
Block a user