Skip to content

Commit

Permalink
Merge pull request #238 from CMSTrackerDPG/test_django_allauth
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingface0 authored Jul 14, 2023
2 parents e84dee8 + f2a3522 commit 65e2b40
Show file tree
Hide file tree
Showing 16 changed files with 566 additions and 218 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,19 @@ jobs:
git config --global url."https://${{ secrets.CERN_GITLAB_USER }}:${{ secrets.CERN_GITLAB_TOKEN }}@gitlab.cern.ch".insteadOf https://gitlab.cern.ch
git config --global url."https://${{ secrets.CERN_GITLAB_USER }}:${{ secrets.CERN_GITLAB_TOKEN }}@gitlab.cern.ch".insteadOf https://gitlab.cern.ch
python -m pip install --upgrade pip
mkdir -p /tmp/runner
git clone https://github.com/nothingface0/django-allauth.git /tmp/runner/django-allauth
cd /tmp/runner/django-allauth
git checkout 77368a8
wget https://github.com/pennersr/django-allauth/compare/main...nothingface0:django-allauth:fix_cern_sso.patch --output-document=patch
git apply patch --reject || true
cd -
pip install -r requirements.txt
pip install --index-url https://test.pypi.org/simple runregistry==1.0.0
pip install --upgrade pytest pytest-django pytest-cov codecov mixer selenium
- name: Run Unit Tests
Expand Down
13 changes: 13 additions & 0 deletions .s2i/bin/assemble
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
#!/bin/bash
echo "Before assembling"
git config --global url."https://$CERN_GITLAB_USER:$CERN_GITLAB_TOKEN@gitlab.cern.ch".insteadOf https://gitlab.cern.ch

# TODO: remove once PR in django-allauth merged
mkdir -p /tmp/runner
git clone https://github.com/nothingface0/django-allauth.git /tmp/runner/django-allauth
cd /tmp/runner/django-allauth
git checkout 77368a8
wget https://github.com/pennersr/django-allauth/compare/main...nothingface0:django-allauth:fix_cern_sso.patch --output-document=patch
git apply patch --reject || true
cd -


/usr/libexec/s2i/assemble
rc=$?

ls

# Temporarily install runregistry api client from test PyPI
pip install --index-url https://test.pypi.org/simple runregistry==1.0.0

Expand Down
2 changes: 1 addition & 1 deletion certifier/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def runs_for_slr():
@pytest.fixture
def shifter(django_user_model):
user = mixer.blend(get_user_model(), username=SHIFTER1_USERNAME, password=PASSWORD)
user.extra_data = {"groups": ["tkdqmdoctor-shifters"]}
user.extra_data = {"cern_roles": ["shifter"]}
user.update_privilege()
user.save()
return user
Expand Down
8 changes: 6 additions & 2 deletions dqmhelper/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"allauth.account",
"allauth.socialaccount",
"allauth.socialaccount.providers.cern",
"allauth.socialaccount.providers.github",
"widget_tweaks",
"django_extensions",
"django_tables2",
Expand Down Expand Up @@ -176,7 +175,11 @@

USE_TZ = True

SITE_ID = 1
# This must be added from the admin page. Then, you
# can see the id by:
# from django.contrib.sites.models import Site
# Site.objects.all()
SITE_ID = config("SITE_ID", default=2, cast=int)

LOGGING = {
"version": 1,
Expand Down Expand Up @@ -222,3 +225,4 @@

# When Upgraded to Django 3.2 - RELEASE 06.04.2021
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
ACCOUNT_EMAIL_VERIFICATION = "none"
8 changes: 4 additions & 4 deletions listruns/tests/test_listruns_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_update_not_logged_dispatch(self):
req = RequestFactory().get(reverse("listruns:update", kwargs=arguments))

user = mixer.blend(get_user_model())
user.extra_data = {"groups": ["tkdqmdoctor-shiftleaders"]}
user.extra_data = {"cern_roles": ["shiftleader"]}
user.update_privilege()
user.save()

Expand Down Expand Up @@ -158,7 +158,7 @@ def test_update_get_success_url(self):
req = RequestFactory().get(reverse("listruns:update", kwargs=arguments))

user = mixer.blend(get_user_model())
user.extra_data = {"groups": ["tkdqmdoctor-shiftleaders"]}
user.extra_data = {"cern_roles": ["shiftleader"]}
user.update_privilege()
user.save()

Expand Down Expand Up @@ -195,7 +195,7 @@ def test_update_same_user_or_shiftleader_true(self):
req = RequestFactory().get(reverse("listruns:update", kwargs=arguments))

user = mixer.blend(get_user_model())
user.extra_data = {"groups": ["tkdqmdoctor-shiftleaders"]}
user.extra_data = {"cern_roles": ["shiftleader"]}
user.update_privilege()
user.save()

Expand Down Expand Up @@ -233,7 +233,7 @@ def test_update_same_user_or_shiftleader_false(self):

user = mixer.blend(get_user_model())
user_aux = mixer.blend(get_user_model())
user.extra_data = {"groups": ["tkdqmdoctor-shiftleaders"]}
user.extra_data = {"cern_roles": ["shiftleader"]}
user.update_privilege()
user.save()

Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ certifi<2023.0.0
channels[daphne]
channels_redis
Django<4.2.0
django-allauth<1.0.0
# TODO: Update this once PR is merged to django-allauth
-e /tmp/runner/django-allauth
#django-allauth<1.0.0
django-bootstrap3<24.0
django-filter<24.0
django-ckeditor<7.0.0
Expand Down
2 changes: 1 addition & 1 deletion shiftleader/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@pytest.fixture
def shifter(django_user_model):
user = mixer.blend(get_user_model(), username=SHIFTER1_USERNAME, password=PASSWORD)
user.extra_data = {"groups": ["tkdqmdoctor-shifters"]}
user.extra_data = {"cern_roles": ["shifter"]}
user.update_privilege()
user.save()
return user
Expand Down
Loading

0 comments on commit 65e2b40

Please sign in to comment.