def test_action_attribute_is_working_properly(self): """testing if the action attribute is working properly """ from stalker import AuthenticationLog from stalker.models.auth import LOGIN, LOGOUT import datetime import pytz uli = AuthenticationLog(user=self.test_user1, action=LOGIN, date=datetime.datetime.now(pytz.utc)) self.assertNotEqual(uli.action, LOGOUT) uli.action = LOGOUT self.assertEqual(uli.action, LOGOUT)
def test_action_attribute_value_is_not_login_or_logout(self): """testing if a ValueError will be raised when the action attribute """ from stalker import AuthenticationLog from stalker.models.auth import LOGIN import datetime import pytz uli = AuthenticationLog(user=self.test_user1, action=LOGIN, date=datetime.datetime.now(pytz.utc)) with pytest.raises(ValueError) as cm: uli.action = 'not login' assert str(cm.value) == \ 'AuthenticationLog.action should be one of "login" or "logout", ' \ 'not "not login"'
def test_action_attribute_value_is_not_login_or_logout(self): """testing if a ValueError will be raised when the action attribute """ from stalker import AuthenticationLog from stalker.models.auth import LOGIN import datetime uli = AuthenticationLog( user=self.test_user1, action=LOGIN, date=datetime.datetime.now() ) with self.assertRaises(ValueError) as cm: uli.action = 'not login' self.assertEqual( str(cm.exception), 'AuthenticationLog.action should be one of "login" or "logout", not ' '"not login"' )