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

Use `shared` report_service and test factories

Open Swatinem opened this issue 1 year ago • 7 comments

Purpose/Motivation

This switches most of the code using the report_builder service to use that same code imported from shared (except some functions specific to api).

Similarly, the core.tests.factories were also duplicated in shared, so this switches over to those factories, deleting them from api.

The primary reason here is that the shared code has been changed to remove the obsolete report_builder feature. This feature was recently removed from worker and its configuration from the k8s config. It is currently not enabled in production.

I believe this feature does not pull its weight, as querying multiple tables and fetching the files_array file from storage is most likely slower than just fetching the report_json from storage instead.

Links to relevant tickets

https://github.com/codecov/engineering-team/issues/2554

Swatinem avatar Oct 02 '24 08:10 Swatinem

Codecov Report

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

Project coverage is 96.25%. Comparing base (e14d14d) to head (f26a4e4). Report is 1 commits behind head on main.

Changes have been made to critical files, which contain lines commonly executed in production. Learn more

:white_check_mark: All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #849      +/-   ##
==========================================
- Coverage   96.26%   96.25%   -0.02%     
==========================================
  Files         823      823              
  Lines       19235    19049     -186     
==========================================
- Hits        18516    18335     -181     
+ Misses        719      714       -5     
Flag Coverage Δ
unit 92.52% <100.00%> (-0.11%) :arrow_down:
unit-latest-uploader 92.52% <100.00%> (-0.11%) :arrow_down:

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

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

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

Codecov Report

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

:white_check_mark: All tests successful. No failed tests found.

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

codecov-staging[bot] avatar Oct 02 '24 08:10 codecov-staging[bot]

:x: 3 Tests Failed:

Tests completed Failed Passed Skipped
2706 3 2703 6
View the top 3 failed tests by shortest run time
codecov_auth.commands.owner.interactors.tests.test_save_terms_agreement.UpdateSaveTermsAgreementInteractorTest test_update_user_when_agreement_is_true
Stack Traces | 0.348s run time
self = &lt;django.db.backends.utils.CursorWrapper object at 0x7f3ba094bb30&gt;
sql = 'UPDATE "users" SET "created_at" = %s, "updated_at" = %s, "email" = %s, "name" = %s, "is_staff" = %s, "is_superuser" =...erms_agreement" = %s, "terms_agreement_at" = %s, "customer_intent" = %s, "email_opt_in" = NULL WHERE "users"."id" = %s'
params = (datetime.datetime(2024, 10, 21, 8, 22, 59, 167046, tzinfo=datetime.timezone.utc), FakeDatetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), '[email protected]', 'codecov-user', False, False, ...)
ignored_wrapper_args = (False, {'connection': &lt;DatabaseWrapper vendor='postgresql' alias='default'&gt;, 'cursor': &lt;django.db.backends.utils.CursorWrapper object at 0x7f3ba094bb30&gt;})

    def _execute(self, sql, params, *ignored_wrapper_args):
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
                return self.cursor.execute(sql)
            else:
&gt;               return self.cursor.execute(sql, params)
E               psycopg2.errors.NotNullViolation: null value in column "email_opt_in" of relation "users" violates not-null constraint
E               DETAIL:  Failing row contains (3989, 6fd317f3-2d4f-4573-9b61-bf99e576f25c, 2024-10-21 08:22:59.167046+00, 2022-01-01 00:00:00+00, [email protected], codecov-user, f, f, t, 2022-01-01 00:00:00, Business, null).

.../local/lib/python3.12.../db/backends/utils.py:89: NotNullViolation

The above exception was the direct cause of the following exception:

self = &lt;codecov_auth.commands.owner.interactors.tests.test_save_terms_agreement.UpdateSaveTermsAgreementInteractorTest testMethod=test_update_user_when_agreement_is_true&gt;

    @freeze_time("2022-01-01T00:00:00")
    def test_update_user_when_agreement_is_true(self):
&gt;       self.execute(
            current_user=self.current_user,
            input={"terms_agreement": True, "customer_intent": "Business"},
        )

.../interactors/tests/test_save_terms_agreement.py:52: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12............/site-packages/asgiref/sync.py:240: in __call__
    return call_result.result()
.../local/lib/python3.12....../concurrent/futures/_base.py:449: in result
    return self.__get_result()
.../local/lib/python3.12....../concurrent/futures/_base.py:401: in __get_result
    raise self._exception
.../local/lib/python3.12............/site-packages/asgiref/sync.py:306: in main_wrap
    result = await self.awaitable(*args, **kwargs)
.../local/lib/python3.12............/site-packages/asgiref/sync.py:448: in __call__
    ret = await asyncio.wait_for(future, timeout=None)
.../local/lib/python3.12/asyncio/tasks.py:520: in wait_for
    return await fut
.../local/lib/python3.12.../site-packages/asgiref/current_thread_executor.py:22: in run
    result = self.fn(*self.args, **self.kwargs)
codecov/db/__init__.py:82: in thread_handler
    return super().thread_handler(loop, *args, **kwargs)
.../local/lib/python3.12............/site-packages/asgiref/sync.py:490: in thread_handler
    return func(*args, **kwargs)
.../owner/interactors/save_terms_agreement.py:62: in execute
    return self.update_terms_agreement(typed_input)
.../owner/interactors/save_terms_agreement.py:38: in update_terms_agreement
    self.current_user.save()
