Working on UnitTests

This commit is contained in:
wolfswolke 2023-07-12 16:30:15 +02:00
parent 677a7b0d72
commit f03cff231d
4 changed files with 101 additions and 1 deletions

View File

@ -8,4 +8,6 @@ mongodb:
db: db_name
collection: collection_name
api:
allowed_tokens: token1, token2, token3, token4
allowed_tokens: token1, token2, token3, token4
test_case:
user_cookie: ThisIsAUserCookieString

12
tasks.py Normal file
View File

@ -0,0 +1,12 @@
import os.path
import webbrowser
from invoke import task
@task
def run_unit_tests(c):
print("Running unit tests...")
with c.prefix("cd test"):
c.run("coverage run -m unittest discover")
c.run("coverage html")
webbrowser.open(os.path.abspath("test/index.html"), new=2)

6
test/test_matchmaking.py Normal file
View File

@ -0,0 +1,6 @@
from unittest import TestCase
class TestMatchmaking(TestCase):
def test_matchmaking(self):
self.assertEquals(1, 1)

80
test/test_user.py Normal file
View File

@ -0,0 +1,80 @@
from unittest import TestCase
from flask_definitions import app, mongo_host, mongo_db, mongo_collection
from logic.global_handlers import load_config
from logic.mongodb_handler import mongo
config = load_config()
user_cookie = config["test_case"]["user_cookie"]
class TestUser(TestCase):
def test_steam_login(self):
c = app.test_client()
c.set_cookie('bhvrSession', user_cookie)
c.get('/URL')
self.assertEquals(1, 1)
def test_get_currency(self):
c = app.test_client()
c.set_cookie('bhvrSession', user_cookie)
response = c.get('/api/v1/wallet/currencies')
self.assertEquals(response.status_code, 200)
response_json = response.json
currency_iron = response_json['List'][0]['Balance']
currency_blood_cells = response_json['List'][1]['Balance']
currency_ink_cells = response_json['List'][2]['Balance']
currency_hard = response_json['List'][3]['Balance']
currency_progression = response_json['List'][4]['Balance']
currencies = mongo.get_data_with_list(login=user_cookie("bhvrSession"), login_steam=False,
items={"currency_blood_cells", "currency_iron", "currency_ink_cells"},
server=mongo_host, db=mongo_db, collection=mongo_collection)
self.assertEquals(currency_iron, currencies['currency_iron'])
self.assertEquals(currency_blood_cells, currencies['currency_blood_cells'])
self.assertEquals(currency_ink_cells, currencies['currency_ink_cells'])
self.assertEquals(1, 1)
def test_get_modifiers_me(self):
self.assertEquals(1, 1)
def test_check_username(self):
self.assertEquals(1, 1)
def test_get_progression_experience(self):
self.assertEquals(1, 1)
def test_get_challenges_daily(self):
self.assertEquals(1, 1)
def test_get_challenges_weekly(self):
self.assertEquals(1, 1)
def test_get_specific_challenge(self):
self.assertEquals(1, 1)
def test_get_inventory(self):
self.assertEquals(1, 1)
def test_get_ProgressionGroups(self):
self.assertEquals(1, 1)
def test_get_ban_status(self):
self.assertEquals(1, 1)
def test_get_ban_info(self):
self.assertEquals(1, 1)
def test_get_splinteredstates(self):
self.assertEquals(1, 1)
def test_get_message_list(self):
self.assertEquals(1, 1)
def test_initOrGetGroups(self):
self.assertEquals(1, 1)
def test_unlockSpecialItems(self):
self.assertEquals(1, 1)
def test_getChallengeProgressionBatch(self):
self.assertEquals(1, 1)