Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove UploadLevelTotalsFactory #787

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Remove UploadLevelTotalsFactory #787

wants to merge 1 commit into from

Conversation

Swatinem
Copy link
Contributor

@Swatinem Swatinem commented Sep 2, 2024

This seems to be unused, and should be removed.

This seems to be unused, and should be removed.
@Swatinem Swatinem self-assigned this Sep 2, 2024
@codecov-staging
Copy link

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
2270 2 2268 6
View the top 2 failed tests by shortest run time
services.tests.test_report.ReportServiceTest test_build_report_from_commit_null_session_totals
Stack Traces | 0.023s run time
self = <services.tests.test_report.ReportServiceTest testMethod=test_build_report_from_commit_null_session_totals>
read_chunks_mock = <MagicMock name='read_chunks' id='140598046988224'>

    @patch("services.archive.ArchiveService.read_chunks")
    def test_build_report_from_commit_null_session_totals(self, read_chunks_mock):
        f = open(current_file.parent / "samples" / "chunks.txt", "r")
        read_chunks_mock.return_value = f.read()
        commit = CommitWithReportFactory.create(message="aaaaa", commitid="abf6d4d")
        upload = commit.reports.first().sessions.first()
>       upload.uploadleveltotals.delete()

services/tests/test_report.py:179: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <django.db.models.fields.related_descriptors.ReverseOneToOneDescriptor object at 0x7fdfa33ec860>
instance = <ReportSession: ReportSession object (51)>
cls = <class 'shared.django_apps.reports.models.ReportSession'>

    def __get__(self, instance, cls=None):
        """
        Get the related instance through the reverse relation.
    
        With the example above, when getting ``place.restaurant``:
    
        - ``self`` is the descriptor managing the ``restaurant`` attribute
        - ``instance`` is the ``place`` instance
        - ``cls`` is the ``Place`` class (unused)
    
        Keep in mind that ``Restaurant`` holds the foreign key to ``Place``.
        """
        if instance is None:
            return self
    
        # The related instance is loaded from the database and then cached
        # by the field on the model instance state. It can also be pre-cached
        # by the forward accessor (ForwardManyToOneDescriptor).
        try:
            rel_obj = self.related.get_cached_value(instance)
        except KeyError:
            related_pk = instance.pk
            if related_pk is None:
                rel_obj = None
            else:
                filter_args = self.related.field.get_forward_related_filter(instance)
                try:
                    rel_obj = self.get_queryset(instance=instance).get(**filter_args)
                except self.related.related_model.DoesNotExist:
                    rel_obj = None
                else:
                    # Set the forward accessor cache on the related object to
                    # the current instance to avoid an extra SQL query if it's
                    # accessed later on.
                    self.related.field.set_cached_value(rel_obj, instance)
            self.related.set_cached_value(instance, rel_obj)
    
        if rel_obj is None:
>           raise self.RelatedObjectDoesNotExist(
                "%s has no %s."
                % (instance.__class__.__name__, self.related.get_accessor_name())
            )
E           shared.django_apps.reports.models.ReportSession.uploadleveltotals.RelatedObjectDoesNotExist: ReportSession has no uploadleveltotals.

.../local/lib/python3.12.../models/fields/related_descriptors.py:492: RelatedObjectDoesNotExist
api.public.v2.tests.test_api_commit_viewset.RepoCommitUploadsTestCase test_commit_uploads_authenticated
Stack Traces | 0.086s run time
self = <test_api_commit_viewset.RepoCommitUploadsTestCase testMethod=test_commit_uploads_authenticated>
build_report_from_commit = <MagicMock name='build_report_from_commit' id='140598395241200'>
get_repo_permissions = <MagicMock name='get_repo_permissions' id='140598396329600'>

    @patch("services.report.build_report_from_commit")
    def test_commit_uploads_authenticated(
        self, build_report_from_commit, get_repo_permissions
    ):
        build_report_from_commit.return_value = MockReport()
        get_repo_permissions.return_value = (True, True)
        commit = CommitWithReportFactory(author=self.org, repository=self.repo)
    
        response = self.client.get(
            reverse(
                "api-v2-commits-uploads",
                kwargs={
                    "service": self.org.service,
                    "owner_username": self.org.username,
                    "repo_name": self.repo.name,
                    "commitid": commit.commitid,
                },
            )
        )
        data = response.json()
    
        expected_storage_path = ".../4434BC2A2EC4FCA57F77B473D83F928C/abf6d4df662c47e32460020ab14abf9303581429/9ccc55a1-8b41-4bb1-a946-ee7a33a7fb56.txt"
    
        assert response.status_code == 200
        assert len(data["results"]) == 2
        assert data["results"][0]["storage_path"] == expected_storage_path
        assert data["results"][1]["storage_path"] == expected_storage_path
