Skip to content

Commit

Permalink
Merge pull request breatheco-de#1450 from jefer94/feat/capy-core
Browse files Browse the repository at this point in the history
add capy core package
  • Loading branch information
jefer94 authored Sep 5, 2024
2 parents fc4e181 + e080757 commit c5b0f92
Show file tree
Hide file tree
Showing 95 changed files with 2,208 additions and 4,347 deletions.
15 changes: 9 additions & 6 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ google-apps-meet = "*"
google-auth-httplib2 = "*"
google-auth-oauthlib = "*"
black = "*"
capy-core = {extras = ["pytest"], version = "*"}

[packages]
django = "*"
Expand Down Expand Up @@ -128,19 +129,21 @@ brotli = "*"
circuitbreaker = "*"
kombu = "*"
zstandard = "*"
psycopg = {extras = ["pool", "binary"], version = "*"}
psycopg = {extras = ["pool", "binary"] }
cryptography = "*"
adrf = "*"
uvicorn = "*"
django-minify-html = "*"
django-storages = {extras = ["google"], version = "*"}
aiohttp = {extras = ["speedups"], version = "*"}
django-storages = {extras = ["google"] }
aiohttp = {extras = ["speedups"] }
aiodns = "*"
eventlet = "*"
linked-services = {extras = ["django", "aiohttp", "requests"], version = "*"}
celery-task-manager = {extras = ["django"], version = "*"}
django-sql-explorer = {extras = ["xls"], version = "*"}
linked-services = {extras = ["django", "aiohttp", "requests"] }
celery-task-manager = {extras = ["django"] }
django-sql-explorer = {extras = ["xls"] }
contextlib2 = "*"
google-apps-meet = "*"
google-auth-httplib2 = "*"
google-auth-oauthlib = "*"
capy-core = {extras = ["django"], version = "*"}
google-api-python-client = "*"
3,523 changes: 1,902 additions & 1,621 deletions Pipfile.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

from unittest.mock import MagicMock

import capyc.pytest as capyc
import pytest
from dateutil.relativedelta import relativedelta
from linked_services.django.actions import reset_app_cache

from breathecode.assignments.management.commands.schedule_repository_deletions import Command
from breathecode.registry.models import Asset
from capyc.rest_framework import pytest as capyc


