def test_package6(self): """test package validation (invalid model)""" RemotePackage.SCHEMA = self.fixture_file('package_simple.xsd') pkg = RemotePackage('foo', 'bar') pkg.set('invalidattr', 'yes') self.assertRaises(etree.DocumentInvalid, pkg.validate) self.assertRaises(etree.DocumentInvalid, pkg.store)
def test_package8(self): """test package validation (invalid xml response after store)""" RemotePackage.SCHEMA = self.fixture_file('package_simple.xsd') RemotePackage.PUT_RESPONSE_SCHEMA = self.fixture_file('ok_simple.xsd') pkg = RemotePackage('foo', 'bar') # check that validation is ok pkg.validate() self.assertRaises(etree.DocumentInvalid, pkg.store)
def _commit_deletes(self, cstate): cinfo = cstate.info for package in cinfo.deleted: if cstate.state == CommitStateMixin.STATE_TRANSFER: RemotePackage.delete(self.name, package, apiurl=self.apiurl) cstate.state = CommitStateMixin.STATE_COMMITTING self._remove_wc_dir(package, notify=True) cstate.processed(package, None) self.notifier.processed(package, None, 'D')
def real_obj(self): """Returns a "real" Request object. The returned object is "writable" too that is its state can be changed etc. """ return RemotePackage(xml_data=etree.tostring(self))
def test_package2(self): """create a remote package""" pkg = RemotePackage('openSUSE:Tools', 'osc') debug = pkg.add_debuginfo() debug.add_disable() debug.add_enable(repository='openSUSE_Factory') debug.add_enable(repository='some_repo', arch='i586') pkg.title = 'tiny title' pkg.description = 'some useless\ndescription...' # modify person afterwards person = pkg.add_person(userid='wrongid', role='maintainer') person.set('userid', 'foobar') pkg.store()
def test_package3(self): """get, modify, store remote package""" pkg = RemotePackage.find('openSUSE:Tools', 'osc') # remove debuginfo element del pkg.debuginfo # add build element build = pkg.add_build() build.add_enable(arch='x86_64') build.add_disable(arch='i586') # add devel element pkg.add_devel(project='openSUSE:Factory', package='osc') pkg.store()
def test_package1(self): """get a remote package""" pkg = RemotePackage.find('openSUSE:Tools', 'osc') self.assertEqual(pkg.get('project'), 'openSUSE:Tools') self.assertEqual(pkg.get('name'), 'osc') self.assertEqual(pkg.title, 'tiny title') self.assertEqual(pkg.description, 'some useless\ndescription...') self.assertIsNotNone(pkg.debuginfo.disable) self.assertIsNotNone(pkg.debuginfo.disable[0]) self.assertEqual(pkg.debuginfo.enable[0].get('repository'), 'openSUSE_Factory') self.assertEqual(pkg.debuginfo.enable[1].get('repository'), 'some_repo') self.assertEqual(pkg.debuginfo.enable[1].get('arch'), 'i586') self.assertEqual(pkg.person.get('userid'), 'foobar') self.assertEqual(pkg.person.get('role'), 'maintainer')
def _commit_adds(self, cstate, package_filenames, comment): cinfo = cstate.info tl = self.notifier.listener for package in cinfo.added: if cstate.state == CommitStateMixin.STATE_TRANSFER: # check if package was created in the meantime exists = RemotePackage.exists(self.name, package, apiurl=self.apiurl) if not exists: pkg = RemotePackage(self.name, package) pkg.store(apiurl=self.apiurl) pkg = self.package(package, transaction_listener=tl) filenames = package_filenames.get(package, []) pkg.commit(*filenames, comment=comment) cstate.state = CommitStateMixin.STATE_COMMITTING cstate.processed(package, ' ') self.notifier.processed(package, ' ', 'A')
def test_package12(self): """test delete method""" self.assertFalse(RemotePackage.delete('foo', 'bar'))
def test_package10(self): """test exists method""" self.assertFalse(RemotePackage.exists('newprj', 'foo'))
def test_package4(self): """test package validation""" RemotePackage.SCHEMA = self.fixture_file('package_simple.xsd') pkg = RemotePackage.find('foo', 'bar') pkg.set('project', 'newprj') pkg.store()
def test_package9(self): """test exists method""" self.assertTrue(RemotePackage.exists('newprj', 'bar'))
def test_package5(self): """test package validation""" RemotePackage.SCHEMA = self.fixture_file('package_simple.xsd') RemotePackage.PUT_RESPONSE_SCHEMA = self.fixture_file('ok_simple.xsd') pkg = RemotePackage('newprj', 'bar') pkg.store()