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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
from django.test import TestCase
from .models import (
Profile, User, Workshop, WorkshopType,
RequestedWorkshop, BookedWorkshop, ProposeWorkshopDate
)
from datetime import datetime
# Setup for Model Test
def setUpModule():
'''
demo user as coordinator and test user as instructor
'''
demoUser1 = User.objects.create(username='demouser1',
email='doke.akshen@gmail.com', password='pass@123')
demoUser2 = User.objects.create(username='demouser2',
email='doke.akshen@gmail.com', password='pass@123')
testUser1 = User.objects.create(username='testuser1',
email='doke.akshen@gmail.com',password='pass@123')
testUser2 = User.objects.create(username='testuser2',
email='doke.akshen@gmail.com', password='pass@123')
ip = Profile.objects.create(user=testUser2, position='instructor',
department='cs', institute='ace', phone_number='9930011492',
is_email_verified=1)
cp = Profile.objects.create(user=demoUser2, position='coordinator',
department='IT', institute='iit', phone_number='9930011492',
is_email_verified=1)
wt1 = WorkshopType.objects.create(workshoptype_name='ISCP',
workshoptype_description='Introduction to Scientific Computing in\
Python <br> > Numpy <br> > Matplotlib <br> > iPython <br>',
workshoptype_duration='1day, 8hours a day')
rw = RequestedWorkshop.objects.create(
requested_workshop_instructor=testUser2,
requested_workshop_coordinator=demoUser2,
requested_workshop_title=wt1,
requested_workshop_date='2017-07-24'
)
pw = ProposeWorkshopDate.objects.create(
proposed_workshop_coordinator=demoUser2,
proposed_workshop_instructor=testUser2,
proposed_workshop_title=wt1,
proposed_workshop_date='2017-07-06',
conditionone=1,
conditiontwo=1,
conditionthree=1
)
def tearDownModule():
User.objects.all().delete()
Profile.objects.all().delete()
ProposeWorkshopDate.objects.all().delete()
RequestedWorkshop.objects.all().delete()
WorkshopType.objects.all().delete()
class ProfileModelTest(TestCase):
'''
This class tests the Profile Model
'''
def setUp(self):
'''
ip is for instructor profile and cp is for coordinator profile
'''
self.testuser1 = User.objects.get(username='testuser1')
self.demouser1 = User.objects.get(username='demouser1')
self.ip1 = Profile.objects.create(user=self.testuser1, position='instructor',
department='cs', institute='ace', phone_number='9930011492',
is_email_verified=1)
self.cp1 = Profile.objects.create(user=self.demouser1, position='coordinator',
department='IT', institute='iit', phone_number='9930011492',
is_email_verified=1)
def test_profile_model(self):
self.assertEqual(self.demouser1.email,'doke.akshen@gmail.com')
self.assertEqual(self.testuser1.email,'doke.akshen@gmail.com')
self.assertEqual(self.ip1.position,'instructor')
self.assertEqual(self.cp1.position,'coordinator')
class WorkshopTypeModelTest(TestCase):
'''
This class tests the WorkshopType Model
'''
def setUp(self):
self.wt1 = WorkshopType.objects.create(workshoptype_name='ISCP',
workshoptype_description='Introduction to Scientific Computing in\
Python <br> > Numpy <br> > Matplotlib <br> > iPython <br>',
workshoptype_duration='1day, 8hours a day')
self.wt2 = WorkshopType.objects.create(workshoptype_name='Basic Python',
workshoptype_description='Basic Python <br> > DataTypes <br> \
> Conditions <br> > Loops <br> > Functions'
,workshoptype_duration='3days, 8hours a day')
def test_workshoptype_model(self):
self.assertEqual(self.wt2.workshoptype_duration,'3days, 8hours a day')
self.assertEqual(self.wt1.workshoptype_name, 'ISCP')
class WorkshopTest(TestCase):
'''
This class tests the Workshop Model
'''
def setUp(self):
'''
w is workshop object
'''
self.testuser2 = User.objects.get(username='testuser2')
self.ip = Profile.objects.get(user=self.testuser2)
self.wt = WorkshopType.objects.get(workshoptype_name='ISCP')
self.w = Workshop.objects.create(workshop_instructor=self.testuser2,
workshop_title=self.wt,
recurrences='RRULE:FREQ=WEEKLY;UNTIL=20170524T183000Z;BYDAY=WE')
def test_workshop_model(self):
self.assertEqual(self.w.workshop_title.workshoptype_name,'ISCP' )
class RequestedWorkshopTest(TestCase):
'''
This class tests the RequestedWorkshop Model
'''
def setUp(self):
self.testuser2 = User.objects.get(username='testuser2')
self.demouser2 = User.objects.get(username='demouser2')
self.wt = WorkshopType.objects.get(workshoptype_name='ISCP')
self.rw = RequestedWorkshop.objects.create(
requested_workshop_instructor=self.testuser2,
requested_workshop_coordinator=self.demouser2,
requested_workshop_title=self.wt,
requested_workshop_date='2017-05-24'
)
def test_requestedworkshop_model(self):
self.assertEqual(self.rw.requested_workshop_date, '2017-05-24')
self.assertEqual(self.rw.status, 'Pending')
class ProposedWorkshopDateTest(TestCase):
'''
This class tests the ProposeWorkshopDate Model
'''
def setUp(self):
self.testuser2 = User.objects.get(username='testuser2')
self.demouser2 = User.objects.get(username='demouser2')
self.wt = WorkshopType.objects.get(workshoptype_name='ISCP')
self.pw = ProposeWorkshopDate.objects.create(
proposed_workshop_coordinator=self.demouser2,
proposed_workshop_instructor=self.testuser2,
proposed_workshop_title=self.wt,
proposed_workshop_date='2017-06-06',
conditionone=1,
conditiontwo=1,
conditionthree=1
)
def test_proposedworkshopdate_model(self):
self.assertEqual(self.pw.proposed_workshop_title.workshoptype_name,'ISCP')
self.assertEqual(self.pw.conditionthree, 1)
self.assertEqual(self.pw.status, 'Pending')
class BookedWorkshopTest(TestCase):
'''
This class tests the BookedWorkshop Model
'''
def setUp(self):
self.rw = RequestedWorkshop.objects.get(requested_workshop_date='2017-07-24')
self.pw = ProposeWorkshopDate.objects.get(proposed_workshop_date='2017-07-06')
self.bwr = BookedWorkshop.objects.create(booked_workshop_requested=self.rw)
self.bwp = BookedWorkshop.objects.create(booked_workshop_proposed=self.pw)
def test_bookedworkshop_model(self):
self.assertEqual(self.bwp.booked_workshop_proposed.conditionone,1)
self.assertEqual(self.bwr.booked_workshop_requested.requested_workshop_title.workshoptype_name,'ISCP' )
|