>       assert data["results"][0]["totals"] == {
            "files": 3,
            "lines": 20,
            "hits": 17,
            "misses": 3,
            "partials": 0,
            "coverage": 85.0,
            "branches": 0,
            "methods": 0,
        }
E       AssertionError: assert None == {'branches': 0, 'coverage': 85.0, 'files': 3, 'hits': 17, ...}

.../v2/tests/test_api_commit_viewset.py:440: AssertionError

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

Copy link

codecov bot commented Sep 2, 2024

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
2270 2 2268 6
View the top 2 failed tests by shortest run time
services.tests.test_report.ReportServiceTest test_build_report_from_commit_null_session_totals
Stack Traces | 0.023s run time
self = <services.tests.test_report.ReportServiceTest testMethod=test_build_report_from_commit_null_session_totals>
read_chunks_mock = <MagicMock name='read_chunks' id='140598046988224'>

    @patch("services.archive.ArchiveService.read_chunks")
    def test_build_report_from_commit_null_session_totals(self, read_chunks_mock):
        f = open(current_file.parent / "samples" / "chunks.txt", "r")
        read_chunks_mock.return_value = f.read()
        commit = CommitWithReportFactory.create(message="aaaaa", commitid="abf6d4d")
        upload = commit.reports.first().sessions.first()
>       upload.uploadleveltotals.delete()

services/tests/test_report.py:179: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <django.db.models.fields.related_descriptors.ReverseOneToOneDescriptor object at 0x7fdfa33ec860>
instance = <ReportSession: ReportSession object (51)>
cls = <class 'shared.django_apps.reports.models.ReportSession'>

    def __get__(self, instance, cls=None):
        """
        Get the related instance through the reverse relation.
    
        With the example above, when getting ``place.restaurant``:
    
        - ``self`` is the descriptor managing the ``restaurant`` attribute
        - ``instance`` is the ``place`` instance
        - ``cls`` is the ``Place`` class (unused)
    
        Keep in mind that ``Restaurant`` holds the foreign key to ``Place``.
        """
        if instance is None:
            return self
    
        # The related instance is loaded from the database and then cached
        # by the field on the model instance state. It can also be pre-cached
        # by the forward accessor (ForwardManyToOneDescriptor).
        try:
            rel_obj = self.related.get_cached_value(instance)
        except KeyError:
            related_pk = instance.pk
            if related_pk is None:
                rel_obj = None
            else:
                filter_args = self.related.field.get_forward_related_filter(instance)
                try:
                    rel_obj = self.get_queryset(instance=instance).get(**filter_args)
                except self.related.related_model.DoesNotExist:
                    rel_obj = None
                else:
                    # Set the forward accessor cache on the related object to
                    # the current instance to avoid an extra SQL query if it's
                    # accessed later on.
                    self.related.field.set_cached_value(rel_obj, instance)
            self.related.set_cached_value(instance, rel_obj)
    
        if rel_obj is None:
>           raise self.RelatedObjectDoesNotExist(
                "%s has no %s."
                % (instance.__class__.__name__, self.related.get_accessor_name())
            )
