def test_star_family(self):
        """Test LoginManager with '*' as family."""
        lm = LoginManager()
        self.assertEqual(lm.username, FakeUsername)

        del FakeConfig.usernames['*']
        FakeConfig.usernames['*']['en'] = FakeUsername
        self.assertRaises(NoUsername, LoginManager)

        FakeConfig.usernames['*']['*'] = FakeUsername
        lm = LoginManager()
        self.assertEqual(lm.username, FakeUsername)
Пример #2
0
    def test_star_family(self):
        """Test LoginManager with '*' as family."""
        lm = LoginManager()
        self.assertEqual(lm.username, FakeUsername)

        del FakeConfig.usernames['*']
        FakeConfig.usernames['*']['en'] = FakeUsername
        error_undefined_username = '******'
        self.assertRaisesRegex(NoUsername, error_undefined_username,
                               LoginManager)
        FakeConfig.usernames['*']['*'] = FakeUsername
        lm = LoginManager()
        self.assertEqual(lm.username, FakeUsername)
 def test_default_init(self):
     """Test initialization of LoginManager without parameters."""
     obj = LoginManager()
     self.assertIsInstance(obj.site, FakeSite)
     self.assertEqual(obj.username, FakeUsername)
     self.assertEqual(obj.login_name, FakeUsername)
     self.assertIsNone(obj.password)
Пример #4
0
 def test_auto_chmod_not_OK(self):
     """Chmod files that do not have mode private_files_permission."""
     self.stat.return_value.st_mode = 0o100644
     LoginManager()
     self.stat.assert_called_with(self.config.password_file)
     self.chmod.assert_called_once_with(
         self.config.password_file,
         0o600
     )
 def _test_pwfile(self, contents, password):
     self.open.return_value = self._file_lines(contents.split("\n"))
     obj = LoginManager()
     self.assertEqual(obj.password, password)
     return obj
 def test_auto_chmod_OK(self):
     """Do not chmod files that have mode private_files_permission."""
     self.stat.return_value.st_mode = 0o100600
     LoginManager()
     self.stat.assert_called_with(self.config.password_file)
     self.assertFalse(self.chmod.called)
Пример #7
0
 def _test_pwfile(self, contents, password):
     self.open.return_value = StringIO(contents)
     obj = LoginManager()
     self.assertEqual(obj.password, password)
     return obj