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

Conversation

@calvin-codecov
Copy link
Contributor

Purpose/Motivation

What is the feature? Why is this being done?

Cleanup the graphql changes made at #847 as the fields should now be switched onto the new structure.

Links to relevant tickets

Closes codecov/engineering-team#2286

What does this PR do?

Include a brief description of the changes in this PR. Bullet points are your friend.

Notes to Reviewer

Anything to note to the team? Any tips on how to review, or where to start?

@calvin-codecov calvin-codecov requested a review from a team as a code owner October 16, 2024 23:37
@codecov
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.25%. Comparing base (a769cb6) to head (2794a16).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #898      +/-   ##
==========================================
- Coverage   96.26%   96.25%   -0.01%     
==========================================
  Files         823      823              
  Lines       19048    18999      -49     
==========================================
- Hits        18337    18288      -49     
  Misses        711      711              
Flag Coverage Δ
unit 92.52% <ø> (-0.03%) ⬇️
unit-latest-uploader 92.52% <ø> (-0.03%) ⬇️

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-notifications
Copy link

codecov-notifications bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codecov-qa
Copy link

codecov-qa bot commented Oct 16, 2024

❌ 33 Tests Failed:

Tests completed Failed Passed Skipped
2703 33 2670 6
View the top 3 failed tests by shortest run time
graphql_api.tests.test_commit_legacy.TestCommit test_bundle_analysis_report_assets_paginated_first_after
Stack Traces | 0.375s run time
self = &lt;graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_first_after&gt;
get_storage_service = &lt;MagicMock name='get_appropriate_storage_service' id='139779315419088'&gt;

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report_assets_paginated_first_after(
        self, get_storage_service
    ):
        storage = MemoryStorageService({})
        get_storage_service.return_value = storage
    
        head_commit_report = CommitReportFactory(
            commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
        )
    
        with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
            storage_path = StoragePaths.bundle_report.path(
                repo_key=ArchiveService.get_archive_hash(self.repo),
                report_key=head_commit_report.external_id,
            )
            storage.write_file(get_bucket_name(), storage_path, f)
    
        query = """
            query FetchCommit(
                $org: String!,
                $repo: String!,
                $commit: String!,
                $ordering: AssetOrdering,
                $orderingDirection: OrderingDirection
            ) {
                owner(username: $org) {
                    repository(name: $repo) {
                        ... on Repository {
                            commit(id: $commit) {
                                bundleAnalysisReport {
                                    __typename
                                    ... on BundleAnalysisReport {
                                        bundle(name: "b1") {
                                            assetsPaginated (
                                                ordering: $ordering,
                                                orderingDirection: $orderingDirection,
                                                first: 2,
                                                after: "5",
                                            ){
                                                totalCount
                                                edges {
                                                    cursor
                                                    node {
                                                        normalizedName
                                                    }
                                                }
                                                pageInfo {
                                                    hasNextPage
                                                    hasPreviousPage
                                                    startCursor
                                                    endCursor
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        """
    
        variables = {
            "org": self.org.username,
            "repo": self.repo.name,
            "commit": self.commit.commitid,
            "ordering": "NAME",
            "orderingDirection": "ASC",
        }
&gt;       data = self.gql_request(query, variables=variables)

graphql_api/tests/test_commit_legacy.py:1397: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_first_after&gt;
query = '\n            query FetchCommit(\n                $org: String!,\n                $repo: String!,\n                $c...                       }\n                        }\n                    }\n                }\n            }\n        '
provider = 'gh', owner = None
variables = {'commit': 'c313ed46d335eb88e66f5bde6052b88c9b0bb59d', 'ordering': 'NAME', 'orderingDirection': 'ASC', 'org': 'codecov', ...}
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
graphql_api.tests.test_commit_legacy.TestCommit test_flag_names
Stack Traces | 0.378s run time
self = &lt;graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_flag_names&gt;
report_mock = &lt;MagicMock name='build_report_from_commit' id='139780051633504'&gt;

    @patch("shared.reports.api_report_service.build_report_from_commit")
    def test_flag_names(self, report_mock):
        query = query_commit % "flagNames"
        variables = {
            "org": self.org.username,
            "repo": self.repo.name,
            "commit": self.commit.commitid,
            "path": "path",
        }
        report_mock.return_value = MockReport()
&gt;       data = self.gql_request(query, variables=variables)

graphql_api/tests/test_commit_legacy.py:685: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_flag_names&gt;
query = '\nquery FetchCommit($org: String!, $repo: String!, $commit: String!) {\n    owner(username: $org) {\n        reposito...         commit(id: $commit) {\n                    flagNames\n                }\n            }\n        }\n    }\n}\n'
provider = 'gh', owner = None
variables = {'commit': 'd368b6bc6a81216a84d5972db5ccc5a9889d7b9c', 'org': 'codecov', 'path': 'path', 'repo': 'gazebo'}
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
graphql_api.tests.test_commit_legacy.TestCommit test_bundle_analysis_report_assets_paginated_first_after_non_existing_cursor
Stack Traces | 0.381s run time
self = &lt;graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_first_after_non_existing_cursor&gt;
get_storage_service = &lt;MagicMock name='get_appropriate_storage_service' id='139779316360848'&gt;

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report_assets_paginated_first_after_non_existing_cursor(
        self, get_storage_service
    ):
        storage = MemoryStorageService({})
        get_storage_service.return_value = storage
    
        head_commit_report = CommitReportFactory(
            commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
        )
    
        with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
            storage_path = StoragePaths.bundle_report.path(
                repo_key=ArchiveService.get_archive_hash(self.repo),
                report_key=head_commit_report.external_id,
            )
            storage.write_file(get_bucket_name(), storage_path, f)
    
        query = """
            query FetchCommit(
                $org: String!,
                $repo: String!,
                $commit: String!,
                $ordering: AssetOrdering,
                $orderingDirection: OrderingDirection
            ) {
                owner(username: $org) {
                    repository(name: $repo) {
                        ... on Repository {
                            commit(id: $commit) {
                                bundleAnalysisReport {
                                    __typename
                                    ... on BundleAnalysisReport {
                                        bundle(name: "b1") {
                                            assetsPaginated (
                                                ordering: $ordering,
                                                orderingDirection: $orderingDirection,
                                                first: 2,
                                                after: "notanumber",
                                            ){
                                                totalCount
                                                edges {
                                                    cursor
                                                    node {
                                                        normalizedName
                                                    }
                                                }
                                                pageInfo {
                                                    hasNextPage
                                                    hasPreviousPage
                                                    startCursor
                                                    endCursor
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        """
    
        variables = {
            "org": self.org.username,
            "repo": self.repo.name,
            "commit": self.commit.commitid,
            "ordering": "NAME",
            "orderingDirection": "ASC",
        }
