-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from jrsmth/feature/improvements/main
[patch] UMA-55-56: test suite extension
- Loading branch information
Showing
15 changed files
with
96 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import base64 | ||
import pytest | ||
from flask import current_app | ||
from src.app.app import app | ||
|
||
|
||
class AdminSpec: | ||
client = app.test_client() | ||
|
||
def should_not_allow_destroy_all_games_when_invalid_creds(self): | ||
response = self.client.get('/flood') | ||
assert response.status_code == 401 | ||
|
||
# TODO :: mock out redis and/or add redis to GH Action | ||
@pytest.mark.skipif('current_app.config["ENV"] == "prod"') | ||
def should_allow_destroy_all_games_when_valid_creds(self): | ||
byte_string = "{0}:{1}".format( | ||
current_app.config["USERNAME"], | ||
current_app.config["PASSWORD"] | ||
).encode() | ||
|
||
creds = base64.b64encode(byte_string).decode("utf-8") | ||
response = self.client.get('/flood', headers={"Authorization": "Basic " + creds}) | ||
assert response.status_code == 204 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class Config(object): | ||
ENV = "local" | ||
APP_URL = "http://localhost:8080" | ||
REDIS_URL = "redis://@localhost:6379/0" | ||
USERNAME = "noah" | ||
|
@@ -7,10 +8,12 @@ class Config(object): | |
|
||
|
||
class DevConfig(Config): | ||
ENV = "dev" | ||
APP_URL = "http://localhost:8080" | ||
REDIS_URL = "rediss://red-cklv99jj89us738u33i0:[email protected]:6379" | ||
|
||
|
||
class ProductionConfig(Config): | ||
ENV = "prod" | ||
APP_URL = "https://www.ultima.jrsmth.io/" | ||
REDIS_URL = 'redis://red-cklv99jj89us738u33i0:6379' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# parsed_html = PyQuery(response.data.decode('utf-8')) | ||
# player_two = parsed_html('span#player-two-name') | ||
# assert player_two.text() == "" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import pytest | ||
from src.app.app import app, redis | ||
from flask import current_app | ||
|
||
|
||
class LoginSpec: | ||
client = app.test_client() | ||
|
||
# TODO :: mock out redis and/or add redis to GH Action | ||
@pytest.mark.skipif('current_app.config["ENV"] == "prod"') | ||
def should_load_login_page_without_error(self): | ||
response = self.client.get("/", content_type="html/text") | ||
assert response.status_code == 200 | ||
assert "Player Name" in response.data.decode('utf-8') | ||
|
||
# TODO :: mock out redis and/or add redis to GH Action | ||
@pytest.mark.skipif('current_app.config["ENV"] == "prod"') | ||
@pytest.mark.parametrize("game_mode,player_mode", [ | ||
("standard", "single"), | ||
("standard", "double"), | ||
("ultimate", "single"), | ||
("ultimate", "double") | ||
]) | ||
def should_create_game_with_game_and_player_modes(self, game_mode, player_mode): | ||
data = { | ||
"name": "test", | ||
"gameId": "", | ||
"gameMode": game_mode, | ||
"playerMode": player_mode | ||
} | ||
|
||
response = self.client.post("/", data=data) | ||
location = response.headers["Location"] | ||
|
||
game_id = location.split("/")[2] | ||
game_state = redis.get_complex(game_id) | ||
assert game_state["game_mode"] == game_mode | ||
assert game_state["player_mode"] == player_mode | ||
|
||
assert response.status_code == 302 | ||
assert "/game" in location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,6 @@ gevent | |
flask_socketio | ||
shortuuid | ||
jsons | ||
Flask-HTTPAuth | ||
Flask-HTTPAuth | ||
from-root | ||
pyquery |
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[pytest] | ||
python_files = *_spec.py | ||
python_functions = should_* | ||
python_classes = *Spec | ||
testpaths = | ||
app | ||
app/admin | ||
app/login | ||
app/game |