1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-09 22:36:14 +01:00

- added new testcases for #657838 ("osc 0.130: osc repairwc fails totally - working copy useless")

This commit is contained in:
Marcus Huewe 2010-12-07 20:29:59 +01:00
parent 15178b6e4f
commit fffd0c395a
10 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1 @@
urlwithoutprotocolandtld

View File

@ -0,0 +1 @@
<directory name="invalid_apiurl" rev="1" vrev="1" srcmd5="2738234914de5cc154b1494b1e98d940" />

View File

@ -0,0 +1,11 @@
<package project="remote" name="foo">
<title>Title of New Package</title>
<description>
LONG DESCRIPTION
GOES
HERE
</description>
<person userid="Admin" role="maintainer"/>
<person userid="Admin" role="bugowner"/>
<url>PUT_UPSTREAM_URL_HERE</url>
</package>

View File

@ -0,0 +1 @@
invalid_apiurl

View File

@ -0,0 +1 @@
remote

View File

@ -0,0 +1 @@
noschemeandnotld

View File

@ -0,0 +1 @@
<project name="prj_noapiurl" />

View File

@ -0,0 +1 @@
prj_invalidapiurl

View File

@ -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()