def test_get_token(self): cfg = EobotConfig() self.assertIsNone(cfg.get_token()) cfg.set_token("token") self.assertEqual("token", cfg.get_token()) cfg.set_token(None) self.assertIsNone(cfg.get_token())
def test_get_authentication_write_with_user_id_with_email_without_password_with_token( self): cfg = EobotConfig() cfg.set_user_id(123) cfg.set_email("email") cfg.set_token("token") auth = cfg.get_authentication(False) self.assertIsInstance(auth, EobotWriteAuthentication) self.assertEqual(123, auth.user_id) self.assertEqual("email", auth.email) self.assertEqual("token", auth.password)
def test_get_authentication_write_with_user_id_with_email_with_password_with_token( self): cfg = EobotConfig() cfg.set_user_id(123) cfg.set_email("email") cfg.set_password("password") cfg.set_token("token") auth = cfg.get_authentication(False) self.assertIsInstance(auth, EobotWriteAuthentication) self.assertEqual(123, auth.user_id) self.assertEqual("email", auth.email) # token takes precedence over password, if available self.assertEqual("token", auth.password)
def test_set_token_with_invalid_value(self): cfg = EobotConfig() with self.assertRaises(ValueError): # noinspection PyTypeChecker cfg.set_token(123)
def test_set_token_with_none_value(self): cfg = EobotConfig() cfg.configure(token="token") self.assertEqual("token", cfg._token) cfg.set_token(None) self.assertIsNone(cfg._token)
def test_set_token_with_valid_value(self): cfg = EobotConfig() self.assertIsNone(cfg._token) cfg.set_token("token") self.assertEqual("token", cfg._token)
def test_set_token_without_value(self): cfg = EobotConfig() with self.assertRaises(TypeError): # noinspection PyArgumentList cfg.set_token()