mirror of
https://github.com/ae-utbm/sith.git
synced 2025-06-30 23:25:19 +00:00
galaxy: add a full galaxy state test
This commit is contained in:
parent
e864f427eb
commit
966ea01c71
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,6 +11,7 @@ dist/
|
||||
env/
|
||||
doc/html
|
||||
data/
|
||||
galaxy/test_galaxy_state.json
|
||||
/static/
|
||||
sith/settings_custom.py
|
||||
sith/search_indexes/
|
||||
|
1
galaxy/ref_galaxy_state.json
Normal file
1
galaxy/ref_galaxy_state.json
Normal file
@ -0,0 +1 @@
|
||||
{"nodes": [{"id": 11, "name": "Com Unity", "mass": 1}, {"id": 0, "name": "Bibou ", "mass": 9}, {"id": 1, "name": "S' Kia", "mass": 10}, {"id": 3, "name": "Subscribed User", "mass": 8}, {"id": 6, "name": "Compte Able", "mass": 8}, {"id": 8, "name": "Richard Batsbak", "mass": 10}, {"id": 9, "name": "S Li", "mass": 8}, {"id": 10, "name": "Kro Phil'", "mass": 2}], "links": [{"source": 10, "target": 1, "value": 12}, {"source": 1, "target": 10, "value": 12}, {"source": 10, "target": 8, "value": 14}, {"source": 8, "target": 10, "value": 14}, {"source": 10, "target": 9, "value": 74}, {"source": 9, "target": 10, "value": 74}, {"source": 9, "target": 1, "value": 3}, {"source": 1, "target": 9, "value": 3}, {"source": 8, "target": 1, "value": 14}, {"source": 1, "target": 8, "value": 14}, {"source": 8, "target": 3, "value": 3}, {"source": 3, "target": 8, "value": 3}, {"source": 8, "target": 6, "value": 3}, {"source": 6, "target": 8, "value": 3}, {"source": 1, "target": 0, "value": 1}, {"source": 0, "target": 1, "value": 1}]}
|
@ -22,6 +22,10 @@
|
||||
#
|
||||
#
|
||||
|
||||
import json
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from django.test import TestCase
|
||||
from django.core.management import call_command
|
||||
|
||||
@ -143,3 +147,18 @@ class GalaxyTest(TestCase):
|
||||
self.client.login(username="root", password="plop")
|
||||
response = self.client.get("/galaxy/2/")
|
||||
self.assertEquals(response.status_code, 404)
|
||||
|
||||
def test_full_galaxy_state(self):
|
||||
Galaxy.rule()
|
||||
Galaxy.make_state()
|
||||
state = Galaxy.objects.first().state
|
||||
|
||||
galaxy_dir = Path(__file__).parent
|
||||
|
||||
# Dump computed state, either for easier debugging, or to copy as new reference if changes are legit
|
||||
(galaxy_dir / "test_galaxy_state.json").write_text(json.dumps(state))
|
||||
|
||||
self.assertEqual(
|
||||
state,
|
||||
json.loads((galaxy_dir / "ref_galaxy_state.json").read_text()),
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user