mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-12 23:56:13 +01:00
- Project.init_project: return Project object
- adjusted testcases
This commit is contained in:
parent
c330700f36
commit
d77f8919fe
@ -851,7 +851,7 @@ class Project:
|
||||
return '\n'.join(r)
|
||||
|
||||
@staticmethod
|
||||
def init_project(apiurl, dir, project, package_tracking=True):
|
||||
def init_project(apiurl, dir, project, package_tracking=True, getPackageList=True, progress_obj=None, wc_check=True):
|
||||
global store
|
||||
|
||||
if not os.path.exists(dir):
|
||||
@ -868,6 +868,7 @@ class Project:
|
||||
store_write_apiurl(dir, apiurl)
|
||||
if package_tracking:
|
||||
store_write_initial_packages(dir, project, [])
|
||||
return Project(dir, getPackageList, progress_obj, wc_check)
|
||||
|
||||
|
||||
class Package:
|
||||
|
@ -1,7 +1,7 @@
|
||||
import osc.core
|
||||
import osc.oscerr
|
||||
import os
|
||||
from common import OscTestCase
|
||||
from common import GET, OscTestCase
|
||||
FIXTURES_DIR = os.path.join(os.getcwd(), 'init_project_fixtures')
|
||||
|
||||
def suite():
|
||||
@ -23,7 +23,8 @@ class TestInitProject(OscTestCase):
|
||||
def test_simple(self):
|
||||
"""initialize a project dir"""
|
||||
prj_dir = os.path.join(self.tmpdir, 'testprj')
|
||||
osc.core.Project.init_project('http://localhost', prj_dir, 'testprj')
|
||||
prj = osc.core.Project.init_project('http://localhost', prj_dir, 'testprj', getPackageList=False)
|
||||
self.assertTrue(isinstance(prj, osc.core.Project))
|
||||
storedir = os.path.join(prj_dir, osc.core.store)
|
||||
self._check_list(os.path.join(storedir, '_project'), 'testprj\n')
|
||||
self._check_list(os.path.join(storedir, '_apiurl'), 'http://localhost\n')
|
||||
@ -33,7 +34,8 @@ class TestInitProject(OscTestCase):
|
||||
"""initialize a project dir but the dir already exists"""
|
||||
prj_dir = os.path.join(self.tmpdir, 'testprj')
|
||||
os.mkdir(prj_dir)
|
||||
osc.core.Project.init_project('http://localhost', prj_dir, 'testprj')
|
||||
prj = osc.core.Project.init_project('http://localhost', prj_dir, 'testprj', getPackageList=False)
|
||||
self.assertTrue(isinstance(prj, osc.core.Project))
|
||||
storedir = os.path.join(prj_dir, osc.core.store)
|
||||
self._check_list(os.path.join(storedir, '_project'), 'testprj\n')
|
||||
self._check_list(os.path.join(storedir, '_apiurl'), 'http://localhost\n')
|
||||
@ -46,11 +48,19 @@ class TestInitProject(OscTestCase):
|
||||
os.mkdir(os.path.join(prj_dir, osc.core.store))
|
||||
self.assertRaises(osc.oscerr.OscIOError, osc.core.Project.init_project, 'http://localhost', prj_dir, 'testprj')
|
||||
|
||||
@GET('http://localhost/source/testprj', text='<directory count="0" />')
|
||||
def test_no_package_tracking(self):
|
||||
"""initialize a project dir but disable package tracking"""
|
||||
"""initialize a project dir but disable package tracking; enable getPackageList=True;
|
||||
disable wc_check (because we didn't disable the package tracking before the Project class
|
||||
was imported therefore REQ_STOREFILES contains '_packages')
|
||||
"""
|
||||
import osc.conf
|
||||
# disable package tracking
|
||||
osc.conf.config['do_package_tracking'] = False
|
||||
prj_dir = os.path.join(self.tmpdir, 'testprj')
|
||||
os.mkdir(prj_dir)
|
||||
osc.core.Project.init_project('http://localhost', prj_dir, 'testprj', False)
|
||||
prj = osc.core.Project.init_project('http://localhost', prj_dir, 'testprj', False, wc_check=False)
|
||||
self.assertTrue(isinstance(prj, osc.core.Project))
|
||||
storedir = os.path.join(prj_dir, osc.core.store)
|
||||
self._check_list(os.path.join(storedir, '_project'), 'testprj\n')
|
||||
self._check_list(os.path.join(storedir, '_apiurl'), 'http://localhost\n')
|
||||
|
Loading…
Reference in New Issue
Block a user