E           shared.django_apps.reports.models.ReportSession.uploadleveltotals.RelatedObjectDoesNotExist: ReportSession has no uploadleveltotals.

.../local/lib/python3.12.../models/fields/related_descriptors.py:492: RelatedObjectDoesNotExist
api.public.v2.tests.test_api_commit_viewset.RepoCommitUploadsTestCase test_commit_uploads_authenticated
Stack Traces | 0.086s run time
self = <test_api_commit_viewset.RepoCommitUploadsTestCase testMethod=test_commit_uploads_authenticated>
build_report_from_commit = <MagicMock name='build_report_from_commit' id='140598395241200'>
get_repo_permissions = <MagicMock name='get_repo_permissions' id='140598396329600'>

    @patch("services.report.build_report_from_commit")
    def test_commit_uploads_authenticated(
        self, build_report_from_commit, get_repo_permissions
    ):
        build_report_from_commit.return_value = MockReport()
        get_repo_permissions.return_value = (True, True)
        commit = CommitWithReportFactory(author=self.org, repository=self.repo)
    
        response = self.client.get(
            reverse(
                "api-v2-commits-uploads",
                kwargs={
                    "service": self.org.service,
                    "owner_username": self.org.username,
                    "repo_name": self.repo.name,
                    "commitid": commit.commitid,
                },
            )
        )
        data = response.json()
    
        expected_storage_path = ".../4434BC2A2EC4FCA57F77B473D83F928C/abf6d4df662c47e32460020ab14abf9303581429/9ccc55a1-8b41-4bb1-a946-ee7a33a7fb56.txt"
    
        assert response.status_code == 200
        assert len(data["results"]) == 2
        assert data["results"][0]["storage_path"] == expected_storage_path
        assert data["results"][1]["storage_path"] == expected_storage_path
>       assert data["results"][0]["totals"] == {
            "files": 3,
            "lines": 20,
            "hits": 17,
            "misses": 3,
            "partials": 0,
            "coverage": 85.0,
            "branches": 0,
            "methods": 0,
        }
E       AssertionError: assert None == {'branches': 0, 'coverage': 85.0, 'files': 3, 'hits': 17, ...}

.../v2/tests/test_api_commit_viewset.py:440: AssertionError

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

@codecov-qa
Copy link

codecov-qa bot commented Sep 2, 2024

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
2270 2 2268 6
View the top 2 failed tests by shortest run time
services.tests.test_report.ReportServiceTest test_build_report_from_commit_null_session_totals
Stack Traces | 0.023s run time
self = <services.tests.test_report.ReportServiceTest testMethod=test_build_report_from_commit_null_session_totals>
read_chunks_mock = <MagicMock name='read_chunks' id='140598046988224'>

    @patch("services.archive.ArchiveService.read_chunks")
    def test_build_report_from_commit_null_session_totals(self, read_chunks_mock):
        f = open(current_file.parent / "samples" / "chunks.txt", "r")
        read_chunks_mock.return_value = f.read()
        commit = CommitWithReportFactory.create(message="aaaaa", commitid="abf6d4d")
        upload = commit.reports.first().sessions.first()
>       upload.uploadleveltotals.delete()

services/tests/test_report.py:179: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <django.db.models.fields.related_descriptors.ReverseOneToOneDescriptor object at 0x7fdfa33ec860>
instance = <ReportSession: ReportSession object (51)>
cls = <class 'shared.django_apps.reports.models.ReportSession'>

    def __get__(self, instance, cls=None):
        """
        Get the related instance through the reverse relation.
    
        With the example above, when getting ``place.restaurant``:
    
        - ``self`` is the descriptor managing the ``restaurant`` attribute
        - ``instance`` is the ``place`` instance
        - ``cls`` is the ``Place`` class (unused)
    
        Keep in mind that ``Restaurant`` holds the foreign key to ``Place``.
        """
        if instance is None:
            return self
    
        # The related instance is loaded from the database and then cached
        # by the field on the model instance state. It can also be pre-cached
        # by the forward accessor (ForwardManyToOneDescriptor).
        try:
            rel_obj = self.related.get_cached_value(instance)
        except KeyError:
            related_pk = instance.pk
            if related_pk is None:
                rel_obj = None
            else:
                filter_args = self.related.field.get_forward_related_filter(instance)
                try:
                    rel_obj = self.get_queryset(instance=instance).get(**filter_args)
                except self.related.related_model.DoesNotExist:
                    rel_obj = None
                else:
                    # Set the forward accessor cache on the related object to
                    # the current instance to avoid an extra SQL query if it's
                    # accessed later on.
                    self.related.field.set_cached_value(rel_obj, instance)
            self.related.set_cached_value(instance, rel_obj)
    
        if rel_obj is None:
