Skip to content

Commit

Permalink
[DONE] Code formatting and cleanup (#1101)
Browse files Browse the repository at this point in the history
* Minor code formatting and cleanup:
* Flake8: ignore node_modules path, no more ignore E203, and ignore some very stricts pydocstyle rules
* Typo: Remove space before `:` in english strings.
* Add some missing Pydocs
* Correct some pydoc formats (use imperative, ending dot, startig cap, etc...)
* Remove a lot of flake8 pydocstring warnings

* Correct Playlist Unit test

* Remove merge artifacts
+ compile .mo lang files

* Correct the self.assertContains call in playlist test
  • Loading branch information
Badatos authored Apr 15, 2024
1 parent 58b0f75 commit f3c34d9
Show file tree
Hide file tree
Showing 117 changed files with 645 additions and 671 deletions.
4 changes: 2 additions & 2 deletions .env.dev-exemple
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ELASTICSEARCH_TAG=elasticsearch:8.13.0
NODE_TAG=node:19
PYTHON_TAG=python:3.9-bullseye
REDIS_TAG=redis:alpine3.16
### DOCKER_ENV : You can specify light or full.
### DOCKER_ENV: You can specify light or full.
### In case of value changing, you have to rebuild and restart your container.
### All yours datas will be kept.
DOCKER_ENV=light
DOCKER_ENV=light
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Before sending your pull request, make sure the following are done :
Before sending your pull request, make sure the following are done:

* [ ] You have read our [contribution guidelines](https://github.com/EsupPortail/Esup-Pod/blob/master/CONTRIBUTING.md).
* [ ] Your PR targets the `develop` branch.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pod_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env:
ELASTICSEARCH_TAG: "elasticsearch:7.17.18"
NODE_VERSION: "19"
NODE_TAG: "node:19"
PYTHON_TAG: "python:3.9-buster"
PYTHON_TAG: "python:3.9-bullseye"
REDIS_TAG: "redis:alpine3.16"
DOCKER_ENV: "full-test"

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ While the prerequisites above must be satisfied prior to having your pull reques

### Git config

Warning about the configuration of line ending : https://docs.github.com/fr/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
Warning about the configuration of line ending: https://docs.github.com/fr/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
We add a .gitattributes file at the root of repository

### Git Commit Messages
Expand Down
2 changes: 1 addition & 1 deletion dockerfile-dev-with-volumes/pod-back/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ COPY --from=source-build-js /tmp/pod/node_modules/ /tmp/node_modules/
RUN pip3 install --no-cache-dir -r requirements-conteneur.txt \
&& pip3 install elasticsearch==7.17.7

# ENTRYPOINT :
# ENTRYPOINT:
COPY ./dockerfile-dev-with-volumes/pod-back/my-entrypoint-back.sh /tmp/my-entrypoint-back.sh
RUN chmod 755 /tmp/my-entrypoint-back.sh

Expand Down
2 changes: 1 addition & 1 deletion dockerfile-dev-with-volumes/pod-encode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ COPY ./requirements-encode.txt .

RUN pip3 install --no-cache-dir -r requirements-encode.txt

# ENTRYPOINT :
# ENTRYPOINT:
COPY ./dockerfile-dev-with-volumes/pod-encode/my-entrypoint-encode.sh /tmp/my-entrypoint-encode.sh
RUN chmod 755 /tmp/my-entrypoint-encode.sh

Expand Down
4 changes: 2 additions & 2 deletions dockerfile-dev-with-volumes/pod-transcript/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ COPY ./requirements-encode.txt .
COPY ./requirements-transcripts.txt .

RUN pip3 install --no-cache-dir -r requirements-transcripts.txt \
&& pip3 install --no-cache-dir -r requirements-encode.txt
&& pip3 install --no-cache-dir -r requirements-encode.txt

# ENTRYPOINT :
# ENTRYPOINT:
COPY ./dockerfile-dev-with-volumes/pod-transcript/my-entrypoint-transcript.sh /tmp/my-entrypoint-transcript.sh
RUN chmod 755 /tmp/my-entrypoint-transcript.sh

Expand Down
2 changes: 1 addition & 1 deletion dockerfile-dev-with-volumes/pod-xapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ COPY ./requirements-encode.txt .

RUN pip3 install --no-cache-dir -r requirements-encode.txt

# ENTRYPOINT :
# ENTRYPOINT:
COPY ./dockerfile-dev-with-volumes/pod-xapi/my-entrypoint-xapi.sh /tmp/my-entrypoint-xapi.sh
RUN chmod 755 /tmp/my-entrypoint-xapi.sh

Expand Down
2 changes: 1 addition & 1 deletion dockerfile-dev-with-volumes/pod/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ COPY --from=source-build-js /tmp/pod/node_modules/ /tmp/node_modules/
RUN pip3 install --no-cache-dir -r requirements-conteneur.txt \
&& pip3 install elasticsearch==8.9.0

# ENTRYPOINT :
# ENTRYPOINT:
COPY ./dockerfile-dev-with-volumes/pod/my-entrypoint.sh /tmp/my-entrypoint.sh
RUN chmod 755 /tmp/my-entrypoint.sh

Expand Down
3 changes: 2 additions & 1 deletion pod/authentication/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Esup-Pod authentication models."""
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User, Permission, Group
Expand Down Expand Up @@ -66,7 +67,7 @@

def get_name(self) -> str:
"""
Returns the user's full name, including the username if not hidden.
Return the user's full name, including the username if not hidden.
Returns:
str: The user's full name and username if not hidden.
Expand Down
5 changes: 3 additions & 2 deletions pod/authentication/shibmiddleware.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Esup-Pod Shibboleth middleware authentication."""
from shibboleth.middleware import ShibbolethRemoteUserMiddleware
from django.conf import settings
from pod.authentication.models import AFFILIATION_STAFF
Expand Down Expand Up @@ -46,7 +47,7 @@ class ShibbMiddleware(ShibbolethRemoteUserMiddleware):
header = REMOTE_USER_HEADER

def check_user_meta(self, user, shib_meta):
"""Check shibboleth access rights with user's meta
"""Check Shibboleth access rights with user's meta.
Args:
user: User,
Expand All @@ -62,7 +63,7 @@ def check_user_meta(self, user, shib_meta):
)

def is_staffable(self, user):
"""Check that given user, his domain is in authorized domains of shibboleth staff
"""Check that given user, his domain is in authorized domains of shibboleth staff.
Args:
user: User
Expand Down
13 changes: 7 additions & 6 deletions pod/authentication/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Esup-Pod authentication models test cases."""
from django.test import TestCase
from pod.authentication.models import Owner, AccessGroup
from django.contrib.auth.models import User
Expand All @@ -9,15 +10,15 @@


class OwnerTestCase(TestCase):
"""OwnerTestCase"""
"""Owner Test Case."""

def setUp(self):
"""setUp OwnerTestCase create user pod"""
"""Set up OwnerTestCase create user Pod."""
User.objects.create(username="pod", password="pod1234pod")
# Owner.objects.create(user=user)

def test_creation_owner(self):
"""check if owner exist with username pod and check hashkey"""
"""Check if owner exist with username pod and check hashkey."""
owner = Owner.objects.get(user__username="pod")
user = User.objects.get(username="pod")
self.assertEqual(user.owner, owner)
Expand All @@ -33,16 +34,16 @@ def test_suppression_owner(self):


class AccessGroupTestCase(TestCase):
"""AcessGroupTestCase"""
"""Acess Group Test Case."""

def setUp(self):
"""setUp AcessGroupTestCase create user pod"""
"""Set up AcessGroupTestCase create user Pod."""
User.objects.create(username="pod", password="pod1234pod")

AccessGroup.objects.create(code_name="group1", display_name="Group 1")

def test_creation_accessgroup(self):
"""check if owner exist with username pod and check hashkey"""
"""Check if owner exist with username pod and check hashkey."""
accessgroup = AccessGroup.objects.get(code_name="group1")
self.assertEqual(accessgroup.code_name, "group1")
self.assertEqual(accessgroup.display_name, "Group 1")
Expand Down
8 changes: 4 additions & 4 deletions pod/authentication/tests/test_populated.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""test populated authentication."""
"""Esup-Pod test populated authentication."""

import random
from django.conf import settings
Expand Down Expand Up @@ -108,7 +108,7 @@ class PopulatedCASTestCase(TestCase):
</ns0:serviceResponse>"""

def setUp(self):
"""setUp PopulatedCASTestCase create user pod"""
"""Set up PopulatedCASTestCase create user Pod."""
User.objects.create(username="pod", password="pod1234pod")
AccessGroup.objects.create(code_name="groupTest", display_name="Group de test")
AccessGroup.objects.create(
Expand Down Expand Up @@ -295,7 +295,7 @@ class PopulatedLDAPTestCase(TestCase):
entry = ""

def setUp(self):
"""setUp PopulatedLDAPTestCase create user pod"""
"""Set up PopulatedLDAPTestCase create user Pod."""
User.objects.create(username="pod", password="pod1234pod")
AccessGroup.objects.create(code_name="groupTest", display_name="Group de test")
AccessGroup.objects.create(
Expand Down Expand Up @@ -433,7 +433,7 @@ def test_populate_user_from_entry_unpopulate_group(self):

class PopulatedShibTestCase(TestCase):
def setUp(self):
"""setUp PopulatedShibTestCase create user pod"""
"""Set up PopulatedShibTestCase create user Pod."""
self.hmap = {}
for a in SHIBBOLETH_ATTRIBUTE_MAP:
self.hmap[SHIBBOLETH_ATTRIBUTE_MAP[a][1]] = a
Expand Down
2 changes: 1 addition & 1 deletion pod/authentication/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ def get_owners(search, limit, offset):
"first_name",
"last_name",
)
)[offset : limit + offset]
)[offset: limit + offset]

return JsonResponse(users, safe=False)
5 changes: 4 additions & 1 deletion pod/bbb/management/commands/bbb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""
Esup-Pod BBB command.
This command is used to manage the recordings made by BigBlueButton.
To achieve this, this command performs the following tasks:
Expand Down Expand Up @@ -43,7 +45,8 @@
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.6; cd
/data/www/%userpod%/django_projects/podv3; source
/usr/bin/virtualenvwrapper.sh; workon django_pod; python manage.py bbb
main' """
main'
"""

import os
import traceback
Expand Down
4 changes: 1 addition & 3 deletions pod/completion/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Unit tests for completion views
"""
"""Unit tests for completion views."""

from django.test import TestCase
from django.conf import settings
Expand Down
6 changes: 5 additions & 1 deletion pod/completion/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
"""Esup-Pod completion app utilities."""


def get_video_completion_context(
video,
list_contributor=None,
Expand All @@ -10,7 +13,8 @@ def get_video_completion_context(
form_overlay=None,
):
"""
Returns a dictionary containing information extracted from the video
Return a dictionary containing information extracted from the video.
and its associated objects
(video, list of contributors, list of documents, track and overlay,
as well as forms for creating or updating these objects)
Expand Down
2 changes: 0 additions & 2 deletions pod/completion/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ def video_completion_contributor_modify(request, video):

def video_completion_contributor_delete(request, video):
"""View to delete a video contributor."""

contributor = get_object_or_404(Contributor, id=request.POST["id"])
contributor.delete()
list_contributor = video.contributor_set.all()
Expand Down Expand Up @@ -504,7 +503,6 @@ def video_completion_document_modify(request, video):

def video_completion_document_delete(request, video):
"""View to delete a document associated to a video."""

document = get_object_or_404(Document, id=request.POST["id"])
document.delete()
list_document = video.document_set.all()
Expand Down
2 changes: 1 addition & 1 deletion pod/cut/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def context_settings(request):
"""Return all context settings for cut app"""
"""Return all context settings for cut app."""
new_settings = {}
new_settings["USE_CUT"] = USE_CUT
return new_settings
10 changes: 5 additions & 5 deletions pod/cut/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_bad_time(self):
cut.start = "00:00:12"
cut.end = "00:00:08"
self.assertRaises(ValidationError, cut.clean)
print(" ---> test_bad_time: OK ! --- CutVideoModel")
print(" ---> test_bad_time: OK! --- CutVideoModel")

def test_verify_time__value_error(self):
"""Test verify_time method with bad values."""
Expand All @@ -51,7 +51,7 @@ def test_verify_time__value_error(self):
cut.start = "bad_value"
cut.end = "bad_value"
self.assertFalse(cut.verify_time())
print(" ---> test_verify_time_value_error: OK ! --- CutVideoModel")
print(" ---> test_verify_time_value_error: OK! --- CutVideoModel")

def test_verify_time__good_values(self):
"""Test verify_time method with good values."""
Expand All @@ -62,16 +62,16 @@ def test_verify_time__good_values(self):
cut.start = "00:00:00"
cut.end = "00:00:15"
self.assertTrue(cut.verify_time())
print(" ---> test_verify_time_good_values: OK ! --- CutVideoModel")
print(" ---> test_verify_time_good_values: OK! --- CutVideoModel")

def test_start_in_int(self):
"""Test the start_in_int property."""
cut = CutVideo.objects.get(id=1)
self.assertEqual(cut.start_in_int, 0)
print(" ---> test_start_in_int: OK ! --- CutVideoModel")
print(" ---> test_start_in_int: OK! --- CutVideoModel")

def test_end_in_int(self):
"""Test the end_in_int property."""
cut = CutVideo.objects.get(id=1)
self.assertEqual(cut.end_in_int, 20)
print(" ---> test_end_in_int: OK ! --- CutVideoModel")
print(" ---> test_end_in_int: OK! --- CutVideoModel")
4 changes: 3 additions & 1 deletion pod/cut/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Esup-Pod video cutting app views."""

from django.shortcuts import render
from pod.main.views import in_maintenance
from django.shortcuts import redirect
Expand Down Expand Up @@ -28,7 +30,7 @@
@csrf_protect
@login_required(redirect_field_name="referrer")
def cut_video(request, slug): # noqa: C901
"""View for video cutting"""
"""View for video cutting."""
if in_maintenance():
return redirect(reverse("maintenance"))
video = get_object_or_404(Video, slug=slug, sites=get_current_site(request))
Expand Down
4 changes: 1 addition & 3 deletions pod/enrichment/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# gitguardian:ignore

"""
Unit tests for enrichment views.
"""
"""Esup-Pod unit tests for enrichment views."""
from django.test import TestCase
from django.contrib.auth import authenticate
from django.contrib.auth.models import User
Expand Down
2 changes: 1 addition & 1 deletion pod/import_video/templates/import_video/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
});

/**
* Manage the upload To Pod : confirm and loader
* Manage the upload To Pod: confirm and loader
*/
function confirmUploadToPod(message) {
const answer=confirm(message);
Expand Down
4 changes: 2 additions & 2 deletions pod/import_video/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def test_change_attributs(self):
"""Change attributs values in a recording and save it."""
recording1 = ExternalRecording.objects.get(id=1)
self.assertEqual(recording1.name, "test recording1")
recording1.name = "New test recording1 !"
recording1.name = "New test recording1!"
recording1.save()
newrecording1 = ExternalRecording.objects.get(id=1)
self.assertEqual(newrecording1.name, "New test recording1 !")
self.assertEqual(newrecording1.name, "New test recording1!")

def test_delete_object(self):
"""Delete a recording."""
Expand Down
Loading

0 comments on commit f3c34d9

Please sign in to comment.