1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

- new testcases for repair_wc: check if the passed parameter is a valid apiurl

This commit is contained in:
Marcus Huewe 2010-12-09 20:32:07 +01:00
parent 67cd6582b5
commit 71bedd4bb1

View File

@ -200,6 +200,14 @@ class TestRepairWC(OscTestCase):
self.assertEqual(open(os.path.join('.osc', '_apiurl')).read(), 'http://localhost\n')
self.assertEqual(p.apiurl, 'http://localhost')
def test_invalidapiurl_param(self):
"""pass an invalid apiurl to wc_repair"""
import urllib2
self._change_to_pkg('invalid_apiurl')
p = osc.core.Package('.', wc_check=False)
self.assertRaises(urllib2.URLError, p.wc_repair, 'http:/localhost')
self.assertRaises(urllib2.URLError, p.wc_repair, 'invalid')
def test_noapiurlNotExistingApiurl(self):
"""the package wc has no _apiurl file and no apiurl is passed to repairwc"""
self._change_to_pkg('noapiurl')
@ -234,6 +242,18 @@ 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_param(self):
"""pass an invalid apiurl to wc_repair"""
import shutil
import urllib2
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)
self.assertRaises(urllib2.URLError, prj.wc_repair, 'http:/localhost')
self.assertRaises(urllib2.URLError, prj.wc_repair, 'invalid')
if __name__ == '__main__':
import unittest
unittest.main()