Skip to content

Commit

Permalink
#5, #12: StatusHandler is now 100% test covered.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bystroushaak committed Nov 3, 2015
1 parent dc921f6 commit 4d4daa9
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions tests/database/test_status_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Variables ===================================================================
USERNAME = "pepa"
REST_ID = "some id"
ALT_REST_ID = "something_else"


# Fixtures ====================================================================
Expand Down Expand Up @@ -113,10 +114,31 @@ def test_status_handler_save_status_update(status_handler):
assert query == [StatusMessage(m, t)]


def test_query_status_exceptions(status_handler):
def test_status_handler_query_status_exceptions(status_handler):
with pytest.raises(IndexError):
status_handler.query_status(USERNAME, "azgabash")

status_handler.register_status_tracking(USERNAME, "something_else")
status_handler.register_status_tracking(USERNAME, ALT_REST_ID)
with pytest.raises(AccessDeniedException):
status_handler.query_status("azgabash", REST_ID)


def test_status_handler_remove_status_info(status_handler):
assert ALT_REST_ID in status_handler.query_statuses(USERNAME)

with pytest.raises(AccessDeniedException):
status_handler.remove_status_info(
username="tona hluchonemec",
rest_id=ALT_REST_ID,
)

status_handler.remove_status_info(rest_id=ALT_REST_ID)

assert ALT_REST_ID not in status_handler.query_statuses(USERNAME)


def test_status_handler_trigger_garbage_collection(status_handler):
status_handler.trigger_garbage_collection(interval=0)

with pytest.raises(IndexError):
status_handler.query_statuses(USERNAME)

0 comments on commit 4d4daa9

Please sign in to comment.