-
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.
Improve coverage - add new unit tests.
- Loading branch information
Showing
13 changed files
with
193 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
[run] | ||
omit = | ||
*__init__* | ||
tests\* | ||
tests/* | ||
application/debugger.py | ||
application/alembic/* |
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
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,5 +1,6 @@ | ||
# Hidden folder/file types. | ||
.coverage | ||
htmlcov/ | ||
venv/* | ||
.env | ||
*__pycache__* | ||
|
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
black | ||
coverage | ||
flake8 | ||
pytest | ||
pytest | ||
pytest-mock |
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,43 @@ | ||
"AppState" | ||
{ | ||
"appid" "1829350" | ||
"Universe" "1" | ||
"LauncherPath" "C:\\AgentSmith\\steam\\steamcmd.exe" | ||
"name" "V Rising Dedicated Server" | ||
"StateFlags" "4" | ||
"installdir" "VRisingDedicatedServer" | ||
"LastUpdated" "1710615232" | ||
"LastPlayed" "0" | ||
"SizeOnDisk" "1453745726" | ||
"StagingSize" "0" | ||
"buildid" "12520643" | ||
"LastOwner" "76561200388861161" | ||
"UpdateResult" "0" | ||
"BytesToDownload" "213631952" | ||
"BytesDownloaded" "213631952" | ||
"BytesToStage" "1453745726" | ||
"BytesStaged" "1453745726" | ||
"TargetBuildID" "12520643" | ||
"AutoUpdateBehavior" "0" | ||
"AllowOtherDownloadsWhileRunning" "0" | ||
"ScheduledAutoUpdate" "0" | ||
"InstalledDepots" | ||
{ | ||
"1004" | ||
{ | ||
"manifest" "1923798258558304932" | ||
"size" "44194776" | ||
} | ||
"1829351" | ||
{ | ||
"manifest" "5850011680124575304" | ||
"size" "1409550950" | ||
} | ||
} | ||
"UserConfig" | ||
{ | ||
} | ||
"MountedConfig" | ||
{ | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
tests/unit/resources/steam_manifest/appmanifest_1829350.acf
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,43 @@ | ||
"AppState" | ||
{ | ||
"appid" "1829350" | ||
"Universe" "1" | ||
"LauncherPath" "C:\\AgentSmith\\steam\\steamcmd.exe" | ||
"name" "V Rising Dedicated Server" | ||
"StateFlags" "4" | ||
"installdir" "VRisingDedicatedServer" | ||
"LastUpdated" "1710615232" | ||
"LastPlayed" "0" | ||
"SizeOnDisk" "1453745726" | ||
"StagingSize" "0" | ||
"buildid" "12520643" | ||
"LastOwner" "76561200388861161" | ||
"UpdateResult" "0" | ||
"BytesToDownload" "213631952" | ||
"BytesDownloaded" "213631952" | ||
"BytesToStage" "1453745726" | ||
"BytesStaged" "1453745726" | ||
"TargetBuildID" "12520643" | ||
"AutoUpdateBehavior" "0" | ||
"AllowOtherDownloadsWhileRunning" "0" | ||
"ScheduledAutoUpdate" "0" | ||
"InstalledDepots" | ||
{ | ||
"1004" | ||
{ | ||
"manifest" "1923798258558304932" | ||
"size" "44194776" | ||
} | ||
"1829351" | ||
{ | ||
"manifest" "5850011680124575304" | ||
"size" "1409550950" | ||
} | ||
} | ||
"UserConfig" | ||
{ | ||
} | ||
"MountedConfig" | ||
{ | ||
} | ||
} |
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,45 @@ | ||
from application.common import authorization | ||
|
||
|
||
class FakeRequest: | ||
def __init__(self, headers=None): | ||
self.headers = headers or {} | ||
|
||
|
||
class FakeToken: | ||
def __init__(self) -> None: | ||
self.token_name = "foo" | ||
|
||
|
||
class FakeSetting: | ||
def __init__(self) -> None: | ||
self.setting_value = "bar" | ||
|
||
|
||
class TestAuthorization: | ||
@classmethod | ||
def setup_class(cls): | ||
pass | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
pass | ||
|
||
def test_verify_bearer_token(self, mocker): | ||
# Arrange | ||
fake_headers = {"Authorization": "Bearer 1234"} | ||
fake_request = FakeRequest(headers=fake_headers) | ||
fake_token = FakeToken() | ||
fake_setting = FakeSetting() | ||
|
||
mocker.patch( | ||
"application.common.authorization._get_token", return_value=fake_token | ||
) | ||
mocker.patch( | ||
"application.common.authorization._get_setting", return_value=fake_setting | ||
) | ||
mocker.patch("jwt.decode", return_value={"token_name": "foo"}) | ||
|
||
return_code = authorization._verify_bearer_token(fake_request) | ||
|
||
assert return_code == 200 |
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,35 @@ | ||
import os | ||
|
||
from application.common.steam_manifest_parser import read_acf, parser, read_dir | ||
|
||
|
||
class TestSteamManifestParser: | ||
ACF_FILE_NAME = "appmanifest_1829350.acf" | ||
ACF_FILE_PATH = "" | ||
ACF_FOLDER = "" | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
# Get the current working directory | ||
current_location = os.path.abspath(__file__) | ||
current_folder = os.path.dirname(current_location) | ||
cls.ACF_FOLDER = os.path.join(current_folder, "resources", "steam_manifest") | ||
cls.ACF_FILE_PATH = os.path.join( | ||
current_folder, "resources", "steam_manifest", cls.ACF_FILE_NAME | ||
) | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
pass | ||
|
||
def test_read_dir(self): | ||
steamapps = read_dir(self.ACF_FOLDER) | ||
assert len(steamapps) == 1 | ||
assert "1829350" in steamapps | ||
|
||
def test_read_acf(self): | ||
acf = read_acf(self.ACF_FILE_PATH) | ||
assert acf["appid"] == "1829350" | ||
assert acf["name"] == "V Rising Dedicated Server" | ||
assert acf["StateFlags"] == "4" | ||
assert acf["installdir"] == "VRisingDedicatedServer" |