def test_cookie_handler_empty_list_if_no_cookie(self): """Test that a CookieHandler retrieves an empty list if the cookie for a project does not exist""" mock_signer = MagicMock() mock_signer.loads = lambda x: x mock_request = MagicMock(cookies={}) project = MagicMock(short_name='my_project') cookie_handler = CookieHandler(request=mock_request, signer=mock_signer) cookie = cookie_handler.get_cookie_from(project) assert cookie == [], cookie
def test_cookie_handler_retrieves_cookie_if_exists(self): """Test that a CookieHandler retrieves a cookie form the request if that exists""" mock_signer = MagicMock() mock_signer.loads = lambda x: x mock_request = MagicMock(cookies={'my_projectpswd': ['a_user']}) project = MagicMock(short_name='my_project') cookie_handler = CookieHandler(request=mock_request, signer=mock_signer) cookie = cookie_handler.get_cookie_from(project) assert cookie == ['a_user'], cookie
def test_cookie_handler_empty_list_if_no_cookie(self): """Test that a CookieHandler retrieves an empty list if the cookie for a project does not exist""" mock_signer = MagicMock() mock_signer.loads = lambda x: x mock_request = MagicMock(cookies={}) project = MagicMock(short_name='my_project') cookie_handler = CookieHandler(request=mock_request, signer=mock_signer) cookie = cookie_handler.get_cookie_from(project) assert cookie == [], cookie
def test_cookie_handler_retrieves_cookie_if_exists(self): """Test that a CookieHandler retrieves a cookie form the request if that exists""" mock_signer = MagicMock() mock_signer.loads = lambda x: x mock_request = MagicMock(cookies={'my_projectpswd': ['a_user']}) project = MagicMock(short_name='my_project') cookie_handler = CookieHandler(request=mock_request, signer=mock_signer) cookie = cookie_handler.get_cookie_from(project) assert cookie == ['a_user'], cookie