@pytest.fixture(autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion breathecode/assignments/tests/urls/tests_user_me_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from datetime import datetime
from unittest.mock import MagicMock, call, patch

import capyc.pytest as capy
import pytest
from django.urls.base import reverse_lazy
from django.utils import timezone
Expand All @@ -15,7 +16,6 @@
from breathecode.assignments import tasks
from breathecode.assignments.caches import TaskCache
from breathecode.utils.api_view_extensions.api_view_extension_handlers import APIViewExtensionHandlers
from capyc.rest_framework import pytest as capy

from ..mixins import AssignmentsTestCase

Expand Down
19 changes: 18 additions & 1 deletion breathecode/authenticate/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,24 @@ def save(self, *args, **kwargs):
class AcademyAuthSettings(models.Model):
academy = models.OneToOneField(Academy, on_delete=models.CASCADE)
github_username = models.SlugField(max_length=40, blank=True)
github_owner = models.ForeignKey(User, on_delete=models.SET_NULL, blank=True, default=None, null=True)
github_owner = models.ForeignKey(
User,
on_delete=models.SET_NULL,
blank=True,
default=None,
null=True,
# TODO: uncomment this
# help_text="Github auth token for this user will be used for any admin call to the google cloud api, for example: inviting users to the academy",
)
# TODO: uncomment this
# google_cloud_owner = models.ForeignKey(
# User,
# on_delete=models.SET_NULL,
# blank=True,
# default=None,
# null=True,
# help_text="Google auth token for this user will be used for any admin call to the google cloud api, for example: creating classroom video calls",
# )
github_default_team_ids = models.CharField(
max_length=40,
blank=True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import random
from unittest.mock import MagicMock, call

import capyc.pytest as capy
import pytest

from breathecode.authenticate.tasks import async_validate_email_invite
from capyc.rest_framework import pytest as capy


@pytest.fixture(autouse=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import random
from unittest.mock import MagicMock, call

import capyc.pytest as capy
import pytest

from breathecode.authenticate.tasks import verify_user_invite_email
from breathecode.notify import actions
from capyc.rest_framework import pytest as capy


@pytest.fixture(autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion breathecode/authenticate/tests/urls/tests_app_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from typing import Callable
from unittest.mock import MagicMock

import capyc.pytest as capy
import pytest
from django.urls.base import reverse_lazy
from rest_framework import status

from breathecode.tests.mixins.breathecode_mixin.breathecode import Breathecode
from capyc.rest_framework import pytest as capy


@pytest.fixture(autouse=True)
Expand Down
6 changes: 3 additions & 3 deletions breathecode/events/tests/urls/tests_me_event_id_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from datetime import timedelta
from unittest.mock import MagicMock, call, patch

import capyc.pytest as capy
import pytest
from django.template import loader
from django.urls.base import reverse_lazy
Expand All @@ -11,7 +12,6 @@
from breathecode.events.caches import EventCache
from breathecode.payments import tasks
from breathecode.tests.mixins.breathecode_mixin.breathecode import Breathecode
from capyc.rest_framework.pytest import fixtures as fx

from ..mixins.new_events_tests_case import EventTestCase

Expand Down Expand Up @@ -1557,7 +1557,7 @@ def test_with_consumable__it_try_to_consume__with_live_event__in_the_future__sho
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test__post__auth__no_saas__finantial_status_no_late(
bc: Breathecode, client: fx.Client, academy, cohort, cohort_user
bc: Breathecode, client: capy.Client, academy, cohort, cohort_user
):
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = bc.fake.url()
Expand Down Expand Up @@ -1643,7 +1643,7 @@ def test__post__auth__no_saas__finantial_status_no_late(
@patch("django.db.models.signals.pre_delete.send_robust", MagicMock(return_value=None))
@patch("breathecode.admissions.signals.student_edu_status_updated.send_robust", MagicMock(return_value=None))
@patch("breathecode.payments.tasks.end_the_consumption_session.apply_async", MagicMock(return_value=None))
def test__post__auth__no_saas__finantial_status_late(bc: Breathecode, client: fx.Client, academy, cohort):
def test__post__auth__no_saas__finantial_status_late(bc: Breathecode, client: capy.Client, academy, cohort):
service = {"consumer": "EVENT_JOIN"}
online_meeting_url = bc.fake.url()
delta = timedelta(seconds=random.randint(1, 1000))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from logging import Logger
from unittest.mock import MagicMock, call

import capyc.pytest as capy
import pytest
from asgiref.sync import sync_to_async

Expand All @@ -11,7 +12,6 @@
from breathecode.monitoring.models import SupervisorIssue
from breathecode.tests.mixins.breathecode_mixin.breathecode import Breathecode
from breathecode.utils.decorators import supervisor as supervisor_decorator
from capyc.rest_framework import pytest as capy


class Supervisor:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
from datetime import datetime, timedelta
from logging import Logger
from unittest.mock import MagicMock, call
from unittest.mock import MagicMock

import capyc.pytest as capy
import pytest
from asgiref.sync import sync_to_async

from breathecode.feedback.supervisors import supervise_mentorship_survey
from breathecode.monitoring.models import Supervisor as SupervisorModel
from breathecode.monitoring.models import SupervisorIssue
from breathecode.tests.mixins.breathecode_mixin.breathecode import Breathecode
from breathecode.utils.decorators import supervisor as supervisor_decorator
from capyc.rest_framework import pytest as capy


class Supervisor:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import logging
from unittest.mock import MagicMock, call

import capyc.pytest as capy
import pytest
from django.utils import timezone

from breathecode.feedback.tasks import process_student_graduation
from capyc.rest_framework import pytest as capy

now = timezone.now()

Expand Down
2 changes: 1 addition & 1 deletion breathecode/media/tests/settings/tests_del_temp_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from unittest.mock import MagicMock, PropertyMock, call

import capyc.pytest as capy
import pytest

from breathecode.media.settings import del_temp_file
from breathecode.services.google_cloud import File, Storage
from capyc.rest_framework import pytest as capy


@pytest.fixture(autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion breathecode/media/tests/settings/tests_process_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from unittest.mock import MagicMock, call

import capyc.pytest as capy
import pytest

from breathecode.media import settings
from breathecode.media.settings import MEDIA_SETTINGS, process_media
from capyc.rest_framework import pytest as capy


@pytest.fixture(autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion breathecode/media/tests/settings/tests_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from io import BytesIO
from unittest.mock import AsyncMock, MagicMock, PropertyMock, call

import capyc.pytest as capy
import pytest

from breathecode.media import settings
from breathecode.media.settings import MEDIA_SETTINGS, transfer
from breathecode.services.google_cloud import File, Storage
from capyc.rest_framework import pytest as capy


def mock_download(x: BytesIO) -> None:
Expand Down
2 changes: 1 addition & 1 deletion breathecode/media/tests/signals/tests_schedule_deletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import random
from unittest.mock import MagicMock, PropertyMock, call

import capyc.pytest as capy
import pytest

from breathecode.media import settings
from breathecode.media.signals import schedule_deletion
from breathecode.services.google_cloud import File, Storage
from capyc.rest_framework import pytest as capy


@pytest.fixture(autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion breathecode/media/tests/tasks/tests_process_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from logging import Logger
from unittest.mock import MagicMock, call

import capyc.pytest as capy
import pytest

from breathecode.media.settings import MEDIA_SETTINGS
from breathecode.media.tasks import process_file
from capyc.rest_framework import pytest as capy


@pytest.fixture(autouse=True)
Expand Down
2 changes: 1 addition & 1 deletion breathecode/media/tests/urls/v2/tests_academy_chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from typing import Callable
from unittest.mock import MagicMock, PropertyMock, call

import capyc.pytest as capy
import pytest
from django.core.files.uploadedfile import InMemoryUploadedFile, SimpleUploadedFile
from django.urls.base import reverse_lazy
from rest_framework import status

from breathecode.services.google_cloud import File, Storage
from capyc.rest_framework import pytest as capy


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from io import BytesIO
from unittest.mock import AsyncMock, MagicMock, PropertyMock, call

import capyc.pytest as capy
import pytest
from django.core.files.uploadedfile import SimpleUploadedFile
from django.urls.base import reverse_lazy
Expand All @@ -15,7 +16,6 @@
from breathecode.media.signals import schedule_deletion
from breathecode.media.tasks import process_file
from breathecode.services.google_cloud import File, Storage
from capyc.rest_framework import pytest as capy


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion breathecode/media/tests/urls/v2/tests_me_chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
from typing import Callable
from unittest.mock import MagicMock, PropertyMock, call

import capyc.pytest as capy
import pytest
from django.core.files.uploadedfile import InMemoryUploadedFile, SimpleUploadedFile
from django.urls.base import reverse_lazy
from rest_framework import status

from breathecode.services.google_cloud import File, Storage
from capyc.rest_framework import pytest as capy


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion breathecode/media/tests/urls/v2/tests_me_chunk_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import Callable
from unittest.mock import AsyncMock, MagicMock, PropertyMock, call

import capyc.pytest as capy
import pytest
from django.core.files.uploadedfile import InMemoryUploadedFile, SimpleUploadedFile
from django.urls.base import reverse_lazy
Expand All @@ -16,7 +17,6 @@
from breathecode.media.signals import schedule_deletion
from breathecode.media.tasks import process_file
from breathecode.services.google_cloud import File, Storage
from capyc.rest_framework import pytest as capy


@pytest.fixture
Expand Down
3 changes: 1 addition & 2 deletions breathecode/media/tests/urls/v2/tests_operationtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
Test /answer
"""

import capyc.pytest as capy
from django.urls.base import reverse_lazy
from django.utils import timezone
from rest_framework import status

from capyc.rest_framework import pytest as capy

UTC_NOW = timezone.now()


Expand Down
3 changes: 1 addition & 2 deletions breathecode/media/tests/urls/v2/tests_operationtype_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
Test /answer
"""

import capyc.pytest as capy
import pytest
from django.urls.base import reverse_lazy
from django.utils import timezone
from rest_framework import status

from capyc.rest_framework import pytest as capy

UTC_NOW = timezone.now()


Expand Down
2 changes: 1 addition & 1 deletion breathecode/mentorship/tests/admin/tests_use_daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Test mentorships
"""

import capyc.pytest as capy
import pytest

from breathecode.mentorship.admin import use_daily
from capyc.rest_framework import pytest as capy


@pytest.mark.fixture(autouse=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Test mentorships
"""

import capyc.pytest as capy
import pytest

from breathecode.mentorship.admin import use_google_meet
from capyc.rest_framework import pytest as capy


@pytest.mark.fixture(autouse=True)
Expand Down
Loading

0 comments on commit c5b0f92

Please sign in to comment.