def test_simple_create(self): self.get_tag.return_value = None self.get_tag_id.return_value = 99 self.verify_name_internal.return_value = None self.context.event_id = 42 self.context.session.user_id = 23 kojihub.create_tag('newtag') # check the insert self.assertEqual(len(self.inserts), 1) insert = self.inserts[0] self.assertEqual(insert.table, 'tag_config') values = { 'arches': '', 'create_event': 42, 'creator_id': 23, 'locked': False, 'maven_include_all': False, 'maven_support': False, 'perm_id': None, 'tag_id': 99, } self.assertEqual(insert.data, values) self.assertEqual(insert.rawdata, {}) insert = self.inserts[0]
def test_tag_wrong_format(self): tag_name = 'test-tag+' # name is longer as expected self.verify_name_internal.side_effect = koji.GenericError with self.assertRaises(koji.GenericError): kojihub.create_tag(tag_name) # not except regex rules self.verify_name_internal.side_effect = koji.GenericError with self.assertRaises(koji.GenericError): kojihub.create_tag(tag_name)
def test_simple_create(self): self.get_tag.return_value = None self.get_tag_id.return_value = 99 self.context.event_id = 42 self.context.session.user_id = 23 kojihub.create_tag('newtag') # check the insert self.assertEqual(len(self.inserts), 1) insert = self.inserts[0] self.assertEqual(insert.table, 'tag_config') values = { 'arches': None, 'create_event': 42, 'creator_id': 23, 'locked': False, 'maven_include_all': False, 'maven_support': False, 'perm_id': None, 'tag_id': 99, } self.assertEqual(insert.data, values) self.assertEqual(insert.rawdata, {}) insert = self.inserts[0]
def test_invalid_archs(self): self.get_tag.return_value = None self.get_tag_id.return_value = 99 self.context.event_id = 42 self.context.session.user_id = 23 with self.assertRaises(koji.GenericError): kojihub.create_tag('newtag', arches=u'ěšč') with self.assertRaises(koji.GenericError): kojihub.create_tag('newtag', arches=u'arch1;arch2') with self.assertRaises(koji.GenericError): kojihub.create_tag('newtag', arches=u'arch1,arch2') self.assertEqual(len(self.inserts), 0)
def test_duplicate(self): self.get_tag.return_value = {'name': 'duptag'} with self.assertRaises(koji.GenericError): kojihub.create_tag('duptag')