Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 57c966c

Browse files
Adjust tests to mock new property
1 parent 6913fdc commit 57c966c

File tree

1 file changed

+7
-140
lines changed

1 file changed

+7
-140
lines changed

graphql_api/tests/test_pull_comparison.py

Lines changed: 7 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ def setUp(self):
5757
self.head_report = self.head_report_patcher.start()
5858
self.head_report.return_value = None
5959
self.addCleanup(self.head_report_patcher.stop)
60+
self.head_report_without_diff_patcher = patch(
61+
"services.comparison.Comparison.head_report_without_applied_diff",
62+
new_callable=PropertyMock,
63+
)
64+
self.head_report_without_diff = self.head_report_without_diff_patcher.start()
65+
self.head_report_without_diff.return_value = None
66+
self.addCleanup(self.head_report_without_diff_patcher.stop)
6067
self.base_report_patcher = patch(
6168
"services.comparison.Comparison.base_report", new_callable=PropertyMock
6269
)
@@ -506,146 +513,6 @@ def test_pull_comparison_impacted_files(
506513
},
507514
}
508515

509-
@patch(
510-
"services.comparison.ComparisonReport.files",
511-
new_callable=PropertyMock,
512-
)
513-
def test_pull_comparison_is_critical_file(self, files_mock):
514-
TestImpactedFile = namedtuple("TestImpactedFile", ["base_name", "head_name"])
515-
516-
files_mock.return_value = [
517-
TestImpactedFile(
518-
base_name="foo.py",
519-
head_name="bar.py",
520-
),
521-
TestImpactedFile(
522-
base_name=None,
523-
head_name="baz.py",
524-
),
525-
]
526-
527-
query = """
528-
pullId
529-
compareWithBase {
530-
... on Comparison {
531-
impactedFiles(filters:{}) {
532-
... on ImpactedFiles {
533-
results {
534-
baseName
535-
headName
536-
isCriticalFile
537-
}
538-
}
539-
... on UnknownFlags {
540-
message
541-
}
542-
}
543-
}
544-
}
545-
"""
546-
547-
res = self._request(query)
548-
assert res == {
549-
"pullId": self.pull.pullid,
550-
"compareWithBase": {
551-
"impactedFiles": {
552-
"results": [
553-
{
554-
"baseName": "foo.py",
555-
"headName": "bar.py",
556-
"isCriticalFile": False,
557-
},
558-
{
559-
"baseName": None,
560-
"headName": "baz.py",
561-
"isCriticalFile": False,
562-
},
563-
]
564-
},
565-
},
566-
}
567-
568-
@patch(
569-
"services.comparison.ComparisonReport.files",
570-
new_callable=PropertyMock,
571-
)
572-
def test_pull_comparison_is_critical_file_returns_false_through_repositories(
573-
self, files_mock
574-
):
575-
TestImpactedFile = namedtuple("TestImpactedFile", ["base_name", "head_name"])
576-
577-
files_mock.return_value = [
578-
TestImpactedFile(
579-
base_name="foo.py",
580-
head_name="bar.py",
581-
),
582-
]
583-
584-
query = """
585-
query {
586-
me {
587-
owner {
588-
repositories (first: 1) {
589-
edges {
590-
node {
591-
pull (id: %s) {
592-
pullId
593-
compareWithBase {
594-
... on Comparison {
595-
impactedFiles(filters:{}) {
596-
... on ImpactedFiles {
597-
results {
598-
baseName
599-
headName
600-
isCriticalFile
601-
}
602-
}
603-
... on UnknownFlags {
604-
message
605-
}
606-
}
607-
}
608-
}
609-
}
610-
}
611-
}
612-
}
613-
}
614-
}
615-
}
616-
"""
617-
618-
data = self.gql_request(query % (self.pull.pullid), owner=self.owner)
619-
620-
assert data == {
621-
"me": {
622-
"owner": {
623-
"repositories": {
624-
"edges": [
625-
{
626-
"node": {
627-
"pull": {
628-
"pullId": 2,
629-
"compareWithBase": {
630-
"impactedFiles": {
631-
"results": [
632-
{
633-
"baseName": "foo.py",
634-
"headName": "bar.py",
635-
"isCriticalFile": False,
636-
}
637-
]
638-
},
639-
},
640-
}
641-
}
642-
}
643-
]
644-
}
645-
}
646-
}
647-
}
648-
649516
@patch(
650517
"services.comparison.PullRequestComparison.get_file_comparison",
651518
)

0 commit comments

Comments
 (0)