Skip to content

Commit

Permalink
Adapt tests to new test structure
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo-medici committed Dec 18, 2024
1 parent 204057c commit 838f132
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 109 deletions.
3 changes: 2 additions & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sequenceDiagram
App->>Jira: Searches for existing Jira issues
Jira->>App: Provides list of existing issues if any
App->>Jira: Creates/updates Jira issue
App->>repo: (Optional) Adds 'synced-to-jira' on the Issue
App->>repo: (Optional) Adds a comment on the Issue
App->>GH: Returns web response
Expand Down Expand Up @@ -54,4 +55,4 @@ sequenceDiagram
App1->>repo: (Optional) Adds a comment on the Issue
App1->>GH: Returns web response
```
```
2 changes: 1 addition & 1 deletion github_jira_sync_app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ async def bot(request: Request, payload: dict = Body(...)):
if settings["add_gh_synced_label"]:
try:
repo.get_label(gh_synced_label_name)
issue.add_to_labels(gh_synced_label_name)
gh_issue.add_to_labels(gh_synced_label_name)
except UnknownObjectException:
logger.warning(nonexistent_gh_label_warning)
synced_label_absent_in_repo = True
Expand Down
21 changes: 15 additions & 6 deletions tests/unit/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,20 @@ def test_issue_created_and_sync_label_added(signature_mock):
8. Validate that synced-to-jira label exists in repo
9. Add synced-to-jira label to the issue
"""

responses._add_from_file(UNITTESTS_DIR / "url_responses" / "github_auth.yaml")
responses._add_from_file(
UNITTESTS_DIR / "url_responses" / "github_settings_with_gh_sync_label.yaml"
)
responses._add_from_file(
UNITTESTS_DIR / "url_responses" / "auth_github_responses_sync_label.yaml"
UNITTESTS_DIR / "url_responses" / "github_responses_synced_label_exists.yaml"
)
responses._add_from_file(UNITTESTS_DIR / "url_responses" / "jira_jql_no_issues.yaml")
responses._add_from_file(UNITTESTS_DIR / "url_responses" / "jira_auth_responses.yaml")
responses._add_from_file(UNITTESTS_DIR / "url_responses" / "issue_labeled_correct.yaml")
responses._add_from_file(UNITTESTS_DIR / "url_responses" / "jira_create_issue.yaml")
response = client.post(
"/",
json=_get_json("issue_created_with_label.json"),
json=_get_json("issue_created_without_label.json"),
)

assert response.status_code == 200
Expand All @@ -280,15 +285,19 @@ def test_issue_created_and_sync_label_not_present(signature_mock):
9. Label doesn't exist, warning comment is added to GitHub issue even though
<add_gh_comment> is false
"""
responses._add_from_file(UNITTESTS_DIR / "url_responses" / "github_auth.yaml")
responses._add_from_file(
UNITTESTS_DIR / "url_responses" / "github_settings_with_gh_sync_label.yaml"
)
responses._add_from_file(
UNITTESTS_DIR / "url_responses" / "auth_github_responses_sync_label_not_found.yaml"
UNITTESTS_DIR / "url_responses" / "github_responses_synced_label_notfound.yaml"
)
responses._add_from_file(UNITTESTS_DIR / "url_responses" / "jira_jql_no_issues.yaml")
responses._add_from_file(UNITTESTS_DIR / "url_responses" / "jira_auth_responses.yaml")
responses._add_from_file(UNITTESTS_DIR / "url_responses" / "issue_labeled_correct.yaml")
responses._add_from_file(UNITTESTS_DIR / "url_responses" / "jira_create_issue.yaml")
response = client.post(
"/",
json=_get_json("issue_created_with_label.json"),
json=_get_json("issue_created_without_label.json"),
)

assert response.status_code == 200
Expand Down
50 changes: 0 additions & 50 deletions tests/unit/url_responses/auth_github_responses_sync_label.yaml

This file was deleted.

Loading

0 comments on commit 838f132

Please sign in to comment.