add audio/tests/test_licensechoices.py

This commit is contained in:
Trent Palmer 2021-04-05 14:25:29 -07:00
parent fa30e89b0e
commit 620140336c
4 changed files with 35 additions and 3 deletions

1
.gitignore vendored
View File

@ -4,4 +4,5 @@ accounts/__pycache__
accounts/migrations/__pycache__ accounts/migrations/__pycache__
audio/__pycache__ audio/__pycache__
audio/migrations/__pycache__ audio/migrations/__pycache__
audio/tests/__pycache__
tp/__pycache__ tp/__pycache__

View File

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

0
audio/tests/__init__.py Normal file
View File

View File

@ -0,0 +1,34 @@
from django.test import TestCase
from audio.choices import LICENSE_CHOICES, get_license_info
TEST_LICENSE_CHOICES = (
(1, 'Public Domain'),
(2, 'Unknown'),
(3, 'CC BY-SA 2.5'),
(4, 'CC BY-SA 3.0'),
(5, 'CC BY 3.0'),
(6, 'CC BY 1.0'),
(7, 'CC0 1.0')
)
TEST_LICENSE_INFO = (
('Public Domain', 'https://en.wikipedia.org/wiki/Public_domain'),
('Unknown', 'https://example.com'),
('CC BY-SA 2.5', 'https://creativecommons.org/licenses/by-sa/2.5'),
('CC BY-SA 3.0', 'https://creativecommons.org/licenses/by-sa/3.0'),
('CC BY 3.0', 'https://creativecommons.org/licenses/by/3.0'),
('CC BY 1.0', 'https://creativecommons.org/licenses/by/1.0'),
('CC0 1.0', 'https://creativecommons.org/publicdomain/zero/1.0')
)
class LicenseChoicesTestCase(TestCase):
def test_license_choices(self):
self.assertEqual(len(LICENSE_CHOICES), 7)
for i, x in enumerate(TEST_LICENSE_CHOICES):
self.assertEqual(TEST_LICENSE_CHOICES[i], LICENSE_CHOICES[i])
def test_license_info(self):
for i in range(len(LICENSE_CHOICES)):
self.assertEqual(get_license_info(i + 1), TEST_LICENSE_INFO[i])