Skip to content

Commit c8c2432

Browse files
committed
added basic tests
1 parent 8694ae3 commit c8c2432

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# -*- coding: utf-8 -*-

tests/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# requirements from setup.py
2+
# other requirements
3+
djangocms-helper>=0.9.2,<0.10
4+
tox
5+
coverage

tests/settings.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
HELPER_SETTINGS = {
5+
'INSTALLED_APPS': [
6+
'easy_thumbnails',
7+
'filer',
8+
'mptt',
9+
],
10+
'ALLOWED_HOSTS': ['localhost'],
11+
'CMS_LANGUAGES': {
12+
1: [{
13+
'code': 'en',
14+
'name': 'English',
15+
}]
16+
},
17+
'LANGUAGE_CODE': 'en',
18+
}
19+
20+
def run():
21+
from djangocms_helper import runner
22+
runner.cms('djangocms_file')
23+
24+
if __name__ == '__main__':
25+
run()

tests/tests_models.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- coding: utf-8 -*-
2+
from django.test import TestCase
3+
4+
from filer.models import File as FilerFile
5+
from filer.models import Folder as FilerFolder
6+
7+
from djangocms_file.models import File
8+
9+
10+
class FileTestCase(TestCase):
11+
12+
def setUp(self):
13+
filer_file = FilerFile.objects.create(
14+
file='test.jpg',
15+
)
16+
File.objects.create(
17+
file_src=filer_file,
18+
file_name='test',
19+
)
20+
21+
def test_file_instance(self):
22+
"""File instance has been created"""
23+
test_file = File.objects.get(file_name='test')
24+
self.assertEqual(test_file.file_name, 'test')
25+
26+
27+
class FolderTestCase(TestCase):
28+
29+
def setUp(self):
30+
FilerFolder.objects.create(
31+
name='test',
32+
)
33+
34+
def test_folder_instance(self):
35+
"""Folder instance has been created"""
36+
test_folder = FilerFolder.objects.get(name='test')
37+
self.assertEqual(test_folder.name, 'test')

0 commit comments

Comments
 (0)