Skip to content

Commit

Permalink
re-add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Oct 15, 2024
1 parent 2183e16 commit 90b968b
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions tasks/tests/unit/test_upload_processing_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
from shared.reports.enums import UploadState
from shared.reports.resources import Report, ReportFile, ReportLine, ReportTotals
from shared.storage.exceptions import FileNotInStorageError
from shared.torngit.exceptions import TorngitObjectNotFoundError
from shared.upload.constants import UploadErrorCode

from database.models import CommitReport, ReportDetails, UploadError
from database.tests.factories import CommitFactory, UploadFactory
from helpers.exceptions import ReportEmptyError, ReportExpiredException
from helpers.exceptions import (
ReportEmptyError,
ReportExpiredException,
RepositoryWithoutValidBotError,
)
from helpers.parallel import ParallelProcessing
from rollouts import USE_LABEL_INDEX_IN_REPORT_PROCESSING_BY_REPO_ID
from services.archive import ArchiveService
Expand All @@ -22,7 +27,11 @@
SessionAdjustmentResult,
UploadProcessingResult,
)
from tasks.upload_processor import UploadProcessorTask, save_report_results
from tasks.upload_processor import (
UploadProcessorTask,
load_commit_diff,
save_report_results,
)

here = Path(__file__)

Expand Down Expand Up @@ -1036,6 +1045,29 @@ def test_save_report_results_apply_diff_not_there(
}
assert report.diff_totals is None

def test_load_commit_diff_no_diff(
self, mocker, mock_configuration, dbsession, mock_repo_provider
):
commit = CommitFactory.create()
dbsession.add(commit)
dbsession.flush()
mock_repo_provider.get_commit_diff.side_effect = TorngitObjectNotFoundError(
"response", "message"
)
diff = load_commit_diff(commit, None, None)
assert diff is None

def test_load_commit_diff_no_bot(self, mocker, mock_configuration, dbsession):
commit = CommitFactory.create()
dbsession.add(commit)
dbsession.flush()
mock_get_repo_service = mocker.patch(
"tasks.upload_processor.get_repo_provider_service"
)
mock_get_repo_service.side_effect = RepositoryWithoutValidBotError()
diff = load_commit_diff(commit, None, None)
assert diff is None

def test_save_report_results_apply_diff_valid(
self, mocker, mock_configuration, dbsession, mock_storage
):
Expand Down

0 comments on commit 90b968b

Please sign in to comment.