&gt;       data = self.gql_request(query, variables=variables)

graphql_api/tests/test_commit_legacy.py:1500: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_first_after_non_existing_cursor&gt;
query = '\n            query FetchCommit(\n                $org: String!,\n                $repo: String!,\n                $c...                       }\n                        }\n                    }\n                }\n            }\n        '
provider = 'gh', owner = None
variables = {'commit': 'd1b81a7e0721e959dcb75dfa4363d81a7a2bd47c', 'ordering': 'NAME', 'orderingDirection': 'ASC', 'org': 'codecov', ...}
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-public-qa
Copy link

codecov-public-qa bot commented Oct 16, 2024

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

❌ Failed Test Results:

Completed 2709 tests with 33 failed, 2670 passed and 6 skipped.

View the full list of failed tests

pytest

  • Class name: graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements
    Test name: test_bundle_asset_measurements

    self = <graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements testMethod=test_bundle_asset_measurements>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779788493056'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_asset_measurements(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    $asset: String!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    asset(name: $asset){
    name
    measurements(
    after: $after
    interval: $interval
    before: $before
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    # Tests can only fetch JS asset
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-06",
    "before": "2024-06-10",
    "asset": "asset-same-name-diff-modules.js",
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_bundle_analysis_measurements_legacy.py:812:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements testMethod=test_bundle_asset_measurements>
    query = '\n query FetchMeasurements(\n $org: String!,\n $repo: String!,\n ... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'after': '2024-06-06', 'asset': 'asset-same-name-diff-modules.js', 'before': '2024-06-10', 'commit': 'd2973e83aa069def9dfbf621ee91a0d872f2ae4c', ...}
    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
  • Class name: graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_branch

    self = <graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements testMethod=test_bundle_report_branch>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779650788992'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_branch(self, get_storage_service):
    measurements_data = [
    # 2024-06-10
    ["bundle_analysis_report_size", "super", "2024-06-10T19:07:23", 123],
    # 2024-06-06
    ["bundle_analysis_report_size", "super", "2024-06-06T19:07:23", 456],
    ]

    for item in measurements_data:
    MeasurementFactory(
    name=item[0],
    owner_id=self.org.pk,
    repo_id=self.repo.pk,
    branch="feat",
    measurable_id=item[1],
    commit_sha=self.commit.pk,
    timestamp=item[2],
    value=item[3],
    )

    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    $branch: String!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    branch: $branch
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-07",
    "before": "2024-06-10",
    "branch": "feat",
    "filters": {},
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_bundle_analysis_measurements_legacy.py:2283:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements testMethod=test_bundle_report_branch>
    query = '\n query FetchMeasurements(\n $org: String!,\n $repo: String!,\n ... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'after': '2024-06-07', 'before': '2024-06-10', 'branch': 'feat', 'commit': '6fe1299caad4104cafce8c0f9c2433bfe71fa8ec', ...}
    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
  • Class name: graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_measurements

    self = <graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements testMethod=test_bundle_report_measurements>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779650788128'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_measurements(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    # Test without using asset type filters
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-06",
    "before": "2024-06-10",
    "filters": {},
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_bundle_analysis_measurements_legacy.py:179:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements testMethod=test_bundle_report_measurements>
    query = '\n query FetchMeasurements(\n $org: String!,\n $repo: String!,\n ... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'after': '2024-06-06', 'before': '2024-06-10', 'commit': '89bb96e278a49b55a244f38ce91cba33bee13a9a', 'filters': {}, ...}
    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
  • Class name: graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_measurements_carryovers

    self = <graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements testMethod=test_bundle_report_measurements_carryovers>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779651802832'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_measurements_carryovers(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    # Test without using asset type filters
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-07",
    "before": "2024-06-10",
    "filters": {},
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_bundle_analysis_measurements_legacy.py:992:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements testMethod=test_bundle_report_measurements_carryovers>
    query = '\n query FetchMeasurements(\n $org: String!,\n $repo: String!,\n ... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'after': '2024-06-07', 'before': '2024-06-10', 'commit': 'a22899f3054d61cfe5d11c72d6b1ac267ddab5f1', 'filters': {}, ...}
    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
  • Class name: graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_no_after

    self = <graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements testMethod=test_bundle_report_no_after>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779789744528'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_no_after(self, get_storage_service):
    measurements_data = [
    # 2024-06-10
    ["bundle_analysis_report_size", "super", "2024-06-10T19:07:23", 123],
    # 2024-06-06
    ["bundle_analysis_report_size", "super", "2024-06-06T19:07:23", 456],
    ]

    for item in measurements_data:
    MeasurementFactory(
    name=item[0],
    owner_id=self.org.pk,
    repo_id=self.repo.pk,
    branch="feat",
    measurable_id=item[1],
    commit_sha=self.commit.pk,
    timestamp=item[2],
    value=item[3],
    )

    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime
    $branch: String!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    branch: $branch
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": None,
    "before": "2024-06-10",
    "branch": "feat",
    "filters": {},
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_bundle_analysis_measurements_legacy.py:2542:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements testMethod=test_bundle_report_no_after>
    query = '\n query FetchMeasurements(\n $org: String!,\n $repo: String!,\n ... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'after': None, 'before': '2024-06-10', 'branch': 'feat', 'commit': '514ab7cf594bd5af77a0e89f9663fcfdd15a8101', ...}
    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
  • Class name: graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements
    Test name: test_bundle_report_no_carryovers

    self = <graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements testMethod=test_bundle_report_no_carryovers>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779787265696'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_report_no_carryovers(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    with open("..../tests/samples/bundle_with_uuid.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=self.head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchMeasurements(
    $org: String!,
    $repo: String!,
    $commit: String!
    $filters: BundleAnalysisMeasurementsSetFilters
    $orderingDirection: OrderingDirection!
    $interval: MeasurementInterval!
    $before: DateTime!
    $after: DateTime!
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "super") {
    name
    measurements(
    filters: $filters
    orderingDirection: $orderingDirection
    after: $after
    interval: $interval
    before: $before
    ){
    assetType
    name
    size {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    change {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    measurements {
    avg
    min
    max
    timestamp
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    # Test without using asset type filters
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "orderingDirection": "ASC",
    "interval": "INTERVAL_1_DAY",
    "after": "2024-06-05",
    "before": "2024-06-10",
    "filters": {},
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_bundle_analysis_measurements_legacy.py:1573:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_bundle_analysis_measurements_legacy.TestBundleAnalysisMeasurements testMethod=test_bundle_report_no_carryovers>
    query = '\n query FetchMeasurements(\n $org: String!,\n $repo: String!,\n ... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'after': '2024-06-05', 'before': '2024-06-10', 'commit': 'f0767b664f20325a5d1dfbbad4e4ef6e40eefeef', 'filters': {}, ...}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_asset

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_asset>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779311442288'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_asset(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open(
    "..../tests/samples/bundle_with_assets_and_modules.sqlite", "rb"
    ) as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "b5") {
    moduleCount
    asset(name: "assets/LazyComponent-fcbb0922.js") {
    name
    normalizedName
    extension
    bundleData {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    modules {
    name
    bundleData {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:1950:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_asset>
    query = '\n query FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'commit': 'bc6a21cd6d8081f2ee37b6cb76ff574121f5d827', 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_asset_filtering

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_asset_filtering>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779311727680'>
    asset_reports_mock = <MagicMock name='asset_reports' id='139779311527328'>

    @patch("shared.bundle_analysis.BundleReport.asset_reports")
    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_asset_filtering(
    self, get_storage_service, asset_reports_mock
    ):
    storage = MemoryStorageService({})

    get_storage_service.return_value = storage
    asset_reports_mock.return_value = []

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open(
    "..../tests/samples/bundle_with_assets_and_modules.sqlite", "rb"
    ) as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!, $filters: BundleAnalysisReportFilters) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "b5", filters: $filters) {
    moduleCount
    assets {
    name
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "filters": {},
    }

    configurations = [
    # No filters
    (
    {"loadTypes": None, "reportGroups": None},
    {"asset_types": None, "chunk_entry": None, "chunk_initial": None},
    ),
    ({}, {"asset_types": None, "chunk_entry": None, "chunk_initial": None}),
    # Just report groups
    (
    {"reportGroups": ["JAVASCRIPT", "FONT"]},
    {
    "asset_types": ["JAVASCRIPT", "FONT"],
    "chunk_entry": None,
    "chunk_initial": None,
    },
    ),
    # Load types -> chunk_entry cancels out
    (
    {"loadTypes": ["ENTRY", "INITIAL"]},
    {"asset_types": None, "chunk_entry": None, "chunk_initial": True},
    ),
    # Load types -> chunk_entry = True
    (
    {"loadTypes": ["ENTRY"]},
    {"asset_types": None, "chunk_entry": True, "chunk_initial": None},
    ),
    # Load types -> chunk_lazy = False
    (
    {"loadTypes": ["LAZY"]},
    {"asset_types": None, "chunk_entry": False, "chunk_initial": False},
    ),
    # Load types -> chunk_initial cancels out
    (
    {"loadTypes": ["LAZY", "INITIAL"]},
    {"asset_types": None, "chunk_entry": False, "chunk_initial": None},
    ),
    # Load types -> chunk_initial = True
    (
    {"loadTypes": ["INITIAL"]},
    {"asset_types": None, "chunk_entry": False, "chunk_initial": True},
    ),
    # Load types -> chunk_initial = False
    (
    {"loadTypes": ["LAZY"]},
    {"asset_types": None, "chunk_entry": False, "chunk_initial": False},
    ),
    ]

    for config in configurations:
    input_d, output_d = config
    variables["filters"] = input_d
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:2122:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_asset_filtering>
    query = '\n query FetchCommit($org: String!, $repo: String!, $commit: String!, $filters: BundleAnalysisReportFilter... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'commit': 'aa1ca1b97e3a608da883ab426479b8945400463d', 'filters': {'loadTypes': None, 'reportGroups': None}, 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_compare

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_compare>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779311107488'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_compare(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    base_commit_report = CommitReportFactory(
    commit=self.parent_commit,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )
    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = (
    query_commit
    % """
    bundleAnalysisCompareWithParent {
    __typename
    ... on BundleAnalysisComparison {
    bundles {
    name
    changeType
    bundleData {
    size {
    uncompress
    }
    }
    bundleChange {
    size {
    uncompress
    }
    }
    }
    bundleData {
    size {
    uncompress
    }
    }
    bundleChange {
    size {
    uncompress
    }
    }
    }
    }
    """
    )

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:859:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_compare>
    query = '\nquery FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $org) {\n reposito... }\n }\n }\n \n }\n }\n }\n }\n}\n'
    provider = 'gh', owner = None
    variables = {'commit': '1b1672d6788e88cf4d5600df1bd0f315dfed956e', 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_compare_with_compare_sha

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_compare_with_compare_sha>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779314057920'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_compare_with_compare_sha(self, get_storage_service):
    """
    This tests creates 3 commits C1 -> C2 -> C3
    C1 uses Report1, C2 and C3 uses Report2
    Normally when doing a compare of C3, it would select C2 as its parent
    then it would show no change, as expected
    However the difference is that in C3's Report2 it has the compareSha set to C1.commitid
    Now when doing comparison of C3, it would now select C1 as the parent
    therefore show correct comparison in numbers between Report1 and Report2
    """
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    commit_1 = CommitFactory(
    repository=self.repo,
    commitid="6ca727b0142bf5625bb82af2555d308862063222",
    )
    commit_2 = CommitFactory(
    repository=self.repo, parent_commit_id=commit_1.commitid
    )
    commit_3 = CommitFactory(
    repository=self.repo, parent_commit_id=commit_2.commitid
    )

    commit_report_1 = CommitReportFactory(
    commit=commit_1,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )

    commit_report_2 = CommitReportFactory(
    commit=commit_2,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )

    commit_report_3 = CommitReportFactory(
    commit=commit_3,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=commit_report_1.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=commit_report_2.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open(
    "..../tests/samples/head_bundle_report_with_compare_sha_6ca727b0142bf5625bb82af2555d308862063222.sqlite",
    "rb",
    ) as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=commit_report_3.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = (
    query_commit
    % """
    bundleAnalysisCompareWithParent {
    __typename
    ... on BundleAnalysisComparison {
    bundleData {
    size {
    uncompress
    }
    }
    bundleChange {
    size {
    uncompress
    }
    }
    }
    }
    """
    )

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": commit_report_3.commit.commitid,
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:989:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_compare_with_compare_sha>
    query = '\nquery FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $org) {\n reposito... }\n }\n }\n \n }\n }\n }\n }\n}\n'
    provider = 'gh', owner = None
    variables = {'commit': 'e50c9dca8c3b46cdbfd0f6aa7e528e283190c618', 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_missing_report

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_missing_report>

    def test_bundle_analysis_missing_report(self):
    query = (
    query_commit
    % """
    bundleAnalysisReport {
    __typename
    ... on MissingHeadReport {
    message
    }
    }
    """
    )
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:1132:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_missing_report>
    query = '\nquery FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $org) {\n reposito... message\n }\n }\n \n }\n }\n }\n }\n}\n'
    provider = 'gh', owner = None
    variables = {'commit': '12dc56cd0d272a63589597b139739ae33959ed63', 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_report

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779316192976'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundles {
    name
    assets {
    normalizedName
    }
    asset(name: "not_exist") {
    normalizedName
    }
    bundleData {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    isCached
    }
    bundleData {
    loadTime {
    threeG
    highSpeed
    }
    size {
    gzip
    uncompress
    }
    }
    bundle(name: "not_exist") {
    name
    isCached
    }
    isCached
    }
    ... on MissingHeadReport {
    message
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:1217:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report>
    query = '\n query FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'commit': '3e811d4483c4fde1e541fc2a9d94ee59d656a4e5', 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_report_assets_paginated_before_and_after_error

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_before_and_after_error>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779312387088'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report_assets_paginated_before_and_after_error(
    self, get_storage_service
    ):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit(
    $org: String!,
    $repo: String!,
    $commit: String!,
    $ordering: AssetOrdering,
    $orderingDirection: OrderingDirection
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "b1") {
    assetsPaginated (
    ordering: $ordering,
    orderingDirection: $orderingDirection,
    before: "1",
    after: "2",
    ){
    totalCount
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    data = self.gql_request(query, with_errors=True, variables=variables)
    > commit = data["data"]["owner"]["repository"]["commit"]
    E KeyError: 'data'

    graphql_api/tests/test_commit_legacy.py:1796: KeyError
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_report_assets_paginated_first_after

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_first_after>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779315419088'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report_assets_paginated_first_after(
    self, get_storage_service
    ):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit(
    $org: String!,
    $repo: String!,
    $commit: String!,
    $ordering: AssetOrdering,
    $orderingDirection: OrderingDirection
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "b1") {
    assetsPaginated (
    ordering: $ordering,
    orderingDirection: $orderingDirection,
    first: 2,
    after: "5",
    ){
    totalCount
    edges {
    cursor
    node {
    normalizedName
    }
    }
    pageInfo {
    hasNextPage
    hasPreviousPage
    startCursor
    endCursor
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "ordering": "NAME",
    "orderingDirection": "ASC",
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:1397:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_first_after>
    query = '\n query FetchCommit(\n $org: String!,\n $repo: String!,\n $c... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'commit': 'c313ed46d335eb88e66f5bde6052b88c9b0bb59d', 'ordering': 'NAME', 'orderingDirection': 'ASC', 'org': 'codecov', ...}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_report_assets_paginated_first_after_non_existing_cursor

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_first_after_non_existing_cursor>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779316360848'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report_assets_paginated_first_after_non_existing_cursor(
    self, get_storage_service
    ):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit(
    $org: String!,
    $repo: String!,
    $commit: String!,
    $ordering: AssetOrdering,
    $orderingDirection: OrderingDirection
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "b1") {
    assetsPaginated (
    ordering: $ordering,
    orderingDirection: $orderingDirection,
    first: 2,
    after: "notanumber",
    ){
    totalCount
    edges {
    cursor
    node {
    normalizedName
    }
    }
    pageInfo {
    hasNextPage
    hasPreviousPage
    startCursor
    endCursor
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "ordering": "NAME",
    "orderingDirection": "ASC",
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:1500:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_first_after_non_existing_cursor>
    query = '\n query FetchCommit(\n $org: String!,\n $repo: String!,\n $c... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'commit': 'd1b81a7e0721e959dcb75dfa4363d81a7a2bd47c', 'ordering': 'NAME', 'orderingDirection': 'ASC', 'org': 'codecov', ...}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_report_assets_paginated_first_and_last_error

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_first_and_last_error>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779347005216'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report_assets_paginated_first_and_last_error(
    self, get_storage_service
    ):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit(
    $org: String!,
    $repo: String!,
    $commit: String!,
    $ordering: AssetOrdering,
    $orderingDirection: OrderingDirection
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "b1") {
    assetsPaginated (
    ordering: $ordering,
    orderingDirection: $orderingDirection,
    first: 1,
    last: 2,
    ){
    totalCount
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    data = self.gql_request(query, with_errors=True, variables=variables)
    > commit = data["data"]["owner"]["repository"]["commit"]
    E KeyError: 'data'

    graphql_api/tests/test_commit_legacy.py:1866: KeyError
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_report_assets_paginated_last_before

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_last_before>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779315422208'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report_assets_paginated_last_before(
    self, get_storage_service
    ):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit(
    $org: String!,
    $repo: String!,
    $commit: String!,
    $ordering: AssetOrdering,
    $orderingDirection: OrderingDirection
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "b1") {
    assetsPaginated (
    ordering: $ordering,
    orderingDirection: $orderingDirection,
    last: 2,
    before: "1",
    ){
    totalCount
    edges {
    cursor
    node {
    normalizedName
    }
    }
    pageInfo {
    hasNextPage
    hasPreviousPage
    startCursor
    endCursor
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "ordering": "NAME",
    "orderingDirection": "ASC",
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:1603:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_last_before>
    query = '\n query FetchCommit(\n $org: String!,\n $repo: String!,\n $c... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'commit': '96bfb0f709dcb74264df5921957b6533dbdfcfdf', 'ordering': 'NAME', 'orderingDirection': 'ASC', 'org': 'codecov', ...}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_report_assets_paginated_last_before_non_existing_cursor

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_last_before_non_existing_cursor>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779650602912'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report_assets_paginated_last_before_non_existing_cursor(
    self, get_storage_service
    ):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit(
    $org: String!,
    $repo: String!,
    $commit: String!,
    $ordering: AssetOrdering,
    $orderingDirection: OrderingDirection
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name: "b1") {
    assetsPaginated (
    ordering: $ordering,
    orderingDirection: $orderingDirection,
    last: 2,
    before: "99999",
    ){
    totalCount
    edges {
    cursor
    node {
    normalizedName
    }
    }
    pageInfo {
    hasNextPage
    hasPreviousPage
    startCursor
    endCursor
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "ordering": "NAME",
    "orderingDirection": "ASC",
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:1706:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_assets_paginated_last_before_non_existing_cursor>
    query = '\n query FetchCommit(\n $org: String!,\n $repo: String!,\n $c... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'commit': '82d11569b47876ba82f171edfd57e903c5edc47e', 'ordering': 'NAME', 'orderingDirection': 'ASC', 'org': 'codecov', ...}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_report_gzip_size_total

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_gzip_size_total>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779647963744'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report_gzip_size_total(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open(
    "..../tests/samples/head_bundle_report_with_gzip_size.sqlite", "rb"
    ) as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundles {
    name
    bundleData {
    size {
    gzip
    uncompress
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:2544:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_gzip_size_total>
    query = '\n query FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'commit': 'f57cf340852cd6ff4aba6202614615f8cc4a9a25', 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_report_size_filtered

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_size_filtered>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779648851744'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report_size_filtered(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage
    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )
    with open(
    "..../tests/samples/head_bundle_report_with_gzip_size.sqlite", "rb"
    ) as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)
    query = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!, $bundleFilters: BundleReportFilters) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name:"b1") {
    name
    bundleDataFiltered(filters: $bundleFilters) {
    size {
    gzip
    uncompress
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "bundleFilters": {"reportGroup": "JAVASCRIPT"},
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:2640:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_size_filtered>
    query = '\n query FetchCommit($org: String!, $repo: String!, $commit: String!, $bundleFilters: BundleReportFilters)... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'bundleFilters': {'reportGroup': 'JAVASCRIPT'}, 'commit': 'b957566062dfd0bf53714ed67ea72957d71f35d2', 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_report_size_filtered_no_value

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_size_filtered_no_value>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139780051875600'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_report_size_filtered_no_value(self, get_storage_service):
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage
    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )
    with open(
    "..../tests/samples/head_bundle_report_with_gzip_size.sqlite", "rb"
    ) as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)
    query = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!, $bundleFilters: BundleReportFilters) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    bundleAnalysisReport {
    __typename
    ... on BundleAnalysisReport {
    bundle(name:"b1") {
    name
    bundleDataFiltered(filters: $bundleFilters) {
    size {
    gzip
    uncompress
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    """
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "bundleFilters": {},
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:2697:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_report_size_filtered_no_value>
    query = '\n query FetchCommit($org: String!, $repo: String!, $commit: String!, $bundleFilters: BundleReportFilters)... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'bundleFilters': {}, 'commit': '97e525f1b3d77a44dd4ca9a7ab67c0a34fefa77d', 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_sqlite_file_deleted

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_sqlite_file_deleted>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779316085584'>

    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_sqlite_file_deleted(self, get_storage_service):
    os.system("rm -rf /tmp/bundle_analysis_*")
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    base_commit_report = CommitReportFactory(
    commit=self.parent_commit,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )
    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = (
    query_commit
    % """
    bundleAnalysisCompareWithParent {
    __typename
    ... on BundleAnalysisComparison {
    bundleData {
    size {
    uncompress
    }
    }
    }
    }
    """
    )

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    > self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:1046:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_sqlite_file_deleted>
    query = '\nquery FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $org) {\n reposito... }\n }\n }\n \n }\n }\n }\n }\n}\n'
    provider = 'gh', owner = None
    variables = {'commit': '919cbd378b2ded68c64624fc18978db84a9532c1', 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_bundle_analysis_sqlite_file_not_deleted

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_sqlite_file_not_deleted>
    get_storage_service = <MagicMock name='get_appropriate_storage_service' id='139779648851744'>
    os_unlink_mock = <MagicMock name='unlink' id='139779317515616'>

    @patch("graphql_api.views.os.unlink")
    @patch("graphql_api.dataloader.bundle_analysis.get_appropriate_storage_service")
    def test_bundle_analysis_sqlite_file_not_deleted(
    self, get_storage_service, os_unlink_mock
    ):
    os.system("rm -rf /tmp/bundle_analysis_*")
    os_unlink_mock.side_effect = Exception("something went wrong")
    storage = MemoryStorageService({})
    get_storage_service.return_value = storage

    base_commit_report = CommitReportFactory(
    commit=self.parent_commit,
    report_type=CommitReport.ReportType.BUNDLE_ANALYSIS,
    )
    head_commit_report = CommitReportFactory(
    commit=self.commit, report_type=CommitReport.ReportType.BUNDLE_ANALYSIS
    )

    with open("..../tests/samples/base_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=base_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    with open("..../tests/samples/head_bundle_report.sqlite", "rb") as f:
    storage_path = StoragePaths.bundle_report.path(
    repo_key=ArchiveService.get_archive_hash(self.repo),
    report_key=head_commit_report.external_id,
    )
    storage.write_file(get_bucket_name(), storage_path, f)

    query = (
    query_commit
    % """
    bundleAnalysisCompareWithParent {
    __typename
    ... on BundleAnalysisComparison {
    bundleData {
    size {
    uncompress
    }
    }
    }
    }
    """
    )

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    > self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:1105:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_bundle_analysis_sqlite_file_not_deleted>
    query = '\nquery FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $org) {\n reposito... }\n }\n }\n \n }\n }\n }\n }\n}\n'
    provider = 'gh', owner = None
    variables = {'commit': '6ff3540555c66bb0c445d782b26a6d2fa67483a2', 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_fetch_commit_compare_no_parent

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_fetch_commit_compare_no_parent>

    def test_fetch_commit_compare_no_parent(self):
    self.commit.parent_commit_id = None
    self.commit.save()

    query = (
    query_commit
    % """
    compareWithParent { __typename ... on Comparison { state } }
    bundleAnalysisCompareWithParent { __typename ... on BundleAnalysisComparison { bundleData { size { uncompress } } } }
    """
    )
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:722:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_fetch_commit_compare_no_parent>
    query = '\nquery FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $org) {\n reposito...arison { bundleData { size { uncompress } } } }\n \n }\n }\n }\n }\n}\n'
    provider = 'gh', owner = None
    variables = {'commit': '9191cd4407832e9fa79b42d0550cbf0c35fc8445', 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_fetch_commit_coverage

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_fetch_commit_coverage>

    def test_fetch_commit_coverage(self):
    ReportLevelTotalsFactory(report=self.report, coverage=12)
    query = query_commit % "totals { coverage } "
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    }
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:223:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_fetch_commit_coverage>
    query = '\nquery FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $org) {\n reposito...mmit(id: $commit) {\n totals { coverage } \n }\n }\n }\n }\n}\n'
    provider = 'gh', owner = None
    variables = {'commit': '6ee580e6278f9badbac42175a51daacf398920df', 'org': 'codecov', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_fetch_commit_coverage_file_call_the_command

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_fetch_commit_coverage_file_call_the_command>
    report_mock = <MagicMock name='build_report_from_commit' id='139779660078672'>
    content_mock = <MagicMock name='get_file_content' id='139780050488640'>
    critical_files = <PropertyMock name='critical_files' id='139779659794816'>

    @patch(
    "services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
    )
    @patch("core.commands.commit.commit.CommitCommands.get_file_content")
    @patch("shared.reports.api_report_service.build_report_from_commit")
    def test_fetch_commit_coverage_file_call_the_command(
    self, report_mock, content_mock, critical_files
    ):
    query = (
    query_commit
    % 'coverageFile(path: "path") { hashedPath, content, isCriticalFile, coverage { line,coverage }, totals {coverage} }'
    )
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "path": "path",
    }
    fake_coverage = {
    "content": "file content",
    "coverage": [
    {"line": 0, "coverage": "P"},
    {"line": 1, "coverage": "H"},
    {"line": 2, "coverage": "M"},
    ],
    "totals": {"coverage": 83.0},
    }
    content_mock.return_value = "file content"
    critical_files.return_value = [CriticalFile("path")]

    report_mock.return_value = MockReport()
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:557:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_fetch_commit_coverage_file_call_the_command>
    query = '\nquery FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $org) {\n reposito...CriticalFile, coverage { line,coverage }, totals {coverage} }\n }\n }\n }\n }\n}\n'
    provider = 'gh', owner = None
    variables = {'commit': 'cce3a40dbe01479b527b455ba1a579afe70e6605', 'org': 'codecov', 'path': 'path', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_fetch_commit_coverage_file_with_components

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_fetch_commit_coverage_file_with_components>
    report_mock = <MagicMock name='build_report_from_commit' id='139779650131232'>
    commit_components_mock = <MagicMock name='commit_components' id='139779649943648'>
    filtered_mock = <MagicMock name='component_filtered_report' id='139779780371248'>

    @patch("services.components.component_filtered_report")
    @patch("services.components.commit_components")
    @patch("shared.reports.api_report_service.build_report_from_commit")
    def test_fetch_commit_coverage_file_with_components(
    self, report_mock, commit_components_mock, filtered_mock
    ):
    components = ["Global"]

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "path": "path",
    "components": components,
    }

    report_mock.return_value = MockReport()
    commit_components_mock.return_value = [
    Component.from_dict(
    {
    "component_id": "c1",
    "name": "ComponentOne",
    "paths": ["fileA.py"],
    }
    ),
    Component.from_dict(
    {
    "component_id": "c2",
    "name": "ComponentTwo",
    "paths": ["fileB.py"],
    }
    ),
    Component.from_dict(
    {
    "component_id": "global",
    "name": "Global",
    "paths": ["**/*.py"],
    }
    ),
    ]
    filtered_mock.return_value = MockReport()

    query_files = """
    query FetchCommit($org: String!, $repo: String!, $commit: String!, $components: [String!]!) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $commit) {
    coverageFile(path: "path", components: $components) {
    hashedPath, content, isCriticalFile, coverage { line,coverage }, totals {coverage}
    }
    }
    }
    }
    }
    }
    """

    > data = self.gql_request(query_files, variables=variables)

    graphql_api/tests/test_commit_legacy.py:623:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_fetch_commit_coverage_file_with_components>
    query = '\n query FetchCommit($org: String!, $repo: String!, $commit: String!, $components: [String!]!) {\n ... }\n }\n }\n }\n }\n }\n '
    provider = 'gh', owner = None
    variables = {'commit': 'ea2ad1d8b54b762a211f35d452c6aab62ce7e0a1', 'components': ['Global'], 'org': 'codecov', 'path': 'path', ...}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_fetch_commit_with_no_coverage_data

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_fetch_commit_with_no_coverage_data>
    report_mock = <MagicMock name='build_report_from_commit' id='139779649067184'>
    content_mock = <MagicMock name='get_file_content' id='139780057980832'>
    critical_files = <PropertyMock name='critical_files' id='139780129133184'>

    @patch(
    "services.profiling.ProfilingSummary.critical_files", new_callable=PropertyMock
    )
    @patch("core.commands.commit.commit.CommitCommands.get_file_content")
    @patch("shared.reports.api_report_service.build_report_from_commit")
    def test_fetch_commit_with_no_coverage_data(
    self, report_mock, content_mock, critical_files
    ):
    query = (
    query_commit
    % 'coverageFile(path: "path") { content, isCriticalFile, coverage { line,coverage }, totals {coverage} }'
    )
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "path": "path",
    }
    fake_coverage = {"content": "file content", "coverage": [], "totals": None}
    content_mock.return_value = "file content"
    critical_files.return_value = []

    report_mock.return_value = EmptyReport()
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:668:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_fetch_commit_with_no_coverage_data>
    query = '\nquery FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $org) {\n reposito...CriticalFile, coverage { line,coverage }, totals {coverage} }\n }\n }\n }\n }\n}\n'
    provider = 'gh', owner = None
    variables = {'commit': '774c118a935fd24ada5e5c0887603266a59ee35f', 'org': 'codecov', 'path': 'path', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_commit_legacy.TestCommit
    Test name: test_flag_names

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_flag_names>
    report_mock = <MagicMock name='build_report_from_commit' id='139780051633504'>

    @patch("shared.reports.api_report_service.build_report_from_commit")
    def test_flag_names(self, report_mock):
    query = query_commit % "flagNames"
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "commit": self.commit.commitid,
    "path": "path",
    }
    report_mock.return_value = MockReport()
    > data = self.gql_request(query, variables=variables)

    graphql_api/tests/test_commit_legacy.py:685:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_commit_legacy.TestCommit testMethod=test_flag_names>
    query = '\nquery FetchCommit($org: String!, $repo: String!, $commit: String!) {\n owner(username: $org) {\n reposito... commit(id: $commit) {\n flagNames\n }\n }\n }\n }\n}\n'
    provider = 'gh', owner = None
    variables = {'commit': 'd368b6bc6a81216a84d5972db5ccc5a9889d7b9c', 'org': 'codecov', 'path': 'path', 'repo': 'gazebo'}
    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
  • Class name: graphql_api.tests.test_components_legacy.TestCommitComponents
    Test name: test_components

    self = <graphql_api.tests.test_components_legacy.TestCommitComponents testMethod=test_components>
    commit_components_mock = <MagicMock name='commit_components' id='139779318005296'>
    full_report_mock = <PropertyMock name='full_report' id='139779315820560'>

    @patch("core.models.Commit.full_report", new_callable=PropertyMock)
    @patch("services.components.commit_components")
    def test_components(self, commit_components_mock, full_report_mock):
    commit_components_mock.return_value = [
    Component.from_dict(
    {
    "component_id": "python",
    "paths": [".*/*.py"],
    }
    ),
    Component.from_dict(
    {
    "component_id": "golang",
    "paths": [".*/*.go"],
    }
    ),
    ]

    full_report_mock.return_value = sample_report()

    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "sha": self.commit.commitid,
    }
    > data = self.gql_request(
    query_commit_components,
    variables=variables,
    owner=OwnerFactory(),
    )

    graphql_api/tests/test_components_legacy.py:122:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_components_legacy.TestCommitComponents testMethod=test_components>
    query = '\n query CommitComponents(\n $org: String!\n $repo: String!\n $sha: String!\n ) {\n ... }\n }\n }\n }\n }\n }\n }\n'
    provider = 'gh', owner = <Owner: Owner<github/isaac29>>
    variables = {'org': 'uvaldez', 'repo': 'red', 'sha': 'a081c97f4ea9050a5cfa5343546a98bf6db512f9'}
    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
  • Class name: graphql_api.tests.test_components_legacy.TestCommitComponents
    Test name: test_components_filtering

    self = <graphql_api.tests.test_components_legacy.TestCommitComponents testMethod=test_components_filtering>
    commit_components_mock = <MagicMock name='commit_components' id='139779317998048'>
    full_report_mock = <PropertyMock name='full_report' id='139779317715680'>

    @patch("core.models.Commit.full_report", new_callable=PropertyMock)
    @patch("services.components.commit_components")
    def test_components_filtering(self, commit_components_mock, full_report_mock):
    commit_components_mock.return_value = [
    Component.from_dict(
    {
    "component_id": "python1.1",
    "name": "Python",
    "paths": [".*/*.py"],
    }
    ),
    Component.from_dict(
    {
    "component_id": "golang1.2",
    "name": "Golang",
    "paths": [".*/*.go"],
    }
    ),
    ]

    full_report_mock.return_value = sample_report()

    query_commit_components = """
    query CommitComponents(
    $org: String!
    $repo: String!
    $sha: String!
    $filter: ComponentsFilters
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $sha) {
    components (filters: $filter) {
    id
    name
    }
    }
    }
    }
    }
    }
    """

    # Find one item
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "sha": self.commit.commitid,
    "filter": {"components": ["Python"]},
    }
    > data = self.gql_request(
    query_commit_components, variables=variables, owner=OwnerFactory()
    )

    graphql_api/tests/test_components_legacy.py:207:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_components_legacy.TestCommitComponents testMethod=test_components_filtering>
    query = '\n query CommitComponents(\n $org: String!\n $repo: String!\n ... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = <Owner: Owner<github/parkeramy>>
    variables = {'filter': {'components': ['Python']}, 'org': 'david48', 'repo': 'ball', 'sha': '293c5dbdcf19a20f421cc3ffeb73ede70e86153e'}
    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
  • Class name: graphql_api.tests.test_components_legacy.TestCommitComponents
    Test name: test_components_filtering_case_insensitive

    self = <graphql_api.tests.test_components_legacy.TestCommitComponents testMethod=test_components_filtering_case_insensitive>
    commit_components_mock = <MagicMock name='commit_components' id='139779316323904'>
    full_report_mock = <PropertyMock name='full_report' id='139779317721728'>

    @patch("core.models.Commit.full_report", new_callable=PropertyMock)
    @patch("services.components.commit_components")
    def test_components_filtering_case_insensitive(
    self, commit_components_mock, full_report_mock
    ):
    commit_components_mock.return_value = [
    Component.from_dict(
    {
    "component_id": "cpython",
    "name": "PyThOn",
    "paths": [".*/*.py"],
    }
    ),
    ]

    full_report_mock.return_value = sample_report()

    query_commit_components = """
    query CommitComponents(
    $org: String!
    $repo: String!
    $sha: String!
    $filter: ComponentsFilters
    ) {
    owner(username: $org) {
    repository(name: $repo) {
    ... on Repository {
    commit(id: $sha) {
    components (filters: $filter) {
    id
    name
    }
    }
    }
    }
    }
    }
    """
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "sha": self.commit.commitid,
    "filter": {"components": ["pYtHoN"]},
    }
    > data = self.gql_request(
    query_commit_components, variables=variables, owner=OwnerFactory()
    )

    graphql_api/tests/test_components_legacy.py:331:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_components_legacy.TestCommitComponents testMethod=test_components_filtering_case_insensitive>
    query = '\n query CommitComponents(\n $org: String!\n $repo: String!\n ... }\n }\n }\n }\n }\n '
    provider = 'gh', owner = <Owner: Owner<github/brian88>>
    variables = {'filter': {'components': ['pYtHoN']}, 'org': 'hbarker', 'repo': 'challenge', 'sha': '05de12edf08ea84a3f640a330304eff7c585e1c8'}
    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
  • Class name: graphql_api.tests.test_components_legacy.TestCommitComponents
    Test name: test_no_components

    self = <graphql_api.tests.test_components_legacy.TestCommitComponents testMethod=test_no_components>

    def test_no_components(self):
    variables = {
    "org": self.org.username,
    "repo": self.repo.name,
    "sha": self.commit.commitid,
    }
    > data = self.gql_request(
    query_commit_components, variables=variables, owner=OwnerFactory()
    )

    graphql_api/tests/test_components_legacy.py:84:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <graphql_api.tests.test_components_legacy.TestCommitComponents testMethod=test_no_components>
    query = '\n query CommitComponents(\n $org: String!\n $repo: String!\n $sha: String!\n ) {\n ... }\n }\n }\n }\n }\n }\n }\n'
    provider = 'gh', owner = <Owner: Owner<github/jessica32>>
    variables = {'org': 'mramirez', 'repo': 'government', 'sha': 'b8082b27133e1e80ee65d27063353b65354bd29d'}
    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

@calvin-codecov calvin-codecov force-pushed the cy/cleanup_commit_graphql branch 2 times, most recently from 79aa973 to a878c07 Compare October 18, 2024 16:58
Copy link
Contributor

@suejung-sentry suejung-sentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there are some conflicts with main & some tests failing.
How did the test sweep against gazebo main go? If you have some screenshots on those we can add it to this PR for posterity.

Otherwise the changes make sense to me!

@calvin-codecov calvin-codecov force-pushed the cy/cleanup_commit_graphql branch from a878c07 to 3af970a Compare October 21, 2024 17:53
@calvin-codecov calvin-codecov force-pushed the cy/cleanup_commit_graphql branch from acf46a2 to 5ac92d0 Compare October 21, 2024 20:31
@calvin-codecov calvin-codecov force-pushed the cy/cleanup_commit_graphql branch from 5ac92d0 to 19dc91b Compare October 21, 2024 20:34
@calvin-codecov calvin-codecov added this pull request to the merge queue Oct 21, 2024
Merged via the queue into main with commit f8ac094 Oct 21, 2024
18 of 19 checks passed
@calvin-codecov calvin-codecov deleted the cy/cleanup_commit_graphql branch October 21, 2024 21:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[3.3] Clean Up Old API Implementation

3 participants