Browse Source

Add basic tests

master
Jake Howard 5 years ago
parent
commit
570ffa2c48
Signed by: theorangeone GPG Key ID: 57AFB45680EDD477
  1. 22
      project/files/tests.py
  2. 1
      requirements.txt

22
project/files/tests.py

@ -1,3 +1,23 @@
from django.test import TestCase
from model_mommy import mommy
from .models import SharedFile
from django.core.files.uploadedfile import SimpleUploadedFile
# Create your tests here.
class SharedFileTestCase(TestCase):
def setUp(self):
asset = SimpleUploadedFile(
name='902598_test_file.txt',
content='',
content_type='text/plain'
)
self.file = mommy.make(SharedFile, file=asset)
def test_str(self):
self.assertEqual(str(self.file), self.file.get_original_filename())
def test_get_original_filename(self):
self.assertIn('test_file', self.file.get_original_filename())
def test_absolute_url(self):
self.assertEqual(self.file.get_absolute_url(), '/files/{0}/'.format(self.file.short_id))

1
requirements.txt

@ -6,6 +6,7 @@ django-material==0.8.0
django-shortuuidfield==0.1.3
django==1.8.13
flake8==2.5.4
model-mommy==1.3.0
opbeat==3.3.4
psycopg2==2.6.1
waitress==0.9.0

Loading…
Cancel
Save