Esempio n. 1
0
    def test_get_authentication_readonly_with_user_id(self):
        cfg = EobotConfig()
        cfg.set_user_id(123)

        auth = cfg.get_authentication(True)
        self.assertIsInstance(auth, EobotReadonlyAuthentication)
        self.assertEqual(123, auth.user_id)
Esempio n. 2
0
    def test_get_authentication_write_with_user_id_with_email_without_password_or_token(
            self):
        cfg = EobotConfig()
        cfg.set_user_id(123)
        cfg.set_email("email")

        with self.assertRaises(NoPasswordOrTokenError):
            cfg.get_authentication(False)
Esempio n. 3
0
    def test_get_user_id(self):
        cfg = EobotConfig()
        self.assertIsNone(cfg.get_user_id())

        cfg.set_user_id(123)
        self.assertEqual(123, cfg.get_user_id())

        cfg.set_user_id(None)
        self.assertIsNone(cfg.get_user_id())
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
0
    def test_get_authentication_write_with_user_id_without_email(self):
        cfg = EobotConfig()
        cfg.set_user_id(123)

        with self.assertRaises(NoEmailError):
            cfg.get_authentication(False)
Esempio n. 7
0
    def test_set_user_id_with_invalid_value(self):
        cfg = EobotConfig()

        with self.assertRaises(ValueError):
            # noinspection PyTypeChecker
            cfg.set_user_id("123")
Esempio n. 8
0
 def test_set_user_id_with_none_value(self):
     cfg = EobotConfig()
     cfg.configure(user_id=123)
     self.assertEqual(123, cfg._user_id)
     cfg.set_user_id(None)
     self.assertIsNone(cfg._user_id)
Esempio n. 9
0
 def test_set_user_id_with_valid_value(self):
     cfg = EobotConfig()
     self.assertIsNone(cfg._user_id)
     cfg.set_user_id(123)
     self.assertEqual(123, cfg._user_id)
Esempio n. 10
0
    def test_set_user_id_without_value(self):
        cfg = EobotConfig()

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