codecov-api icon indicating copy to clipboard operation
codecov-api copied to clipboard

feat: add use of computed_name in API

Open joseph-sentry opened this issue 1 year ago • 4 comments

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 avatar Oct 08 '24 16:10 joseph-sentry

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

:loudspeaker: Thoughts on this report? Let us know!

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

:white_check_mark: 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%) :arrow_up:
unit-latest-uploader 92.66% <100.00%> (+<0.01%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 08 '24 16:10 codecov[bot]

:x: 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

codecov-qa[bot] avatar Oct 08 '24 18:10 codecov-qa[bot]

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

:x: 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

codecov-public-qa[bot] avatar Oct 08 '24 18:10 codecov-public-qa[bot]