5 from common import GET, OscTestCase
6 FIXTURES_DIR = os.path.join(os.getcwd(), 'init_project_fixtures')
10 return unittest.makeSuite(TestInitProject)
12 class TestInitProject(OscTestCase):
13 def _get_fixtures_dir(self):
14 # workaround for git because it doesn't allow empty dirs
15 if not os.path.exists(os.path.join(FIXTURES_DIR, 'osctest')):
16 os.mkdir(os.path.join(FIXTURES_DIR, 'osctest'))
20 if os.path.exists(os.path.join(FIXTURES_DIR, 'osctest')):
21 os.rmdir(os.path.join(FIXTURES_DIR, 'osctest'))
22 OscTestCase.tearDown(self)
24 def test_simple(self):
25 """initialize a project dir"""
26 prj_dir = os.path.join(self.tmpdir, 'testprj')
27 osc.core.Project.init_project('http://localhost', prj_dir, 'testprj')
28 storedir = os.path.join(prj_dir, osc.core.store)
29 self._check_list(os.path.join(storedir, '_project'), 'testprj\n')
30 self._check_list(os.path.join(storedir, '_apiurl'), 'http://localhost\n')
31 self._check_list(os.path.join(storedir, '_packages'), '<project name="testprj" />')
33 def test_dirExists(self):
34 """initialize a project dir but the dir already exists"""
35 prj_dir = os.path.join(self.tmpdir, 'testprj')
37 osc.core.Project.init_project('http://localhost', prj_dir, 'testprj')
38 storedir = os.path.join(prj_dir, osc.core.store)
39 self._check_list(os.path.join(storedir, '_project'), 'testprj\n')
40 self._check_list(os.path.join(storedir, '_apiurl'), 'http://localhost\n')
41 self._check_list(os.path.join(storedir, '_packages'), '<project name="testprj" />')
43 def test_storedirExists(self):
44 """initialize a project dir but the storedir already exists"""
45 prj_dir = os.path.join(self.tmpdir, 'testprj')
47 os.mkdir(os.path.join(prj_dir, osc.core.store))
48 self.assertRaises(osc.oscerr.OscIOError, osc.core.Project.init_project, 'http://localhost', prj_dir, 'testprj')
50 def test_no_package_tracking(self):
51 """initialize a project dir but disable package tracking"""
52 prj_dir = os.path.join(self.tmpdir, 'testprj')
54 osc.core.Project.init_project('http://localhost', prj_dir, 'testprj', False)
55 storedir = os.path.join(prj_dir, osc.core.store)
56 self._check_list(os.path.join(storedir, '_project'), 'testprj\n')
57 self._check_list(os.path.join(storedir, '_apiurl'), 'http://localhost\n')
58 self.assertFalse(os.path.exists(os.path.join(storedir, '_packages')))
60 if __name__ == '__main__':