コード例 #1
0
 def test_find_checkout_root(self):
     host = StubRepositoryTest.mock_host_for_stub_repository()
     repository = StubRepository(cwd=host.getcwd(), filesystem=host)
     self.assertEquals(
         repository.find_checkout_root(path=host.join(
             'TestDirectory', 'TestDirectory2', 'TestDirectory3')),
         host.join(host.getcwd(), 'TestDirectory', 'TestDirectory2'))
コード例 #2
0
    def detect_scm_system(self, path, patch_directories=None):
        real_path = self._filesystem.realpath(path)

        if patch_directories == []:
            patch_directories = None

        if SVN.in_working_directory(real_path, executive=self._executive):
            return SVN(cwd=real_path,
                       patch_directories=patch_directories,
                       filesystem=self._filesystem,
                       executive=self._executive)

        if Git.in_working_directory(real_path, executive=self._executive):
            return Git(cwd=real_path,
                       patch_directories=patch_directories,
                       filesystem=self._filesystem,
                       executive=self._executive)

        if StubRepository.in_working_directory(real_path,
                                               filesystem=self._filesystem):
            return StubRepository(cwd=real_path,
                                  patch_directories=patch_directories,
                                  filesystem=self._filesystem,
                                  executive=self._executive)

        return None
コード例 #3
0
 def test_svn_revision(self):
     host = StubRepositoryTest.mock_host_for_stub_repository()
     repository = StubRepository(cwd=host.getcwd(), filesystem=host)
     self.assertEqual(
         repository.svn_revision(path=host.join(host.getcwd(
         ), 'TestDirectory', 'TestDirectory2', 'TestDirectory3')),
         mock_stub_repository_json['id'])
コード例 #4
0
 def test_native_branch(self):
     host = StubRepositoryTest.mock_host_for_stub_repository()
     repository = StubRepository(cwd=host.getcwd(), filesystem=host)
     self.assertEqual(
         repository.native_branch(path=host.join(host.getcwd(
         ), 'TestDirectory', 'TestDirectory2', 'TestDirectory3')),
         mock_stub_repository_json['branch'])
コード例 #5
0
 def test_find_checkout_root_failure(self):
     host = StubRepositoryTest.mock_host_for_stub_repository()
     repository = StubRepository(cwd=host.filesystem.getcwd(),
                                 filesystem=host.filesystem,
                                 executive=host.executive)
     self.assertIsNone(
         repository.find_checkout_root(path=host.filesystem.getcwd()))
コード例 #6
0
 def test_native_revision(self):
     host = StubRepositoryTest.mock_host_for_stub_repository()
     repository = StubRepository(cwd=host.filesystem.getcwd(),
                                 filesystem=host.filesystem,
                                 executive=host.executive)
     self.assertEqual(
         repository.native_revision(
             path=host.filesystem.join(host.filesystem.getcwd(
             ), 'TestDirectory', 'TestDirectory2', 'TestDirectory3')),
         mock_stub_repository_json['id'])
コード例 #7
0
 def test_in_working_directory(self):
     host = StubRepositoryTest.mock_host_for_stub_repository()
     self.assertTrue(
         StubRepository.in_working_directory(path=host.join(
             host.getcwd(), 'TestDirectory', 'TestDirectory2',
             'TestDirectory3'),
                                             filesystem=host))
コード例 #8
0
 def test_find_parent_path_matching_callback_condition_with_file_system(
         self):
     host = StubRepositoryTest.mock_host_for_stub_repository()
     self.assertIsNone(
         StubRepository._find_parent_path_matching_callback_condition(
             path=host.join('TestDirectory'),
             callback=lambda path: True,
             filesystem=host))
コード例 #9
0
 def test_find_parent_path_matching_callback_condition_without_file_system(
         self):
     self.assertIsNone(
         StubRepository._find_parent_path_matching_callback_condition(
             path='/Volumes/', callback=lambda path: True, filesystem=None))