>           raise self.RelatedObjectDoesNotExist(
                "%s has no %s."
                % (instance.__class__.__name__, self.related.get_accessor_name())
            )
E           shared.django_apps.reports.models.ReportSession.uploadleveltotals.RelatedObjectDoesNotExist: ReportSession has no uploadleveltotals.

.../local/lib/python3.12.../models/fields/related_descriptors.py:492: RelatedObjectDoesNotExist
api.public.v2.tests.test_api_commit_viewset.RepoCommitUploadsTestCase test_commit_uploads_authenticated
Stack Traces | 0.086s run time
self = <test_api_commit_viewset.RepoCommitUploadsTestCase testMethod=test_commit_uploads_authenticated>
build_report_from_commit = <MagicMock name='build_report_from_commit' id='140598395241200'>
get_repo_permissions = <MagicMock name='get_repo_permissions' id='140598396329600'>

    @patch("services.report.build_report_from_commit")
    def test_commit_uploads_authenticated(
        self, build_report_from_commit, get_repo_permissions
    ):
        build_report_from_commit.return_value = MockReport()
        get_repo_permissions.return_value = (True, True)
        commit = CommitWithReportFactory(author=self.org, repository=self.repo)
    
        response = self.client.get(
            reverse(
                "api-v2-commits-uploads",
                kwargs={
                    "service": self.org.service,
                    "owner_username": self.org.username,
                    "repo_name": self.repo.name,
                    "commitid": commit.commitid,
                },
            )
        )
        data = response.json()
    
        expected_storage_path = ".../4434BC2A2EC4FCA57F77B473D83F928C/abf6d4df662c47e32460020ab14abf9303581429/9ccc55a1-8b41-4bb1-a946-ee7a33a7fb56.txt"
    
        assert response.status_code == 200
        assert len(data["results"]) == 2
        assert data["results"][0]["storage_path"] == expected_storage_path
        assert data["results"][1]["storage_path"] == expected_storage_path
>       assert data["results"][0]["totals"] == {
            "files": 3,
            "lines": 20,
            "hits": 17,
            "misses": 3,
            "partials": 0,
            "coverage": 85.0,
            "branches": 0,
            "methods": 0,
        }
E       AssertionError: assert None == {'branches': 0, 'coverage': 85.0, 'files': 3, 'hits': 17, ...}

.../v2/tests/test_api_commit_viewset.py:440: AssertionError

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

Copy link

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

❌ Failed Test Results:

Completed 2276 tests with 2 failed, 2268 passed and 6 skipped.

View the full list of failed tests

