Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/pod_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ jobs:
Pod-Dev:
runs-on: ubuntu-latest

env:
DATABASE_HOST: localhost
DATABASE_PORT: '3306'
DATABASE_NAME: pod
DATABASE_USER: root
DATABASE_PASSWORD: root

steps:

- name: Free Disk Space (Ubuntu)
Expand All @@ -53,6 +60,11 @@ jobs:
with:
node-version: ${{env.NODE_VERSION}}

- name: Start MySQL Server
run: |
sudo systemctl start mysql.service
mysql -u root -proot -e "CREATE DATABASE pod CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"

- name: Configure sysctl limits (for ES)
run: |
sudo swapoff -a
Expand All @@ -79,6 +91,8 @@ jobs:
sudo rm -rf /var/lib/apt/lists/*
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
# ensure mysqlclient is available
pip install mysqlclient
sudo npm install -g yarn

# FLAKE 8 (see setup.cfg for configurations)
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/pod_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ on:
jobs:
Pod-Main:
runs-on: ubuntu-latest

env:
DATABASE_HOST: localhost
DATABASE_PORT: '3306'
DATABASE_NAME: pod
DATABASE_USER: root
DATABASE_PASSWORD: root

strategy:
max-parallel: 2
matrix:
Expand Down Expand Up @@ -51,8 +59,15 @@ jobs:
sudo rm -rf /var/lib/apt/lists/*
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
# ensure mysqlclient is available
pip install mysqlclient
sudo npm install -g yarn

- name: Start MySQL Server
run: |
sudo systemctl start mysql.service
mysql -u root -proot -e "CREATE DATABASE pod CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"

## Start unit tests ##
- name: Run Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
Expand Down
20 changes: 20 additions & 0 deletions pod/custom/settings_local_docker_full_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

DEBUG = True

TEST_REMOTE_ENCODE = True
Expand All @@ -23,6 +25,24 @@
}
}

# Override DATABASES when CI provides DATABASE_HOST (MariaDB)
if os.environ.get("DATABASE_HOST"):
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": os.environ.get("DATABASE_NAME", "pod"),
"USER": os.environ.get("DATABASE_USER", "root"),
"PASSWORD": os.environ.get("DATABASE_PASSWORD", ""),
"HOST": os.environ.get("DATABASE_HOST", "127.0.0.1"),
"PORT": os.environ.get("DATABASE_PORT", "3306"),
# option to avoid timezone warnings and ensure strict mode
"OPTIONS": {
"init_command": "SET sql_mode='STRICT_TRANS_TABLES'",
"charset": "utf8mb4",
},
}
}

USE_CUT = True
USE_PODFILE = True
USE_NOTIFICATIONS = False
Expand Down
24 changes: 18 additions & 6 deletions pod/duplicate/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
"""Unit tests for Duplicate views."""
"""
Unit tests for Duplicate views.

* run with 'python manage.py test pod.duplicate.tests.test_views --settings=pod.main.test_settings'
"""

import unittest
from datetime import datetime
from django.test import TestCase
from django.urls import reverse
from django.conf import settings
from django.contrib.auth.models import User
from pod.video.models import Video, Type

Expand All @@ -10,7 +17,12 @@
PWD = "azerty1234" # nosec
# ggignore-end

USE_DUPLICATE = getattr(settings, "USE_DUPLICATE", False)


@unittest.skipUnless(
USE_DUPLICATE, "Set USE_DUPLICATE to True before testing Video Duplication."
)
class VideoDuplicateViewTest(TestCase):
"""Test case for duplicating videos."""

Expand All @@ -33,7 +45,7 @@ def setUp(self) -> None:
description="Original description",
description_fr="Description originale",
description_en="Original description",
date_evt="2023-01-01",
date_evt=datetime(2023, 1, 1),
main_lang="en",
licence="CC BY-SA",
is_draft=False,
Expand Down Expand Up @@ -62,10 +74,10 @@ def test_video_duplicate(self) -> None:
self.assertEqual(duplicated_video.main_lang, "en")
self.assertEqual(duplicated_video.licence, "CC BY-SA")
self.assertTrue(duplicated_video.is_draft)
self.assertEqual(duplicated_video.is_restricted, False)
self.assertEqual(duplicated_video.allow_downloading, True)
self.assertEqual(duplicated_video.is_360, False)
self.assertEqual(duplicated_video.disable_comment, False)
self.assertFalse(duplicated_video.is_restricted)
self.assertTrue(duplicated_video.allow_downloading)
self.assertFalse(duplicated_video.is_360)
self.assertFalse(duplicated_video.disable_comment)

# Check the response status code
self.assertEqual(
Expand Down
28 changes: 14 additions & 14 deletions pod/enrichment/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class EnrichmentGroupModelTestCase(TestCase):
"initial_data.json",
]

def setUp(self):
def setUp(self) -> None:
owner = User.objects.create(username="test")
videotype = Type.objects.create(title="others")
Video.objects.create(
Expand All @@ -45,7 +45,7 @@ def setUp(self):
Group.objects.create(name="group1")
Group.objects.create(name="group2")

def test_create_enrichmentGroup(self):
def test_create_enrichmentGroup(self) -> None:
video = Video.objects.get(id=1)
self.assertTrue(not hasattr(video, "enrichmentgroup"))
EnrichmentGroup.objects.create(video=video)
Expand All @@ -54,7 +54,7 @@ def test_create_enrichmentGroup(self):
EnrichmentGroup.objects.create(video=video)
print(" ---> test_create_enrichmentGroup: OK! --- EnrichmentGroupModel")

def test_modify_enrichmentGroup(self):
def test_modify_enrichmentGroup(self) -> None:
video = Video.objects.get(id=1)
eng = EnrichmentGroup.objects.create(video=video)
self.assertEqual(video.enrichmentgroup.groups.all().count(), 0)
Expand All @@ -70,7 +70,7 @@ def test_modify_enrichmentGroup(self):
self.assertEqual(video.enrichmentgroup.groups.all().count(), 1)
print(" ---> test_modify_enrichmentGroup: OK! --- EnrichmentGroupModel")

def test_delete_enrichmentGroup(self):
def test_delete_enrichmentGroup(self) -> None:
video = Video.objects.get(id=1)
eng = EnrichmentGroup.objects.create(video=video)
eng.groups.add(Group.objects.get(id=1))
Expand All @@ -92,7 +92,7 @@ class EnrichmentModelTestCase(TestCase):
"initial_data.json",
]

def setUp(self):
def setUp(self) -> None:
"""Set up for Enrichment model tests."""
owner = User.objects.create(username="test")
video_type = Type.objects.create(title="others")
Expand Down Expand Up @@ -139,7 +139,7 @@ def setUp(self):
weblink="http://test.com",
)

def test_attributs_full(self):
def test_attributs_full(self) -> None:
"""Test the attributs of the Enrichment model."""
enrichment = Enrichment.objects.get(id=1)
video = Video.objects.get(id=1)
Expand All @@ -152,7 +152,7 @@ def test_attributs_full(self):
self.assertTrue("testimage" in enrichment.image.name)
print(" ---> test_attributs_full: OK! --- EnrichmentModel")

def test_attributs(self):
def test_attributs(self) -> None:
"""Test the attributs of the Enrichment model."""
enrichment = Enrichment.objects.get(id=2)
video = Video.objects.get(id=1)
Expand All @@ -167,7 +167,7 @@ def test_attributs(self):
print(" [ BEGIN ENRICHMENT_TEST MODEL ] ")
print(" ---> test_attributs: OK! --- EnrichmentModel")

def test_type(self):
def test_type(self) -> None:
"""Test the type of the Enrichment model."""
video = Video.objects.get(id=1)
enrichment = Enrichment()
Expand All @@ -179,7 +179,7 @@ def test_type(self):
print(" ---> test_type: OK! --- EnrichmentModel")
print(" [ END ENRICHMENT_TEST MODEL ] ")

def test_bad_attributs(self):
def test_bad_attributs(self) -> None:
"""Test the bad attributs of the Enrichment model."""
video = Video.objects.get(id=1)
enrichment = Enrichment()
Expand All @@ -199,7 +199,7 @@ def test_bad_attributs(self):

print(" ---> test_bad_attributs: OK! --- EnrichmentModel")

def test_overlap(self):
def test_overlap(self) -> None:
"""Test overlap."""
video = Video.objects.get(id=1)
enrichment = Enrichment()
Expand All @@ -211,7 +211,7 @@ def test_overlap(self):
self.assertRaises(ValidationError, enrichment.clean)
print(" ---> test_overlap: OK! --- EnrichmentModel")

def test_delete(self):
def test_delete(self) -> None:
"""Test the delete method of the Enrichment model."""
video = Video.objects.get(id=1)
list_enrichment = video.enrichment_set.all()
Expand All @@ -223,7 +223,7 @@ def test_delete(self):
self.assertEqual(EnrichmentVtt.objects.filter(video=video).count(), 0)
print(" ---> test_delete: OK! --- EnrichmentModel")

def test_sites_property__not_empty(self):
def test_sites_property__not_empty(self) -> None:
"""Test the sites property of the Enrichment model when the video has site."""
video = Video.objects.get(id=1)
video.sites.add(Site.objects.get(pk=1))
Expand All @@ -232,7 +232,7 @@ def test_sites_property__not_empty(self):
self.assertEqual(enrichment.sites, video.sites)
print(" ---> test_sites_property__not_empty: OK! --- EnrichmentModel")

def test_sites_property__empty(self):
def test_sites_property__empty(self) -> None:
"""Test the sites property of the Enrichment model when the video has no site."""
video = Video.objects.get(id=1)
video.sites.clear()
Expand All @@ -242,7 +242,7 @@ def test_sites_property__empty(self):
self.assertEqual(video.sites.count(), 0)
print(" ---> test_sites_property__empty: OK! --- EnrichmentModel")

def test_str(self):
def test_str(self) -> None:
"""Test the str method of the Enrichment model."""
enrichment = Enrichment.objects.get(id=1)
self.assertEqual(
Expand Down
18 changes: 18 additions & 0 deletions pod/main/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@
}
}

# Override DATABASES when CI provides DATABASE_HOST (MariaDB)
if os.environ.get("DATABASE_HOST"):
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": os.environ.get("DATABASE_NAME", "pod"),
"USER": os.environ.get("DATABASE_USER", "root"),
"PASSWORD": os.environ.get("DATABASE_PASSWORD", ""),
"HOST": os.environ.get("DATABASE_HOST", "127.0.0.1"),
"PORT": os.environ.get("DATABASE_PORT", "3306"),
# option to avoid timezone warnings and ensure strict mode
"OPTIONS": {
"init_command": "SET sql_mode='STRICT_TRANS_TABLES'",
"charset": "utf8mb4",
},
}
}

LANGUAGES = (("fr", "Français"), ("en", "English"))
LANGUAGE_CODE = "en"
THIRD_PARTY_APPS = ["enrichment", "live"]
Expand Down
Loading
Loading