.../local/lib/python3.12.../db/models/base.py:814: in save
    self.save_base(
.../local/lib/python3.12.../db/models/base.py:877: in save_base
    updated = self._save_table(
.../local/lib/python3.12.../db/models/base.py:990: in _save_table
    updated = self._do_update(
.../local/lib/python3.12.../site-packages/django_prometheus/models.py:47: in _do_update
    return super()._do_update(*args, **kwargs)
.../local/lib/python3.12.../db/models/base.py:1054: in _do_update
    return filtered._update(values) &gt; 0
.../local/lib/python3.12.../db/models/query.py:1231: in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
.../local/lib/python3.12.../models/sql/compiler.py:1984: in execute_sql
    cursor = super().execute_sql(result_type)
.../local/lib/python3.12.../models/sql/compiler.py:1562: in execute_sql
    cursor.execute(sql, params)
.../local/lib/python3.12.../site-packages/sentry_sdk/utils.py:1730: in runner
    return sentry_patched_function(*args, **kwargs)
.../local/lib/python3.12.../integrations/django/__init__.py:651: in execute
    result = real_execute(self, sql, params)
.../local/lib/python3.12.../db/backends/utils.py:67: in execute
    return self._execute_with_wrappers(
.../local/lib/python3.12.../db/backends/utils.py:80: in _execute_with_wrappers
    return executor(sql, params, many, context)
.../local/lib/python3.12.../db/backends/utils.py:84: in _execute
    with self.db.wrap_database_errors:
.../local/lib/python3.12.../django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;django.db.backends.utils.CursorWrapper object at 0x7f3ba094bb30&gt;
sql = 'UPDATE "users" SET "created_at" = %s, "updated_at" = %s, "email" = %s, "name" = %s, "is_staff" = %s, "is_superuser" =...erms_agreement" = %s, "terms_agreement_at" = %s, "customer_intent" = %s, "email_opt_in" = NULL WHERE "users"."id" = %s'
params = (datetime.datetime(2024, 10, 21, 8, 22, 59, 167046, tzinfo=datetime.timezone.utc), FakeDatetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), '[email protected]', 'codecov-user', False, False, ...)
ignored_wrapper_args = (False, {'connection': &lt;DatabaseWrapper vendor='postgresql' alias='default'&gt;, 'cursor': &lt;django.db.backends.utils.CursorWrapper object at 0x7f3ba094bb30&gt;})

    def _execute(self, sql, params, *ignored_wrapper_args):
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
                return self.cursor.execute(sql)
            else:
&gt;               return self.cursor.execute(sql, params)
E               django.db.utils.IntegrityError: null value in column "email_opt_in" of relation "users" violates not-null constraint
E               DETAIL:  Failing row contains (3989, 6fd317f3-2d4f-4573-9b61-bf99e576f25c, 2024-10-21 08:22:59.167046+00, 2022-01-01 00:00:00+00, [email protected], codecov-user, f, f, t, 2022-01-01 00:00:00, Business, null).

.../local/lib/python3.12.../db/backends/utils.py:89: IntegrityError
codecov_auth.commands.owner.interactors.tests.test_save_terms_agreement.UpdateSaveTermsAgreementInteractorTest test_update_owner_and_user_when_email_is_not_empty
Stack Traces | 0.35s run time
self = &lt;django.db.backends.utils.CursorWrapper object at 0x7f3ba094b710&gt;
sql = 'UPDATE "users" SET "created_at" = %s, "updated_at" = %s, "email" = %s, "name" = %s, "is_staff" = %s, "is_superuser" =...erms_agreement" = %s, "terms_agreement_at" = %s, "customer_intent" = %s, "email_opt_in" = NULL WHERE "users"."id" = %s'
params = (datetime.datetime(2024, 10, 21, 8, 22, 57, 676393, tzinfo=datetime.timezone.utc), FakeDatetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), '[email protected]', 'codecov-user', False, False, ...)
ignored_wrapper_args = (False, {'connection': &lt;DatabaseWrapper vendor='postgresql' alias='default'&gt;, 'cursor': &lt;django.db.backends.utils.CursorWrapper object at 0x7f3ba094b710&gt;})

    def _execute(self, sql, params, *ignored_wrapper_args):
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
                return self.cursor.execute(sql)
            else:
&gt;               return self.cursor.execute(sql, params)
E               psycopg2.errors.NotNullViolation: null value in column "email_opt_in" of relation "users" violates not-null constraint
E               DETAIL:  Failing row contains (3987, 02a58c23-6e39-46cc-817b-6dcb286faac3, 2024-10-21 08:22:57.676393+00, 2022-01-01 00:00:00+00, [email protected], codecov-user, f, f, t, 2022-01-01 00:00:00, Business, null).

.../local/lib/python3.12.../db/backends/utils.py:89: NotNullViolation

The above exception was the direct cause of the following exception:

self = &lt;codecov_auth.commands.owner.interactors.tests.test_save_terms_agreement.UpdateSaveTermsAgreementInteractorTest testMethod=test_update_owner_and_user_when_email_is_not_empty&gt;

    @freeze_time("2022-01-01T00:00:00")
    def test_update_owner_and_user_when_email_is_not_empty(self):
&gt;       self.execute(
            current_user=self.current_user,
            input={
                "business_email": "[email protected]",
                "terms_agreement": True,
                "customer_intent": "Business",
            },
        )

.../interactors/tests/test_save_terms_agreement.py:66: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12............/site-packages/asgiref/sync.py:240: in __call__
    return call_result.result()
.../local/lib/python3.12....../concurrent/futures/_base.py:449: in result
    return self.__get_result()
.../local/lib/python3.12....../concurrent/futures/_base.py:401: in __get_result
    raise self._exception
.../local/lib/python3.12............/site-packages/asgiref/sync.py:306: in main_wrap
    result = await self.awaitable(*args, **kwargs)
.../local/lib/python3.12............/site-packages/asgiref/sync.py:448: in __call__
    ret = await asyncio.wait_for(future, timeout=None)
.../local/lib/python3.12/asyncio/tasks.py:520: in wait_for
    return await fut
.../local/lib/python3.12.../site-packages/asgiref/current_thread_executor.py:22: in run
    result = self.fn(*self.args, **self.kwargs)
codecov/db/__init__.py:82: in thread_handler
    return super().thread_handler(loop, *args, **kwargs)
.../local/lib/python3.12............/site-packages/asgiref/sync.py:490: in thread_handler
    return func(*args, **kwargs)
.../owner/interactors/save_terms_agreement.py:62: in execute
    return self.update_terms_agreement(typed_input)
.../owner/interactors/save_terms_agreement.py:38: in update_terms_agreement
    self.current_user.save()
.../local/lib/python3.12.../db/models/base.py:814: in save
    self.save_base(
.../local/lib/python3.12.../db/models/base.py:877: in save_base
    updated = self._save_table(
.../local/lib/python3.12.../db/models/base.py:990: in _save_table
    updated = self._do_update(
.../local/lib/python3.12.../site-packages/django_prometheus/models.py:47: in _do_update
    return super()._do_update(*args, **kwargs)
.../local/lib/python3.12.../db/models/base.py:1054: in _do_update
    return filtered._update(values) &gt; 0
.../local/lib/python3.12.../db/models/query.py:1231: in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
.../local/lib/python3.12.../models/sql/compiler.py:1984: in execute_sql
    cursor = super().execute_sql(result_type)
.../local/lib/python3.12.../models/sql/compiler.py:1562: in execute_sql
    cursor.execute(sql, params)
.../local/lib/python3.12.../site-packages/sentry_sdk/utils.py:1730: in runner
    return sentry_patched_function(*args, **kwargs)
.../local/lib/python3.12.../integrations/django/__init__.py:651: in execute
    result = real_execute(self, sql, params)
.../local/lib/python3.12.../db/backends/utils.py:67: in execute
    return self._execute_with_wrappers(
.../local/lib/python3.12.../db/backends/utils.py:80: in _execute_with_wrappers
    return executor(sql, params, many, context)
.../local/lib/python3.12.../db/backends/utils.py:84: in _execute
    with self.db.wrap_database_errors:
.../local/lib/python3.12.../django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;django.db.backends.utils.CursorWrapper object at 0x7f3ba094b710&gt;
sql = 'UPDATE "users" SET "created_at" = %s, "updated_at" = %s, "email" = %s, "name" = %s, "is_staff" = %s, "is_superuser" =...erms_agreement" = %s, "terms_agreement_at" = %s, "customer_intent" = %s, "email_opt_in" = NULL WHERE "users"."id" = %s'
params = (datetime.datetime(2024, 10, 21, 8, 22, 57, 676393, tzinfo=datetime.timezone.utc), FakeDatetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), '[email protected]', 'codecov-user', False, False, ...)
ignored_wrapper_args = (False, {'connection': &lt;DatabaseWrapper vendor='postgresql' alias='default'&gt;, 'cursor': &lt;django.db.backends.utils.CursorWrapper object at 0x7f3ba094b710&gt;})

    def _execute(self, sql, params, *ignored_wrapper_args):
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
                return self.cursor.execute(sql)
            else:
&gt;               return self.cursor.execute(sql, params)
E               django.db.utils.IntegrityError: null value in column "email_opt_in" of relation "users" violates not-null constraint
E               DETAIL:  Failing row contains (3987, 02a58c23-6e39-46cc-817b-6dcb286faac3, 2024-10-21 08:22:57.676393+00, 2022-01-01 00:00:00+00, [email protected], codecov-user, f, f, t, 2022-01-01 00:00:00, Business, null).

.../local/lib/python3.12.../db/backends/utils.py:89: IntegrityError
codecov_auth.commands.owner.interactors.tests.test_save_terms_agreement.UpdateSaveTermsAgreementInteractorTest test_update_user_when_agreement_is_false
Stack Traces | 0.361s run time
self = &lt;django.db.backends.utils.CursorWrapper object at 0x7f3ba09cacc0&gt;
sql = 'UPDATE "users" SET "created_at" = %s, "updated_at" = %s, "email" = %s, "name" = %s, "is_staff" = %s, "is_superuser" =...erms_agreement" = %s, "terms_agreement_at" = %s, "customer_intent" = %s, "email_opt_in" = NULL WHERE "users"."id" = %s'
params = (datetime.datetime(2024, 10, 21, 8, 22, 58, 235199, tzinfo=datetime.timezone.utc), FakeDatetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), '[email protected]', 'codecov-user', False, False, ...)
ignored_wrapper_args = (False, {'connection': &lt;DatabaseWrapper vendor='postgresql' alias='default'&gt;, 'cursor': &lt;django.db.backends.utils.CursorWrapper object at 0x7f3ba09cacc0&gt;})

    def _execute(self, sql, params, *ignored_wrapper_args):
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
                return self.cursor.execute(sql)
            else:
&gt;               return self.cursor.execute(sql, params)
E               psycopg2.errors.NotNullViolation: null value in column "email_opt_in" of relation "users" violates not-null constraint
E               DETAIL:  Failing row contains (3988, e5a511e0-06ae-42e0-9389-ae15208fb087, 2024-10-21 08:22:58.235199+00, 2022-01-01 00:00:00+00, [email protected], codecov-user, f, f, f, 2022-01-01 00:00:00, Business, null).

.../local/lib/python3.12.../db/backends/utils.py:89: NotNullViolation

The above exception was the direct cause of the following exception:

self = &lt;codecov_auth.commands.owner.interactors.tests.test_save_terms_agreement.UpdateSaveTermsAgreementInteractorTest testMethod=test_update_user_when_agreement_is_false&gt;

    @freeze_time("2022-01-01T00:00:00")
    def test_update_user_when_agreement_is_false(self):
&gt;       self.execute(
            current_user=self.current_user,
            input={"terms_agreement": False, "customer_intent": "Business"},
        )

.../interactors/tests/test_save_terms_agreement.py:38: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.../local/lib/python3.12............/site-packages/asgiref/sync.py:240: in __call__
    return call_result.result()
.../local/lib/python3.12....../concurrent/futures/_base.py:449: in result
    return self.__get_result()
.../local/lib/python3.12....../concurrent/futures/_base.py:401: in __get_result
    raise self._exception
.../local/lib/python3.12............/site-packages/asgiref/sync.py:306: in main_wrap
    result = await self.awaitable(*args, **kwargs)
.../local/lib/python3.12............/site-packages/asgiref/sync.py:448: in __call__
    ret = await asyncio.wait_for(future, timeout=None)
.../local/lib/python3.12/asyncio/tasks.py:520: in wait_for
    return await fut
.../local/lib/python3.12.../site-packages/asgiref/current_thread_executor.py:22: in run
    result = self.fn(*self.args, **self.kwargs)
codecov/db/__init__.py:82: in thread_handler
    return super().thread_handler(loop, *args, **kwargs)
.../local/lib/python3.12............/site-packages/asgiref/sync.py:490: in thread_handler
    return func(*args, **kwargs)
.../owner/interactors/save_terms_agreement.py:62: in execute
    return self.update_terms_agreement(typed_input)
.../owner/interactors/save_terms_agreement.py:38: in update_terms_agreement
    self.current_user.save()
.../local/lib/python3.12.../db/models/base.py:814: in save
    self.save_base(
.../local/lib/python3.12.../db/models/base.py:877: in save_base
    updated = self._save_table(
.../local/lib/python3.12.../db/models/base.py:990: in _save_table
    updated = self._do_update(
.../local/lib/python3.12.../site-packages/django_prometheus/models.py:47: in _do_update
    return super()._do_update(*args, **kwargs)
.../local/lib/python3.12.../db/models/base.py:1054: in _do_update
    return filtered._update(values) &gt; 0
.../local/lib/python3.12.../db/models/query.py:1231: in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
.../local/lib/python3.12.../models/sql/compiler.py:1984: in execute_sql
    cursor = super().execute_sql(result_type)
.../local/lib/python3.12.../models/sql/compiler.py:1562: in execute_sql
    cursor.execute(sql, params)
.../local/lib/python3.12.../site-packages/sentry_sdk/utils.py:1730: in runner
    return sentry_patched_function(*args, **kwargs)
.../local/lib/python3.12.../integrations/django/__init__.py:651: in execute
    result = real_execute(self, sql, params)
.../local/lib/python3.12.../db/backends/utils.py:67: in execute
    return self._execute_with_wrappers(
.../local/lib/python3.12.../db/backends/utils.py:80: in _execute_with_wrappers
    return executor(sql, params, many, context)
.../local/lib/python3.12.../db/backends/utils.py:84: in _execute
    with self.db.wrap_database_errors:
.../local/lib/python3.12.../django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = &lt;django.db.backends.utils.CursorWrapper object at 0x7f3ba09cacc0&gt;
sql = 'UPDATE "users" SET "created_at" = %s, "updated_at" = %s, "email" = %s, "name" = %s, "is_staff" = %s, "is_superuser" =...erms_agreement" = %s, "terms_agreement_at" = %s, "customer_intent" = %s, "email_opt_in" = NULL WHERE "users"."id" = %s'
params = (datetime.datetime(2024, 10, 21, 8, 22, 58, 235199, tzinfo=datetime.timezone.utc), FakeDatetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), '[email protected]', 'codecov-user', False, False, ...)
ignored_wrapper_args = (False, {'connection': &lt;DatabaseWrapper vendor='postgresql' alias='default'&gt;, 'cursor': &lt;django.db.backends.utils.CursorWrapper object at 0x7f3ba09cacc0&gt;})

    def _execute(self, sql, params, *ignored_wrapper_args):
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
                return self.cursor.execute(sql)
            else:
&gt;               return self.cursor.execute(sql, params)
E               django.db.utils.IntegrityError: null value in column "email_opt_in" of relation "users" violates not-null constraint
E               DETAIL:  Failing row contains (3988, e5a511e0-06ae-42e0-9389-ae15208fb087, 2024-10-21 08:22:58.235199+00, 2022-01-01 00:00:00+00, [email protected], codecov-user, f, f, f, 2022-01-01 00:00:00, Business, null).

.../local/lib/python3.12.../db/backends/utils.py:89: IntegrityError

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

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

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

:x: Failed Test Results:

Completed 2712 tests with 3 failed, 2703 passed and 6 skipped.

View the full list of failed tests

pytest

  • Class name: codecov_auth.commands.owner.interactors.tests.test_save_terms_agreement.UpdateSaveTermsAgreementInteractorTest
    Test name: test_update_owner_and_user_when_email_is_not_empty

    self = <django.db.backends.utils.CursorWrapper object at 0x7f3ba094b710>
    sql = 'UPDATE "users" SET "created_at" = %s, "updated_at" = %s, "email" = %s, "name" = %s, "is_staff" = %s, "is_superuser" =...erms_agreement" = %s, "terms_agreement_at" = %s, "customer_intent" = %s, "email_opt_in" = NULL WHERE "users"."id" = %s'
    params = (datetime.datetime(2024, 10, 21, 8, 22, 57, 676393, tzinfo=datetime.timezone.utc), FakeDatetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), '[email protected]', 'codecov-user', False, False, ...)
    ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f3ba094b710>})

    def _execute(self, sql, params, *ignored_wrapper_args):
    self.db.validate_no_broken_transaction()
    with self.db.wrap_database_errors:
    if params is None:
    # params default might be backend specific.
    return self.cursor.execute(sql)
    else:
    > return self.cursor.execute(sql, params)
    E psycopg2.errors.NotNullViolation: null value in column "email_opt_in" of relation "users" violates not-null constraint
    E DETAIL: Failing row contains (3987, 02a58c23-6e39-46cc-817b-6dcb286faac3, 2024-10-21 08:22:57.676393+00, 2022-01-01 00:00:00+00, [email protected], codecov-user, f, f, t, 2022-01-01 00:00:00, Business, null).

    .../local/lib/python3.12.../db/backends/utils.py:89: NotNullViolation

    The above exception was the direct cause of the following exception:

    self = <codecov_auth.commands.owner.interactors.tests.test_save_terms_agreement.UpdateSaveTermsAgreementInteractorTest testMethod=test_update_owner_and_user_when_email_is_not_empty>

    @freeze_time("2022-01-01T00:00:00")
    def test_update_owner_and_user_when_email_is_not_empty(self):
    > self.execute(
    current_user=self.current_user,
    input={
    "business_email": "[email protected]",
    "terms_agreement": True,
    "customer_intent": "Business",
    },
    )

    .../interactors/tests/test_save_terms_agreement.py:66:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/asgiref/sync.py:240: in __call__
    return call_result.result()
    .../local/lib/python3.12....../concurrent/futures/_base.py:449: in result
    return self.__get_result()
    .../local/lib/python3.12....../concurrent/futures/_base.py:401: in __get_result
    raise self._exception
    .../local/lib/python3.12............/site-packages/asgiref/sync.py:306: in main_wrap
    result = await self.awaitable(*args, **kwargs)
    .../local/lib/python3.12............/site-packages/asgiref/sync.py:448: in __call__
    ret = await asyncio.wait_for(future, timeout=None)
    .../local/lib/python3.12/asyncio/tasks.py:520: in wait_for
    return await fut
    .../local/lib/python3.12.../site-packages/asgiref/current_thread_executor.py:22: in run
    result = self.fn(*self.args, **self.kwargs)
    codecov/db/__init__.py:82: in thread_handler
    return super().thread_handler(loop, *args, **kwargs)
    .../local/lib/python3.12............/site-packages/asgiref/sync.py:490: in thread_handler
    return func(*args, **kwargs)
    .../owner/interactors/save_terms_agreement.py:62: in execute
    return self.update_terms_agreement(typed_input)
    .../owner/interactors/save_terms_agreement.py:38: in update_terms_agreement
    self.current_user.save()
    .../local/lib/python3.12.../db/models/base.py:814: in save
    self.save_base(
    .../local/lib/python3.12.../db/models/base.py:877: in save_base
    updated = self._save_table(
    .../local/lib/python3.12.../db/models/base.py:990: in _save_table
    updated = self._do_update(
    .../local/lib/python3.12.../site-packages/django_prometheus/models.py:47: in _do_update
    return super()._do_update(*args, **kwargs)
    .../local/lib/python3.12.../db/models/base.py:1054: in _do_update
    return filtered._update(values) > 0
    .../local/lib/python3.12.../db/models/query.py:1231: in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
    .../local/lib/python3.12.../models/sql/compiler.py:1984: in execute_sql
    cursor = super().execute_sql(result_type)
    .../local/lib/python3.12.../models/sql/compiler.py:1562: in execute_sql
    cursor.execute(sql, params)
    .../local/lib/python3.12.../site-packages/sentry_sdk/utils.py:1730: in runner
    return sentry_patched_function(*args, **kwargs)
    .../local/lib/python3.12.../integrations/django/__init__.py:651: in execute
    result = real_execute(self, sql, params)
    .../local/lib/python3.12.../db/backends/utils.py:67: in execute
    return self._execute_with_wrappers(
    .../local/lib/python3.12.../db/backends/utils.py:80: in _execute_with_wrappers
    return executor(sql, params, many, context)
    .../local/lib/python3.12.../db/backends/utils.py:84: in _execute
    with self.db.wrap_database_errors:
    .../local/lib/python3.12.../django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <django.db.backends.utils.CursorWrapper object at 0x7f3ba094b710>
    sql = 'UPDATE "users" SET "created_at" = %s, "updated_at" = %s, "email" = %s, "name" = %s, "is_staff" = %s, "is_superuser" =...erms_agreement" = %s, "terms_agreement_at" = %s, "customer_intent" = %s, "email_opt_in" = NULL WHERE "users"."id" = %s'
    params = (datetime.datetime(2024, 10, 21, 8, 22, 57, 676393, tzinfo=datetime.timezone.utc), FakeDatetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), '[email protected]', 'codecov-user', False, False, ...)
    ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f3ba094b710>})

    def _execute(self, sql, params, *ignored_wrapper_args):
    self.db.validate_no_broken_transaction()
    with self.db.wrap_database_errors:
    if params is None:
    # params default might be backend specific.
    return self.cursor.execute(sql)
    else:
    > return self.cursor.execute(sql, params)
    E django.db.utils.IntegrityError: null value in column "email_opt_in" of relation "users" violates not-null constraint
    E DETAIL: Failing row contains (3987, 02a58c23-6e39-46cc-817b-6dcb286faac3, 2024-10-21 08:22:57.676393+00, 2022-01-01 00:00:00+00, [email protected], codecov-user, f, f, t, 2022-01-01 00:00:00, Business, null).

    .../local/lib/python3.12.../db/backends/utils.py:89: IntegrityError
  • Class name: codecov_auth.commands.owner.interactors.tests.test_save_terms_agreement.UpdateSaveTermsAgreementInteractorTest
    Test name: test_update_user_when_agreement_is_false

    self = <django.db.backends.utils.CursorWrapper object at 0x7f3ba09cacc0>
    sql = 'UPDATE "users" SET "created_at" = %s, "updated_at" = %s, "email" = %s, "name" = %s, "is_staff" = %s, "is_superuser" =...erms_agreement" = %s, "terms_agreement_at" = %s, "customer_intent" = %s, "email_opt_in" = NULL WHERE "users"."id" = %s'
    params = (datetime.datetime(2024, 10, 21, 8, 22, 58, 235199, tzinfo=datetime.timezone.utc), FakeDatetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), '[email protected]', 'codecov-user', False, False, ...)
    ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f3ba09cacc0>})

    def _execute(self, sql, params, *ignored_wrapper_args):
    self.db.validate_no_broken_transaction()
    with self.db.wrap_database_errors:
    if params is None:
    # params default might be backend specific.
    return self.cursor.execute(sql)
    else:
    > return self.cursor.execute(sql, params)
    E psycopg2.errors.NotNullViolation: null value in column "email_opt_in" of relation "users" violates not-null constraint
    E DETAIL: Failing row contains (3988, e5a511e0-06ae-42e0-9389-ae15208fb087, 2024-10-21 08:22:58.235199+00, 2022-01-01 00:00:00+00, [email protected], codecov-user, f, f, f, 2022-01-01 00:00:00, Business, null).

    .../local/lib/python3.12.../db/backends/utils.py:89: NotNullViolation

    The above exception was the direct cause of the following exception:

    self = <codecov_auth.commands.owner.interactors.tests.test_save_terms_agreement.UpdateSaveTermsAgreementInteractorTest testMethod=test_update_user_when_agreement_is_false>

    @freeze_time("2022-01-01T00:00:00")
    def test_update_user_when_agreement_is_false(self):
    > self.execute(
    current_user=self.current_user,
    input={"terms_agreement": False, "customer_intent": "Business"},
    )

    .../interactors/tests/test_save_terms_agreement.py:38:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/asgiref/sync.py:240: in __call__
    return call_result.result()
    .../local/lib/python3.12....../concurrent/futures/_base.py:449: in result
    return self.__get_result()
    .../local/lib/python3.12....../concurrent/futures/_base.py:401: in __get_result
    raise self._exception
    .../local/lib/python3.12............/site-packages/asgiref/sync.py:306: in main_wrap
    result = await self.awaitable(*args, **kwargs)
    .../local/lib/python3.12............/site-packages/asgiref/sync.py:448: in __call__
    ret = await asyncio.wait_for(future, timeout=None)
    .../local/lib/python3.12/asyncio/tasks.py:520: in wait_for
    return await fut
    .../local/lib/python3.12.../site-packages/asgiref/current_thread_executor.py:22: in run
    result = self.fn(*self.args, **self.kwargs)
    codecov/db/__init__.py:82: in thread_handler
    return super().thread_handler(loop, *args, **kwargs)
    .../local/lib/python3.12............/site-packages/asgiref/sync.py:490: in thread_handler
    return func(*args, **kwargs)
    .../owner/interactors/save_terms_agreement.py:62: in execute
    return self.update_terms_agreement(typed_input)
    .../owner/interactors/save_terms_agreement.py:38: in update_terms_agreement
    self.current_user.save()
    .../local/lib/python3.12.../db/models/base.py:814: in save
    self.save_base(
    .../local/lib/python3.12.../db/models/base.py:877: in save_base
    updated = self._save_table(
    .../local/lib/python3.12.../db/models/base.py:990: in _save_table
    updated = self._do_update(
    .../local/lib/python3.12.../site-packages/django_prometheus/models.py:47: in _do_update
    return super()._do_update(*args, **kwargs)
    .../local/lib/python3.12.../db/models/base.py:1054: in _do_update
    return filtered._update(values) > 0
    .../local/lib/python3.12.../db/models/query.py:1231: in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
    .../local/lib/python3.12.../models/sql/compiler.py:1984: in execute_sql
    cursor = super().execute_sql(result_type)
    .../local/lib/python3.12.../models/sql/compiler.py:1562: in execute_sql
    cursor.execute(sql, params)
    .../local/lib/python3.12.../site-packages/sentry_sdk/utils.py:1730: in runner
    return sentry_patched_function(*args, **kwargs)
    .../local/lib/python3.12.../integrations/django/__init__.py:651: in execute
    result = real_execute(self, sql, params)
    .../local/lib/python3.12.../db/backends/utils.py:67: in execute
    return self._execute_with_wrappers(
    .../local/lib/python3.12.../db/backends/utils.py:80: in _execute_with_wrappers
    return executor(sql, params, many, context)
    .../local/lib/python3.12.../db/backends/utils.py:84: in _execute
    with self.db.wrap_database_errors:
    .../local/lib/python3.12.../django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <django.db.backends.utils.CursorWrapper object at 0x7f3ba09cacc0>
    sql = 'UPDATE "users" SET "created_at" = %s, "updated_at" = %s, "email" = %s, "name" = %s, "is_staff" = %s, "is_superuser" =...erms_agreement" = %s, "terms_agreement_at" = %s, "customer_intent" = %s, "email_opt_in" = NULL WHERE "users"."id" = %s'
    params = (datetime.datetime(2024, 10, 21, 8, 22, 58, 235199, tzinfo=datetime.timezone.utc), FakeDatetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), '[email protected]', 'codecov-user', False, False, ...)
    ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f3ba09cacc0>})

    def _execute(self, sql, params, *ignored_wrapper_args):
    self.db.validate_no_broken_transaction()
    with self.db.wrap_database_errors:
    if params is None:
    # params default might be backend specific.
    return self.cursor.execute(sql)
    else:
    > return self.cursor.execute(sql, params)
    E django.db.utils.IntegrityError: null value in column "email_opt_in" of relation "users" violates not-null constraint
    E DETAIL: Failing row contains (3988, e5a511e0-06ae-42e0-9389-ae15208fb087, 2024-10-21 08:22:58.235199+00, 2022-01-01 00:00:00+00, [email protected], codecov-user, f, f, f, 2022-01-01 00:00:00, Business, null).

    .../local/lib/python3.12.../db/backends/utils.py:89: IntegrityError
  • Class name: codecov_auth.commands.owner.interactors.tests.test_save_terms_agreement.UpdateSaveTermsAgreementInteractorTest
    Test name: test_update_user_when_agreement_is_true

    self = <django.db.backends.utils.CursorWrapper object at 0x7f3ba094bb30>
    sql = 'UPDATE "users" SET "created_at" = %s, "updated_at" = %s, "email" = %s, "name" = %s, "is_staff" = %s, "is_superuser" =...erms_agreement" = %s, "terms_agreement_at" = %s, "customer_intent" = %s, "email_opt_in" = NULL WHERE "users"."id" = %s'
    params = (datetime.datetime(2024, 10, 21, 8, 22, 59, 167046, tzinfo=datetime.timezone.utc), FakeDatetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), '[email protected]', 'codecov-user', False, False, ...)
    ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f3ba094bb30>})

    def _execute(self, sql, params, *ignored_wrapper_args):
    self.db.validate_no_broken_transaction()
    with self.db.wrap_database_errors:
    if params is None:
    # params default might be backend specific.
    return self.cursor.execute(sql)
    else:
    > return self.cursor.execute(sql, params)
    E psycopg2.errors.NotNullViolation: null value in column "email_opt_in" of relation "users" violates not-null constraint
    E DETAIL: Failing row contains (3989, 6fd317f3-2d4f-4573-9b61-bf99e576f25c, 2024-10-21 08:22:59.167046+00, 2022-01-01 00:00:00+00, [email protected], codecov-user, f, f, t, 2022-01-01 00:00:00, Business, null).

    .../local/lib/python3.12.../db/backends/utils.py:89: NotNullViolation

    The above exception was the direct cause of the following exception:

    self = <codecov_auth.commands.owner.interactors.tests.test_save_terms_agreement.UpdateSaveTermsAgreementInteractorTest testMethod=test_update_user_when_agreement_is_true>

    @freeze_time("2022-01-01T00:00:00")
    def test_update_user_when_agreement_is_true(self):
    > self.execute(
    current_user=self.current_user,
    input={"terms_agreement": True, "customer_intent": "Business"},
    )

    .../interactors/tests/test_save_terms_agreement.py:52:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    .../local/lib/python3.12............/site-packages/asgiref/sync.py:240: in __call__
    return call_result.result()
    .../local/lib/python3.12....../concurrent/futures/_base.py:449: in result
    return self.__get_result()
    .../local/lib/python3.12....../concurrent/futures/_base.py:401: in __get_result
    raise self._exception
    .../local/lib/python3.12............/site-packages/asgiref/sync.py:306: in main_wrap
    result = await self.awaitable(*args, **kwargs)
    .../local/lib/python3.12............/site-packages/asgiref/sync.py:448: in __call__
    ret = await asyncio.wait_for(future, timeout=None)
    .../local/lib/python3.12/asyncio/tasks.py:520: in wait_for
    return await fut
    .../local/lib/python3.12.../site-packages/asgiref/current_thread_executor.py:22: in run
    result = self.fn(*self.args, **self.kwargs)
    codecov/db/__init__.py:82: in thread_handler
    return super().thread_handler(loop, *args, **kwargs)
    .../local/lib/python3.12............/site-packages/asgiref/sync.py:490: in thread_handler
    return func(*args, **kwargs)
    .../owner/interactors/save_terms_agreement.py:62: in execute
    return self.update_terms_agreement(typed_input)
    .../owner/interactors/save_terms_agreement.py:38: in update_terms_agreement
    self.current_user.save()
    .../local/lib/python3.12.../db/models/base.py:814: in save
    self.save_base(
    .../local/lib/python3.12.../db/models/base.py:877: in save_base
    updated = self._save_table(
    .../local/lib/python3.12.../db/models/base.py:990: in _save_table
    updated = self._do_update(
    .../local/lib/python3.12.../site-packages/django_prometheus/models.py:47: in _do_update
    return super()._do_update(*args, **kwargs)
    .../local/lib/python3.12.../db/models/base.py:1054: in _do_update
    return filtered._update(values) > 0
    .../local/lib/python3.12.../db/models/query.py:1231: in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
    .../local/lib/python3.12.../models/sql/compiler.py:1984: in execute_sql
    cursor = super().execute_sql(result_type)
    .../local/lib/python3.12.../models/sql/compiler.py:1562: in execute_sql
    cursor.execute(sql, params)
    .../local/lib/python3.12.../site-packages/sentry_sdk/utils.py:1730: in runner
    return sentry_patched_function(*args, **kwargs)
    .../local/lib/python3.12.../integrations/django/__init__.py:651: in execute
    result = real_execute(self, sql, params)
    .../local/lib/python3.12.../db/backends/utils.py:67: in execute
    return self._execute_with_wrappers(
    .../local/lib/python3.12.../db/backends/utils.py:80: in _execute_with_wrappers
    return executor(sql, params, many, context)
    .../local/lib/python3.12.../db/backends/utils.py:84: in _execute
    with self.db.wrap_database_errors:
    .../local/lib/python3.12.../django/db/utils.py:91: in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <django.db.backends.utils.CursorWrapper object at 0x7f3ba094bb30>
    sql = 'UPDATE "users" SET "created_at" = %s, "updated_at" = %s, "email" = %s, "name" = %s, "is_staff" = %s, "is_superuser" =...erms_agreement" = %s, "terms_agreement_at" = %s, "customer_intent" = %s, "email_opt_in" = NULL WHERE "users"."id" = %s'
    params = (datetime.datetime(2024, 10, 21, 8, 22, 59, 167046, tzinfo=datetime.timezone.utc), FakeDatetime(2022, 1, 1, 0, 0, tzinfo=datetime.timezone.utc), '[email protected]', 'codecov-user', False, False, ...)
    ignored_wrapper_args = (False, {'connection': <DatabaseWrapper vendor='postgresql' alias='default'>, 'cursor': <django.db.backends.utils.CursorWrapper object at 0x7f3ba094bb30>})

    def _execute(self, sql, params, *ignored_wrapper_args):
    self.db.validate_no_broken_transaction()
    with self.db.wrap_database_errors:
    if params is None:
    # params default might be backend specific.
    return self.cursor.execute(sql)
    else:
    > return self.cursor.execute(sql, params)
    E django.db.utils.IntegrityError: null value in column "email_opt_in" of relation "users" violates not-null constraint
    E DETAIL: Failing row contains (3989, 6fd317f3-2d4f-4573-9b61-bf99e576f25c, 2024-10-21 08:22:59.167046+00, 2022-01-01 00:00:00+00, [email protected], codecov-user, f, f, t, 2022-01-01 00:00:00, Business, null).

    .../local/lib/python3.12.../db/backends/utils.py:89: IntegrityError

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

This PR includes changes to shared. Please review them here: https://github.com/codecov/shared/compare/a97eb0ab37733bbb37912a0c26a84f4475437c65...f8cbb655db920fd3f6707b82e009c494630c0752

github-actions[bot] avatar Oct 02 '24 10:10 github-actions[bot]

This PR includes changes to shared. Please review them here: https://github.com/codecov/shared/compare/88117b96a4b420d88549b8df2649c3eb9c61c2a5...bf3b6ee9973e7ec3b1eb57b6dce6ce96a18cbaa1

github-actions[bot] avatar Oct 04 '24 13:10 github-actions[bot]

This PR includes changes to shared. Please review them here: https://github.com/codecov/shared/compare/88117b96a4b420d88549b8df2649c3eb9c61c2a5...bf3b6ee9973e7ec3b1eb57b6dce6ce96a18cbaa1

github-actions[bot] avatar Oct 07 '24 09:10 github-actions[bot]

I see some spots where you've swapped it to the shared factory, and others where you've left it referring to the api factory

This might just be an oversight. This PR still has a ton of failures, and merge conflicts by now, so I will turn it into a draft in the meantime before fixing all that. Thanks for the review nevertheless :-)

Swatinem avatar Oct 14 '24 08:10 Swatinem

This PR includes changes to shared. Please review them here: https://github.com/codecov/shared/compare/88117b96a4b420d88549b8df2649c3eb9c61c2a5...3cac029e52c1bc587f80b1e619103ce5ac4dee66

github-actions[bot] avatar Oct 16 '24 10:10 github-actions[bot]

I rebased the PR, and fixed all of the remaining tests, so things are green 🎉 I would appreciate another review, and hope to get this landed rather sooner than later :-)

Swatinem avatar Oct 16 '24 12:10 Swatinem

This PR includes changes to shared. Please review them here: https://github.com/codecov/shared/compare/88117b96a4b420d88549b8df2649c3eb9c61c2a5...f0e213c4399563990d43fb424f4be36faa5ce5eb

github-actions[bot] avatar Oct 21 '24 08:10 github-actions[bot]