def test_important_metadata_keys_with_spaces(self): project = Project(important_metadata_keys='my key\n') build = Build(project=project) m = { 'my key': 'my value', } with patch('squad.core.models.Build.metadata', m): self.assertEqual({'my key': 'my value'}, build.important_metadata)
def test_important_metadata(self): project = Project(important_metadata_keys='foo1\nfoo2\nmissingkey\n') build = Build(project=project) m = { 'foo1': 'bar1', 'foo2': 'bar2', 'foo3': 'bar3', } with patch('squad.core.models.Build.metadata', m): self.assertEqual({'foo1': 'bar1', 'foo2': 'bar2'}, build.important_metadata) self.assertEqual(True, build.has_extra_metadata)
def test_important_metadata_default(self): project = Project() build = Build(project=project) with patch('squad.core.models.Build.metadata', {'foo': 'bar'}): self.assertEqual({'foo': 'bar'}, build.important_metadata) self.assertEqual({}, build.non_important_metadata)
def get_extra_form_kwargs(self): return {'instance': Project(group=self.group)}
def test_enabled_plugins(self): p = Project(enabled_plugins_list=['aaa', 'bbb']) self.assertEqual(['aaa', 'bbb'], p.enabled_plugins)
def test_enabled_plugins_empty(self): self.assertIsNone(Project().enabled_plugins) self.assertEqual([], Project(enabled_plugins_list=[]).enabled_plugins)
def test_validate_project_settings(self): p = Project(group=self.group, slug='foobar', project_settings='1') with self.assertRaises(ValidationError): p.full_clean() p.project_settings = 'foo: bar\n' p.full_clean()
def test_invalid_slug(self): p = Project(group=self.group, slug='foo/bar') with self.assertRaises(ValidationError): p.full_clean() p.slug = 'foo-bar' p.full_clean() # it this raises no exception, then we are fine
def test_enabled_plugins_empty(self): self.assertEqual([], Project().enabled_plugins)
def test_invalid_slug(self): p = Project(group=self.group, slug='foo/bar') with self.assertRaises(ValidationError): p.full_clean() p.slug = 'foo-bar' p.full_clean() # it this raises no exception, then we are fine