Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add use of computed_name in API #870

Merged
merged 4 commits into from
Oct 15, 2024
Merged

Conversation

joseph-sentry
Copy link
Contributor

if a test has a computed name we want to return that as the test name in the GQL Test Result object instead of its uncomputed name otherwise just return its uncomputed name with the special separation character escaped

@joseph-sentry joseph-sentry requested a review from a team as a code owner October 8, 2024 16:10
@codecov-notifications
Copy link

codecov-notifications bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.31%. Comparing base (7c3c6ae) to head (827093a).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #870   +/-   ##
=======================================
  Coverage   96.31%   96.31%           
=======================================
  Files         823      823           
  Lines       19077    19079    +2     
=======================================
+ Hits        18374    18376    +2     
  Misses        703      703           
Flag Coverage Δ
unit 92.66% <100.00%> (+<0.01%) ⬆️
unit-latest-uploader 92.66% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-qa
Copy link

codecov-qa bot commented Oct 8, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
2676 1 2675 6
View the top 1 failed tests by shortest run time
graphql_api.tests.test_test_result.TestResultTestCase test_fetch_test_result_name_with_computed_name
Stack Traces | 0.382s run time
self = &lt;graphql_api.tests.test_test_result.TestResultTestCase testMethod=test_fetch_test_result_name_with_computed_name&gt;

    def test_fetch_test_result_name_with_computed_name(self) -&gt; None:
        self.test.computed_name = "Computed Name"
        self.test.save()
    
        query = """
            query {
               owner(username: "%s") {
                    repository(name: "%s") {
                        ... on Repository {
                            testAnalytics {
                                results {
                                    edges {
                                        node {
                                            name
                                        }
                                    }
                                }
                            }
                        }
                    }
                 }
            }
        """ % (self.owner.username, self.repository.name)
    
&gt;       result = self.gql_request(query, owner=self.owner)

graphql_api/tests/test_test_result.py:103: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;graphql_api.tests.test_test_result.TestResultTestCase testMethod=test_fetch_test_result_name_with_computed_name&gt;
query = '\n            query {\n               owner(username: "randomOwner") {\n                    repository(name: "today")...                      }\n                        }\n                    }\n                 }\n            }\n        '
provider = 'gh', owner = &lt;Owner: Owner&lt;github/randomOwner&gt;&gt;, variables = None
with_errors = False, okta_signed_in_accounts = [], impersonate_owner = False

    def gql_request(
        self,
        query,
        provider="gh",
        owner=None,
        variables=None,
        with_errors=False,
        okta_signed_in_accounts=[],
        impersonate_owner=False,
    ):
        url = f"/graphql/{provider}"
    
        if owner:
            self.client = Client()
    
            if impersonate_owner:
                staff_owner = OwnerFactory(
                    name="staff_user", service="github", user=UserFactory(is_staff=True)
                )
                self.client.cookies = SimpleCookie({"staff_user": owner.pk})
                self.client.force_login_owner(staff_owner)
            else:
                self.client.force_login_owner(owner)
    
            if okta_signed_in_accounts:
                session = self.client.session
                session[OKTA_SIGNED_IN_ACCOUNTS_SESSION_KEY] = okta_signed_in_accounts
                session.save()
    
        response = self.client.post(
            url,
            {"query": query, "variables": variables or {}},
            content_type="application/json",
        )
&gt;       return response.json() if with_errors else response.json()["data"]
E       KeyError: 'data'

graphql_api/tests/helper.py:44: KeyError

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

Copy link

codecov-public-qa bot commented Oct 8, 2024

Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time.

❌ Failed Test Results:

Completed 2682 tests with 1 failed, 2675 passed and 6 skipped.

View the full list of failed tests

pytest

  • Class name: graphql_api.tests.test_test_result.TestResultTestCase
    Test name: test_fetch_test_result_name_with_computed_name

    self = <graphql_api.tests.test_test_result.TestResultTestCase testMethod=test_fetch_test_result_name_with_computed_name>

    def test_fetch_test_result_name_with_computed_name(self) -> None:
    self.test.computed_name = "Computed Name"
    self.test.save()

    query = """
    query {
    owner(username: "%s") {
    repository(name: "%s") {
    ... on Repository {
    testAnalytics {
    results {
    edges {
    node {
    name
    }
    }
    }
    }
    }
    }
    }
    }
    """ % (self.owner.username, self.repository.name)

    > result = self.gql_request(query, owner=self.owner)

    graphql_api/tests/test_test_result.py:103:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_test_result.TestResultTestCase testMethod=test_fetch_test_result_name_with_computed_name>
    query = '\n query {\n owner(username: "randomOwner") {\n repository(name: "today")... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = <Owner: Owner<github/randomOwner>>, variables = None
    with_errors = False, okta_signed_in_accounts = [], impersonate_owner = False

    def gql_request(
    self,
    query,
    provider="gh",
    owner=None,
    variables=None,
    with_errors=False,
    okta_signed_in_accounts=[],
    impersonate_owner=False,
    ):
    url = f"/graphql/{provider}"

    if owner:
    self.client = Client()

    if impersonate_owner:
    staff_owner = OwnerFactory(
    name="staff_user", service="github", user=UserFactory(is_staff=True)
    )
    self.client.cookies = SimpleCookie({"staff_user": owner.pk})
    self.client.force_login_owner(staff_owner)
    else:
    self.client.force_login_owner(owner)

    if okta_signed_in_accounts:
    session = self.client.session
    session[OKTA_SIGNED_IN_ACCOUNTS_SESSION_KEY] = okta_signed_in_accounts
    session.save()

    response = self.client.post(
    url,
    {"query": query, "variables": variables or {}},
    content_type="application/json",
    )
    > return response.json() if with_errors else response.json()["data"]
    E KeyError: 'data'

    graphql_api/tests/helper.py:44: KeyError

if a test has a computed name we want to return that as the test name
in the GQL Test Result object instead of its uncomputed name
otherwise just return its uncomputed name with the special separation
character escaped
@joseph-sentry joseph-sentry added this pull request to the merge queue Oct 15, 2024
Merged via the queue into main with commit 8945e37 Oct 15, 2024
18 of 19 checks passed
@joseph-sentry joseph-sentry deleted the joseph/computed-name branch October 15, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants