Example #1
0
 def test_get_and_set_date_conf(self):
     with ioutil.TempDir() as td:
         sb = sandbox.layout(td.path, 'foo', 'trunk', 'official')
         now = time.time()
         sb._set_date_conf('info', 'x', now)
         when = sb._get_date_conf('info', 'x')
         self.assertEquals(now, when)
Example #2
0
 def test_inherit_lock_fails_when_same_sandbox_already_locked(self):
     with ioutil.TempDir() as td:
         sb = sandbox.layout(td.path, 'foo', 'trunk', 'x')
         lock = sb.lock('test')
         try:
             lock2 = sb.try_to_inherit_lock()
             self.fail("Expected exception when trying to inherit a lock on a sandbox that's already locked.")
         except:
             pass
Example #3
0
 def test_remove(self):
     temp_dir = tempfile.mkdtemp()
     try:
         sb = sandbox.layout(temp_dir, 'foo', 'trunk', 'official')
         sb.get_sandboxtype().set_should_publish(True)
         self.assertTrue(sb.get_sandboxtype().get_should_publish())
         sb.remove()
         self.assertFalse(os.listdir(temp_dir))
     finally:
         shutil.rmtree(temp_dir)
Example #4
0
 def test_cant_create_inside_existing(self):
     temp_dir = tempfile.mkdtemp()
     try:
         sb = sandbox.layout(temp_dir + '/foo.bar.baz/', 'x', 'y', 'z')
         ok = False
     except:
         ok = True
     shutil.rmtree(temp_dir)
     if not ok:
         self.fail('Expected not to be able to create a sandbox inside an existing sandbox.')
Example #5
0
 def test_inherit_lock(self):
     with ioutil.TempDir() as td:
         sb = sandbox.layout(td.path, 'foo', 'trunk', 'x')
         lock = sb.lock('test')
         sb2 = sandbox.Sandbox(sb.get_root())
         lock2 = sb2.try_to_inherit_lock()
         self.assertTrue(bool(lock2))
         self.assertTrue(lock2.inherited)
         self.assertFalse(lock.inherited)
         lock2.release()
         self.assertTrue(os.path.isfile(lock.path))
Example #6
0
 def test_layout(self):
     with ioutil.TempDir() as td:
         sb = sandbox.layout(td.path, 'foo', 'trunk', 'dev')
         try:
             self.assertTrue(os.path.isdir(sb.get_code_root()))
             self.assertTrue(os.path.isdir(sb.get_built_root()))
             self.assertTrue(os.path.isdir(sb.get_test_root()))
             self.assertTrue(os.path.isdir(sb.get_root()))
             ok = True
         except AssertionError:
             ok = False
     if not ok:
         fail('Layout of sandbox at %s failed.' % sb.get_root())
Example #7
0
 def test_get_iftop_folder_path(self):
     sb = sandbox.Sandbox('foo.trunk.dev')
     path = sb.get_iftop_folder_path()
     # Since component doesn't exist in code root at this point, we should
     # perceive it as a built top-level component.
     self.assertFalse(path.find('/foo.trunk.dev/code/foo/.if_top/') > -1)
     self.assertTrue(path.find('/foo.trunk.dev/built') > -1)
     temp_dir = tempfile.mkdtemp()
     try:
         sb = sandbox.layout(temp_dir, 'foo', 'trunk', 'dev')
         os.makedirs(sb.get_code_root() + 'foo/.bzr')
         path = sb.get_iftop_folder_path()
         # Since component doesn't exist in code root at this point, we should
         # perceive it as a built top-level component.
         self.assertTrue(path.find('/foo.trunk.dev/code/foo/.if_top/') > -1)
     finally:
         shutil.rmtree(temp_dir)