/
test_models.py
67 lines (53 loc) · 2.02 KB
/
test_models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import os
from django.test import TestCase
from django.core.files.uploadedfile import SimpleUploadedFile
from web.models import Contact, Team
class ContactTestCase(TestCase):
def setUp(self):
super(ContactTestCase, self).setUp()
try:
os.makedirs('/tmp/cloudcv')
except OSError:
pass
with self.settings(MEDIA_ROOT='/tmp/cloudcv'):
self.contact = Contact.objects.create(
name='user',
email='user@domain.com',
message='test message',
image=SimpleUploadedFile(
name='test_screnshot.jpg',
content=open('frontend/src/images/cloudcv_logo.png', 'rb').read(),
content_type='image/png'
)
)
def test__unicode__(self):
name = self.contact.name
email = self.contact.email
message = self.contact.message
final_string = '{0}: {1}: {2}'.format(name, email, message)
self.assertEqual(final_string, self.contact.__str__())
class TeamTestCase(TestCase):
def setUp(self):
super(TeamTestCase, self).setUp()
try:
os.makedirs('/tmp/cloudcv')
except OSError:
pass
with self.settings(MEDIA_ROOT='/tmp/cloudcv'):
self.team = Team.objects.create(
name='user',
email='test@user.com',
description='Description for Test User',
image=SimpleUploadedFile(
name='test_image.jpg',
content=open('frontend/src/images/cloudcv_logo.png', 'rb').read(),
content_type='image/png'
),
github_url='www.github.com/Cloud-CV',
linkedin_url='www.linkedin.com/testuser',
personal_website='CloudCV.org',
team_type=Team.TEAM,
visible=True,
)
def test__unicode__(self):
self.assertEqual(self.team.name, self.team.__str__())