def test_repair3(self): """test repair (invalid _packages xml)""" path = self.fixture_file('inv4') self.assertRaises(WCInconsistentError, Project, path) self.assertRaises(ValueError, Project.repair, path) Project.repair(path, added='A', missing=' ') self.assertEqual(Project.wc_check(path), ([], '', []))
def convert_project(path, project='', apiurl='', **package_states): """Convert working copy to the new format. path is the path to the project working copy. Keyword arguments: project -- the name of the project (default: '') apiurl -- the apiurl of the project (default: '') **package_states -- a package to state mapping (default: {}) """ Project.repair(path, project=project, apiurl=apiurl, no_packages=True, **package_states) _write_storefile(path, '_version', str(_VERSION)) project = wc_read_project(path) apiurl = wc_read_apiurl(path) packages = wc_read_packages(path) for entry in packages: package = entry.get('name') package_path = os.path.join(path, package) storedir = wc_pkg_data_mkdir(path, package) convert_package(package_path, project=project, package=package, apiurl=apiurl, ext_storedir=storedir)
def test_repair4(self): """test repair (wc + pkg data missing)""" # remove package from _packages in this case path = self.fixture_file('inv5') self.assertRaises(WCInconsistentError, Project, path) Project.repair(path) self.assertEqual(Project.wc_check(path), ([], '', [])) prj = Project(path) self.assertEqual(prj._status('missing'), '?') self.assertEqual(prj._status('added'), 'A')
def test_repair2(self): """test repair (missing pkg data; state ' ')""" path = self.fixture_file('inv3') self._not_exists(path, 'conflict', data=True) self.assertRaises(WCInconsistentError, Project, path) Project.repair(path) self.assertEqual(Project.wc_check(path), ([], '', [])) self._exists(path, 'conflict', data=True) prj = Project(path) self.assertEqual(prj._status('conflict'), ' ') self.assertIsNotNone(prj.package('conflict'))
def test_repair1(self): """test repair (missing _project and storefile)""" path = self.fixture_file('inv1') self._not_exists(path, '_project', store=True) self.assertRaises(WCInconsistentError, Project, path) self.assertRaises(ValueError, Project.repair, path) Project.repair(path, project='inv1') self.assertEqual(Project.wc_check(path), ([], '', [])) self._exists(path, '_project', store=True) prj = Project(path) self.assertEqual(prj.name, 'inv1')