From 4d4daa948e8276d90cd94934779d4c3d41b469ab Mon Sep 17 00:00:00 2001 From: Bystroushaak Date: Tue, 3 Nov 2015 15:00:02 +0100 Subject: [PATCH] #5, #12: StatusHandler is now 100% test covered. --- tests/database/test_status_handler.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/database/test_status_handler.py b/tests/database/test_status_handler.py index 71687a4..07f4f36 100755 --- a/tests/database/test_status_handler.py +++ b/tests/database/test_status_handler.py @@ -19,6 +19,7 @@ # Variables =================================================================== USERNAME = "pepa" REST_ID = "some id" +ALT_REST_ID = "something_else" # Fixtures ==================================================================== @@ -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)