From 09ccc163e80b1cd4956950196336479c0313f08a Mon Sep 17 00:00:00 2001 From: Marcus Huewe Date: Tue, 7 Dec 2010 20:29:59 +0100 Subject: [PATCH] - added new testcases for #657838 ("osc 0.130: osc repairwc fails totally - working copy useless") --- .../osctest/invalid_apiurl/.osc/_apiurl | 1 + .../osctest/invalid_apiurl/.osc/_files | 1 + .../osctest/invalid_apiurl/.osc/_meta | 11 ++++++++++ .../invalid_apiurl/.osc/_osclib_version | 1 + .../osctest/invalid_apiurl/.osc/_package | 1 + .../osctest/invalid_apiurl/.osc/_project | 1 + .../prj_invalidapiurl/.osc/_apiurl | 1 + .../prj_invalidapiurl/.osc/_packages | 1 + .../prj_invalidapiurl/.osc/_project | 1 + tests/test_repairwc.py | 22 +++++++++++++++++++ 10 files changed, 41 insertions(+) create mode 100644 tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_apiurl create mode 100644 tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_files create mode 100644 tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_meta create mode 100644 tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_osclib_version create mode 100644 tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_package create mode 100644 tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_project create mode 100644 tests/repairwc_fixtures/prj_invalidapiurl/.osc/_apiurl create mode 100644 tests/repairwc_fixtures/prj_invalidapiurl/.osc/_packages create mode 100644 tests/repairwc_fixtures/prj_invalidapiurl/.osc/_project diff --git a/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_apiurl b/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_apiurl new file mode 100644 index 00000000..718a28bd --- /dev/null +++ b/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_apiurl @@ -0,0 +1 @@ +urlwithoutprotocolandtld diff --git a/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_files b/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_files new file mode 100644 index 00000000..15245ceb --- /dev/null +++ b/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_files @@ -0,0 +1 @@ + diff --git a/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_meta b/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_meta new file mode 100644 index 00000000..13c51467 --- /dev/null +++ b/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_meta @@ -0,0 +1,11 @@ + + Title of New Package + +LONG DESCRIPTION +GOES +HERE + + + + PUT_UPSTREAM_URL_HERE + diff --git a/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_osclib_version b/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_osclib_version new file mode 100644 index 00000000..d3827e75 --- /dev/null +++ b/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_osclib_version @@ -0,0 +1 @@ +1.0 diff --git a/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_package b/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_package new file mode 100644 index 00000000..2c2226ba --- /dev/null +++ b/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_package @@ -0,0 +1 @@ +invalid_apiurl diff --git a/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_project b/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_project new file mode 100644 index 00000000..9c998f7b --- /dev/null +++ b/tests/repairwc_fixtures/osctest/invalid_apiurl/.osc/_project @@ -0,0 +1 @@ +remote diff --git a/tests/repairwc_fixtures/prj_invalidapiurl/.osc/_apiurl b/tests/repairwc_fixtures/prj_invalidapiurl/.osc/_apiurl new file mode 100644 index 00000000..c2401e47 --- /dev/null +++ b/tests/repairwc_fixtures/prj_invalidapiurl/.osc/_apiurl @@ -0,0 +1 @@ +noschemeandnotld diff --git a/tests/repairwc_fixtures/prj_invalidapiurl/.osc/_packages b/tests/repairwc_fixtures/prj_invalidapiurl/.osc/_packages new file mode 100644 index 00000000..9b61f306 --- /dev/null +++ b/tests/repairwc_fixtures/prj_invalidapiurl/.osc/_packages @@ -0,0 +1 @@ + diff --git a/tests/repairwc_fixtures/prj_invalidapiurl/.osc/_project b/tests/repairwc_fixtures/prj_invalidapiurl/.osc/_project new file mode 100644 index 00000000..d3dc1c2a --- /dev/null +++ b/tests/repairwc_fixtures/prj_invalidapiurl/.osc/_project @@ -0,0 +1 @@ +prj_invalidapiurl diff --git a/tests/test_repairwc.py b/tests/test_repairwc.py index 38d28e36..6fc1fcc7 100644 --- a/tests/test_repairwc.py +++ b/tests/test_repairwc.py @@ -191,6 +191,15 @@ class TestRepairWC(OscTestCase): self.assertEqual(open(os.path.join('.osc', '_apiurl')).read(), 'http://localhost\n') self.assertEqual(p.apiurl, 'http://localhost') + def test_invalidapiurl(self): + """the package wc has an invalid apiurl file (invalid url format)""" + self._change_to_pkg('invalid_apiurl') + p = osc.core.Package('.', wc_check=False) + p.wc_repair('http://localhost') + self.assertTrue(os.path.exists(os.path.join('.osc', '_apiurl'))) + self.assertEqual(open(os.path.join('.osc', '_apiurl')).read(), 'http://localhost\n') + self.assertEqual(p.apiurl, 'http://localhost') + def test_noapiurlNotExistingApiurl(self): """the package wc has no _apiurl file and no apiurl is passed to repairwc""" self._change_to_pkg('noapiurl') @@ -212,6 +221,19 @@ class TestRepairWC(OscTestCase): self.assertTrue(os.path.exists(os.path.join(storedir, '_apiurl'))) self.assertEqual(open(os.path.join(storedir, '_apiurl'), 'r').read(), 'http://localhost\n') + def test_project_invalidapiurl(self): + """the project wc has an invalid _apiurl file (invalid url format)""" + import shutil + prj_dir = os.path.join(self.tmpdir, 'prj_invalidapiurl') + shutil.copytree(os.path.join(self._get_fixtures_dir(), 'prj_invalidapiurl'), prj_dir) + storedir = os.path.join(prj_dir, osc.core.store) + self.assertRaises(osc.oscerr.WorkingCopyInconsistent, osc.core.Project, prj_dir, getPackageList=False) + prj = osc.core.Project(prj_dir, wc_check=False, getPackageList=False) + prj.wc_repair('http://localhost') + self.assertTrue(os.path.exists(os.path.join(storedir, '_apiurl'))) + self.assertTrue(os.path.exists(os.path.join(storedir, '_apiurl'))) + self.assertEqual(open(os.path.join(storedir, '_apiurl'), 'r').read(), 'http://localhost\n') + if __name__ == '__main__': import unittest unittest.main()