Пример #1
0
    def test_runs_git_extraction_after_signing(self):
        old_git_hash = self.version.git_hash

        with transaction.atomic():
            signing.sign_file(self.version.current_file)

        self.version.refresh_from_db()
        assert self.version.git_hash != old_git_hash

        repo = AddonGitRepository(self.addon)

        output = _run_process('git log listed', repo)
        assert output.count('Create new version') == 2
        assert '(after successful signing)' in output

        # 2 actual commits, including the repo initialization
        assert output.count('Mozilla Add-ons Robot') == 3
Пример #2
0
    def test_runs_git_extraction_after_signing(self):
        # Make sure the initial version is already extracted, simulating
        # a regular upload.
        AddonGitRepository.extract_and_commit_from_version(self.version)
        self.version.refresh_from_db()

        old_git_hash = self.version.git_hash

        signing.sign_file(self.file_)

        self.version.refresh_from_db()
        assert self.version.git_hash != old_git_hash

        repo = AddonGitRepository(self.addon)

        output = _run_process('git log listed', repo)
        assert output.count('Create new version') == 2
        assert '(after successful signing)' in output

        # 2 actual commits, including the repo initialization
        assert output.count('Mozilla Add-ons Robot') == 3
Пример #3
0
    def test_commits_to_git_async_signing_happened(self, extract_mock):
        old_git_hash = self.version.git_hash

        def call_sign_file():
            signing.sign_file(self.version.current_file)
            # raise ValueError after the sign_file call so that
            # the extraction is queued via the on_commit hook
            # but the atomic block won't complete.
            raise ValueError()

        with pytest.raises(ValueError):
            with transaction.atomic():
                call_sign_file()

        extract_mock.assert_not_called()

        self.version.refresh_from_db()
        assert self.version.git_hash == old_git_hash

        repo = AddonGitRepository(self.addon)

        output = _run_process('git log listed', repo)
        assert output.count('Create new version') == 1