pytest

  • Class name: api.public.v2.tests.test_api_commit_viewset.RepoCommitUploadsTestCase
    Test name: test_commit_uploads_authenticated

    self = <test_api_commit_viewset.RepoCommitUploadsTestCase testMethod=test_commit_uploads_authenticated>
    build_report_from_commit = <MagicMock name='build_report_from_commit' id='140598395241200'>
    get_repo_permissions = <MagicMock name='get_repo_permissions' id='140598396329600'>

    @patch("services.report.build_report_from_commit")
    def test_commit_uploads_authenticated(
    self, build_report_from_commit, get_repo_permissions
    ):
    build_report_from_commit.return_value = MockReport()
    get_repo_permissions.return_value = (True, True)
    commit = CommitWithReportFactory(author=self.org, repository=self.repo)

    response = self.client.get(
    reverse(
    "api-v2-commits-uploads",
    kwargs={
    "service": self.org.service,
    "owner_username": self.org.username,
    "repo_name": self.repo.name,
    "commitid": commit.commitid,
    },
    )
    )
    data = response.json()

    expected_storage_path = ".../4434BC2A2EC4FCA57F77B473D83F928C/abf6d4df662c47e32460020ab14abf9303581429/9ccc55a1-8b41-4bb1-a946-ee7a33a7fb56.txt"

    assert response.status_code == 200
    assert len(data["results"]) == 2
    assert data["results"][0]["storage_path"] == expected_storage_path
    assert data["results"][1]["storage_path"] == expected_storage_path
    > assert data["results"][0]["totals"] == {
    "files": 3,
    "lines": 20,
    "hits": 17,
    "misses": 3,
    "partials": 0,
    "coverage": 85.0,
    "branches": 0,
    "methods": 0,
    }
    E AssertionError: assert None == {'branches': 0, 'coverage': 85.0, 'files': 3, 'hits': 17, ...}

    .../v2/tests/test_api_commit_viewset.py:440: AssertionError
  • Class name: services.tests.test_report.ReportServiceTest
    Test name: test_build_report_from_commit_null_session_totals

    self = <services.tests.test_report.ReportServiceTest testMethod=test_build_report_from_commit_null_session_totals>
    read_chunks_mock = <MagicMock name='read_chunks' id='140598046988224'>

    @patch("services.archive.ArchiveService.read_chunks")
    def test_build_report_from_commit_null_session_totals(self, read_chunks_mock):
    f = open(current_file.parent / "samples" / "chunks.txt", "r")
    read_chunks_mock.return_value = f.read()
    commit = CommitWithReportFactory.create(message="aaaaa", commitid="abf6d4d")
    upload = commit.reports.first().sessions.first()
    > upload.uploadleveltotals.delete()

    services/tests/test_report.py:179:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <django.db.models.fields.related_descriptors.ReverseOneToOneDescriptor object at 0x7fdfa33ec860>
    instance = <ReportSession: ReportSession object (51)>
    cls = <class 'shared.django_apps.reports.models.ReportSession'>

    def __get__(self, instance, cls=None):
    """
    Get the related instance through the reverse relation.

    With the example above, when getting ``place.restaurant``:

    - ``self`` is the descriptor managing the ``restaurant`` attribute
    - ``instance`` is the ``place`` instance
    - ``cls`` is the ``Place`` class (unused)

    Keep in mind that ``Restaurant`` holds the foreign key to ``Place``.
    """
    if instance is None:
    return self

    # The related instance is loaded from the database and then cached
    # by the field on the model instance state. It can also be pre-cached
    # by the forward accessor (ForwardManyToOneDescriptor).
    try:
    rel_obj = self.related.get_cached_value(instance)
    except KeyError:
    related_pk = instance.pk
    if related_pk is None:
    rel_obj = None
    else:
    filter_args = self.related.field.get_forward_related_filter(instance)
    try:
    rel_obj = self.get_queryset(instance=instance).get(**filter_args)
    except self.related.related_model.DoesNotExist:
    rel_obj = None
    else:
    # Set the forward accessor cache on the related object to
    # the current instance to avoid an extra SQL query if it's
    # accessed later on.
    self.related.field.set_cached_value(rel_obj, instance)
    self.related.set_cached_value(instance, rel_obj)

    if rel_obj is None:
    > raise self.RelatedObjectDoesNotExist(
    "%s has no %s."
    % (instance.__class__.__name__, self.related.get_accessor_name())
    )
    E shared.django_apps.reports.models.ReportSession.uploadleveltotals.RelatedObjectDoesNotExist: ReportSession has no uploadleveltotals.

    .../local/lib/python3.12.../models/fields/related_descriptors.py:492: RelatedObjectDoesNotExist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant