Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Merge branch 'unity' of https://github.com/ocadotechnology/aimmo into…
Browse files Browse the repository at this point in the history
… unity
  • Loading branch information
ramonfmir committed Jul 26, 2017
2 parents ef31b69 + b586f8c commit 38ee4a4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
8 changes: 0 additions & 8 deletions aimmo-game/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ def plain_exit_game(user_id):
user_id = int(user_id)
__exit_game(user_id)
return "EXITING GAME FOR USER " + str(user_id)
@app.route('/plain/server-ready/<user_id>')
def plain_ready(user_id):
user_id = int(user_id)
world_state = world_state_manager.get_world_state(user_id)
if not world_state.ready_to_update:
return "NOT READY"
else:
return "READY"
@app.route('/plain/update/<user_id>')
def plain_update(user_id):
user_id = int(user_id)
Expand Down
14 changes: 11 additions & 3 deletions integration-tests/tests/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ def __init__(self, binder, player_id = 1):
self.world_states = []
self.player_id = player_id

def check_first_world_state(self, world_state):
self.world_states.append(world_state)

def check_player_moved_at_most_one_space(self, last_pos, curr_pos):
if last_pos is None:
return
Expand Down Expand Up @@ -56,9 +53,20 @@ def check_changes_world_state(self):
self.get_player(world_state)
)

def check_only_feature_creations_happen(self, world_state):
pprint(world_state)
for key, feature in world_state['map_features'].iteritems():
if 'update' in feature.keys():
self.binder.assertEqual(len(feature['update']), 0)
if 'delete' in feature.keys():
self.binder.assertEqual(len(feature['delete']), 0)

def check_first_world_state(self):
world_state = self.world_states[-1]

print("Checking only feature creations happen...")
self.check_only_feature_creations_happen(world_state)

def receive_snapshot(self, world_state_string):
world_state = json.loads(world_state_string)

Expand Down
15 changes: 7 additions & 8 deletions integration-tests/tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,19 @@ def level_1(self, kubernates):
self.assertEqual(self.__get_resource("/plain/client-ready/1", 200, host).text, "RECEIVED USER READY 1")

processor = SnapshotProcessor(self)
updates = 5
while updates > 0:
# polling server to see if it is ready
self.__pool_callback(callback=lambda: "NOT READY" not in self.session.get(host + "/plain/server-ready/1").text, tries=30)
snapshots = 100

# TODO: there might be some polling needed
while snapshots > 0:
# getting the world_state
world_state = self.__get_resource("/plain/update/1", 200, host).text

# send the snapshot to the processor
# the processor will track and verify the information
processor.receive_snapshot(world_state)

updates -= 1

# wait a bit so the server internal state changes
time.sleep(0.5)
time.sleep(0.1)
snapshots -= 1

self.assertEqual(self.__get_resource("/plain/exit-game/1", 200, host).text, "EXITING GAME FOR USER 1")

Expand Down Expand Up @@ -217,6 +215,7 @@ def cant_code_without_login(self, kubernates):
@skip("Local.")
def test_local_start_django(self): self.start_django(kubernates=False)

@skip("Problem with finding game by name.")
def test_local_level_1(self): self.level_1(kubernates=False)

@skip("Problem with finding game by name.")
Expand Down

0 comments on commit 38ee4a4

Please sign in to comment.