Skip to content

Commit

Permalink
Merge pull request #4 from Ajedi32/tests
Browse files Browse the repository at this point in the history
Automated Tests
  • Loading branch information
Ajedi32 committed Dec 3, 2018
2 parents 91a1b2b + f39c122 commit d50ab38
Show file tree
Hide file tree
Showing 16 changed files with 1,005 additions and 5 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ echovr-api = {editable = true, path = "."}
echovr-api = {editable = true, extras = ["docs"], path = "."}
setuptools = "*"
wheel = "*"
pytest = "*"

[requires]
python_version = "3.7"
52 changes: 48 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ For comprehensive documentation of the available methods and classes, please see
To get everything you need to start making changes to this package, first [install Python 3](https://www.python.org/downloads/) and [Pipenv](https://pipenv.readthedocs.io/en/latest/install/), clone this repository, then run:

```
pipenv install
pipenv install --dev
```

### Run the tests

To run all automated tests, run:

```
pipevn run pytest tests/
```

### Try it
Expand Down
Empty file added tests/__init__.py
Empty file.
21 changes: 21 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from os import path, sep
import json
import pytest

DATA_DIR = path.join(path.dirname(__file__), 'data')

def read_json_file(file):
with open(file, "r") as fp:
return json.load(fp)

def json_data(name):
name = name.replace('/', sep)
return read_json_file(path.join(DATA_DIR, f"{name}.json"))

@pytest.fixture(scope="module")
def single_player_private_data():
return json_data('single_player_private')

@pytest.fixture(scope="module")
def standard_public_match_data():
return json_data('standard_public_match')
125 changes: 125 additions & 0 deletions tests/data/single_player_private.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"disc": {
"position": [
0.0,
0.0,
0.0
],
"velocity": [
0.0,
0.0,
0.0
],
"bounce_count": 0
},
"sessionid": "8DFCB732-BF34-497E-B3D2-95D6F659F036",
"orange_points": 0,
"private_match": true,
"client_name": "Ajedi32",
"game_clock_display": "05:00.00",
"game_status": "pre_match",
"game_clock": 300.0,
"match_type": "INVALID GAMETYPE",
"teams": [
{
"players": [
{
"name": "Ajedi32",
"rhand": [
0.40500003,
3.4660001,
-27.412001
],
"playerid": 0,
"position": [
0.19700001,
3.5340002,
-27.876001
],
"lhand": [
0.37900001,
3.4750001,
-27.446001
],
"userid": 1412867812132181,
"stats": {
"possession_time": 0.0,
"points": 0,
"saves": 0,
"goals": 0,
"stuns": 0,
"passes": 0,
"catches": 0,
"steals": 0,
"blocks": 0,
"interceptions": 0,
"assists": 0,
"shots_taken": 0
},
"number": 32,
"level": 50,
"possession": false,
"left": [
0.43300003,
-0.0060000001,
0.90100002
],
"invulnerable": false,
"up": [
0.013,
1.0,
0.0
],
"forward": [
-0.90100002,
0.012,
0.43300003
],
"stunned": false,
"velocity": [
0.0,
0.0,
0.0
],
"blocking": false
}
],
"team": "BLUE TEAM",
"possession": false,
"stats": {
"possession_time": 0.0,
"points": 0,
"goals": 0,
"saves": 0,
"stuns": 0,
"interceptions": 0,
"blocks": 0,
"passes": 0,
"catches": 0,
"steals": 0,
"assists": 0,
"shots_taken": 0
}
},
{
"team": "ORANGE TEAM",
"possession": false
}
],
"map_name": "INVALID LEVEL",
"possession": [
-1,
-1
],
"tournament_match": false,
"blue_points": 0,
"last_score": {
"disc_speed": 0.0,
"team": "blue",
"goal_type": "[NO GOAL]",
"point_amount": 0,
"distance_thrown": 0.0,
"person_scored": "[INVALID]",
"assist_scored": "[INVALID]"
}
}

0 comments on commit d50ab38

Please sign in to comment.