class CommandGetModelTest(TestCase): def setUp(self): self.command = Command() def test_existing(self): charmodel = self.command._get_model('charmodel') self.assertEqual(charmodel, models.CharModel) def test_non_existing(self): with self.assertRaises(CommandError): self.command._get_model('FooModel')
def setUp(self): self.command = Command()
class UserHasAccessTest(TestCase): def setUp(self): self.command = Command() def test_default_access(self): self.command._user_has_access('R') self.command._user_has_access('W') @patch('admin_cli.settings.USERS', {}) def test_empty_setting_access(self, *args): self.command._user_has_access('R') self.command._user_has_access('W') @patch('admin_cli.settings.USERS', {os.getlogin(): 'R'}) def test_user_read_access(self, *args): self.command._user_has_access('R') @patch('admin_cli.settings.USERS', {os.getlogin(): 'W'}) def test_user_no_read_access(self, *args): with self.assertRaises(CommandError): self.command._user_has_access('R') @patch('admin_cli.settings.USERS', {os.getuid(): 'R'}) def test_uid_read_access(self, *args): self.command._user_has_access('R') @patch('admin_cli.settings.USERS', {os.getuid(): 'W'}) def test_uid_no_read_access(self, *args): with self.assertRaises(CommandError): self.command._user_has_access('R') @patch('admin_cli.settings.USERS', {'FOOUSER': '******'}) def test_user_not_found(self, *args): with self.assertRaises(CommandError): self.command._user_has_access('R')