mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
[GHF][BE] Add match_rules test
Also, mark gql_mocks as autogenerated and save them in pretty format Pull Request resolved: https://github.com/pytorch/pytorch/pull/73975 Approved by: https://github.com/suo, https://github.com/seemethere
This commit is contained in:
parent
63a1e7bd09
commit
aed71885cd
1
.gitattributes
vendored
1
.gitattributes
vendored
|
|
@ -2,3 +2,4 @@
|
||||||
.circleci/config.yml linguist-generated=true
|
.circleci/config.yml linguist-generated=true
|
||||||
.github/workflows/generated-*.yml linguist-generated=true
|
.github/workflows/generated-*.yml linguist-generated=true
|
||||||
.github/generated-* linguist-generated=true
|
.github/generated-* linguist-generated=true
|
||||||
|
.github/scripts/gql_mocks.json linguist-generated=true
|
||||||
|
|
|
||||||
1039
.github/scripts/gql_mocks.json
generated
vendored
1039
.github/scripts/gql_mocks.json
generated
vendored
File diff suppressed because one or more lines are too long
14
.github/scripts/test_trymerge.py
vendored
14
.github/scripts/test_trymerge.py
vendored
|
|
@ -2,7 +2,8 @@
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from trymerge import gh_graphql, GitHubPR
|
from trymerge import find_matching_merge_rule, gh_graphql, GitHubPR
|
||||||
|
from gitutils import get_git_remote_name, get_git_repo_dir, GitRepo
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from unittest import TestCase, main, mock
|
from unittest import TestCase, main, mock
|
||||||
|
|
||||||
|
|
@ -17,7 +18,8 @@ def mocked_gh_graphql(query: str, **kwargs: Any) -> Any:
|
||||||
|
|
||||||
def save_mocked_queries(obj: Any) -> None:
|
def save_mocked_queries(obj: Any) -> None:
|
||||||
with open(gql_db_fname, encoding="utf-8", mode="w") as f:
|
with open(gql_db_fname, encoding="utf-8", mode="w") as f:
|
||||||
json.dump(obj, f)
|
json.dump(obj, f, indent=2)
|
||||||
|
f.write("\n")
|
||||||
|
|
||||||
key = f"query_sha={sha256(query.encode('utf-8')).hexdigest()} " + " ".join([f"{k}={kwargs[k]}" for k in sorted(kwargs.keys())])
|
key = f"query_sha={sha256(query.encode('utf-8')).hexdigest()} " + " ".join([f"{k}={kwargs[k]}" for k in sorted(kwargs.keys())])
|
||||||
mocked_queries = get_mocked_queries()
|
mocked_queries = get_mocked_queries()
|
||||||
|
|
@ -34,6 +36,14 @@ def mocked_gh_graphql(query: str, **kwargs: Any) -> Any:
|
||||||
|
|
||||||
|
|
||||||
class TestGitHubPR(TestCase):
|
class TestGitHubPR(TestCase):
|
||||||
|
@mock.patch('trymerge.gh_graphql', side_effect=mocked_gh_graphql)
|
||||||
|
def test_match_rules(self, mocked_gql: Any) -> None:
|
||||||
|
""" Tests that PR passes merge rules
|
||||||
|
"""
|
||||||
|
pr = GitHubPR("pytorch", "pytorch", 71759)
|
||||||
|
repo = GitRepo(get_git_repo_dir(), get_git_remote_name())
|
||||||
|
self.assertTrue(find_matching_merge_rule(pr, repo) is not None)
|
||||||
|
|
||||||
@mock.patch('trymerge.gh_graphql', side_effect=mocked_gh_graphql)
|
@mock.patch('trymerge.gh_graphql', side_effect=mocked_gh_graphql)
|
||||||
def test_get_author_null(self, mocked_gql: Any) -> None:
|
def test_get_author_null(self, mocked_gql: Any) -> None:
|
||||||
""" Tests that PR author can be computed
|
""" Tests that PR author can be computed
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user