Пример #1
0
    def testReadonlyTargetDirectory(self):

        # Install a new repo, then change the original repo.
        self._MakeRepo()
        loader.InstallRuntimeDef(self._GetRepoUrl(), self.repo_clone)
        self._CommitFile(b'third contents', b'third commit')
        self.repo[b'refs/tags/latest'] = self.repo[b'refs/heads/master']

        # Make the files in the target dir readonly.
        for dirpath, dirnames, filenames in os.walk(
                six.text_type(self.repo_clone)):
            for name in filenames:
                full_name = os.path.join(dirpath, name)
                os.chmod(full_name, stat.S_IREAD)

        with self.assertRaises(loader.InvalidTargetDirectoryError):
            loader.InstallRuntimeDef(self._GetRepoUrl(), self.repo_clone)

        # Make all the directories read-only.
        for dirpath, dirnames, filenames in os.walk(
                six.text_type(self.repo_clone)):
            for name in dirnames:
                full_name = os.path.join(dirpath, name)
                file_stat = os.stat(full_name)[0]
                os.chmod(full_name, file_stat & ~stat.S_IWRITE)

        with self.assertRaises(loader.InvalidTargetDirectoryError):
            loader.InstallRuntimeDef(self._GetRepoUrl(), self.repo_clone)
Пример #2
0
    def testBasicFlow(self):
        self._MakeRepo()
        loader.InstallRuntimeDef(self._GetRepoUrl(), self.repo_clone)
        self.AssertFileExistsWithContents(b'first contents', self.repo_clone,
                                          'myfile')

        # Verify that updating an existing repo works.  (We do a commit and then
        # update the latest tag to verify that both tags and objects get fetched).
        self._CommitFile(b'third contents', b'third commit')
        self.repo[b'refs/tags/latest'] = self.repo[b'refs/heads/master']
        loader.InstallRuntimeDef(self._GetRepoUrl(), self.repo_clone)
        self.AssertFileExistsWithContents(b'third contents', self.repo_clone,
                                          'myfile')
Пример #3
0
 def testNonGitTargetDirectory(self):
     self._MakeRepo()
     os.mkdir(self.repo_clone)
     with self.assertRaises(loader.InvalidTargetDirectoryError):
         loader.InstallRuntimeDef(
             self._GetRepoUrl(),
             os.path.join(self.temp_path, 'bogus', 'clone'))
Пример #4
0
    def testNoLatestTag(self):
        self._MakeRepo(set_latest=False)
        loader.InstallRuntimeDef(self._GetRepoUrl(), self.repo_clone)

        # Since there's no "latest" tag, we should get the head of "master" which
        # will be the second commit.
        self.AssertFileExistsWithContents(b'second contents', self.repo_clone,
                                          'myfile')
Пример #5
0
    def testTraditionalClients(self):
        self._MakeRepo(start_server=False)
        self.server = (self._GitServerClass()(server.FileSystemBackend(
            self.repo_path), 'localhost', 0))
        self.server_thread = threading.Thread(target=self.server.serve_forever)
        self.server_thread.start()

        loader.InstallRuntimeDef(
            'git://localhost:{port}'.format(
                port=self.server.server_address[1]), self.repo_clone)

        self.AssertFileExistsWithContents(b'first contents', self.repo_clone,
                                          'myfile')
Пример #6
0
 def testCreateFromNoMasterBranch(self):
     self._MakeRepo(set_latest=False,
                    start_server=False,
                    branch='refs/heads/foo')
     loader.InstallRuntimeDef(self.repo_path, self.repo_clone)
Пример #7
0
 def testCreateFromEmptyRepo(self):
     self.repo = repo.Repo.init(self.repo_path, mkdir=True)
     with self.assertRaises(loader.InvalidRepositoryError):
         loader.InstallRuntimeDef(self.repo_path, self.repo_clone)
Пример #8
0
 def testMissingTargetBaseDirectory(self):
     self._MakeRepo()
     with self.assertRaises(loader.InvalidTargetDirectoryError):
         loader.InstallRuntimeDef(
             self._GetRepoUrl(),
             os.path.join(self.temp_path, 'bogus', 'clone'))
Пример #9
0
 def testInvalidURL(self):
     with self.assertRaises(loader.RepositoryCommunicationError):
         loader.InstallRuntimeDef('bogus:protocol', self.repo_clone)
Пример #10
0
    def testLocalRepo(self):
        self._MakeRepo(start_server=False)
        loader.InstallRuntimeDef(self.repo_path, self.repo_clone)

        self.AssertFileExistsWithContents(b'first contents', self.repo_clone,
                                          'myfile')