Exemple #1
0
    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())
Exemple #2
0
    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)
Exemple #3
0
    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)
Exemple #4
0
    def test_set_token_with_invalid_value(self):
        cfg = EobotConfig()

        with self.assertRaises(ValueError):
            # noinspection PyTypeChecker
            cfg.set_token(123)
Exemple #5
0
 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)
Exemple #6
0
 def test_set_token_with_valid_value(self):
     cfg = EobotConfig()
     self.assertIsNone(cfg._token)
     cfg.set_token("token")
     self.assertEqual("token", cfg._token)
Exemple #7
0
    def test_set_token_without_value(self):
        cfg = EobotConfig()

        with self.assertRaises(TypeError):
            # noinspection PyArgumentList
            cfg.set_token()