diff options
author | Akshen | 2017-05-31 15:41:11 +0530 |
---|---|---|
committer | Akshen | 2017-05-31 15:41:11 +0530 |
commit | 6237cbbfcb692a7003242f6e286be5cff3836194 (patch) | |
tree | 8c0fa6292816db54f4cfe3ea0a7c3ced8aad1af2 /workshop_app | |
parent | d620143f02cf007a90a08757d066bb853597d841 (diff) | |
download | workshop_booking-6237cbbfcb692a7003242f6e286be5cff3836194.tar.gz workshop_booking-6237cbbfcb692a7003242f6e286be5cff3836194.tar.bz2 workshop_booking-6237cbbfcb692a7003242f6e286be5cff3836194.zip |
Changes Tests Variables
- varible naming changed
- testing recurrances
Diffstat (limited to 'workshop_app')
-rw-r--r-- | workshop_app/models.py | 7 | ||||
-rw-r--r-- | workshop_app/test_models.py | 119 | ||||
-rw-r--r-- | workshop_app/test_views.py | 70 |
3 files changed, 83 insertions, 113 deletions
diff --git a/workshop_app/models.py b/workshop_app/models.py index 8eae29e..422eee7 100644 --- a/workshop_app/models.py +++ b/workshop_app/models.py @@ -23,11 +23,12 @@ class Profile(models.Model): phone_number = models.CharField( max_length=15, validators=[RegexValidator( - regex=r'^\+?1?\d{9,15}$', message=( + regex=r'^.{9}$', message=( "Phone number must be entered \ - in the format: '+929490956'.\ + in the format: '+99999999'.\ Up to 15 digits allowed.") - )]) + )] + ,null=False) position = models.CharField(max_length=32, choices=position_choices) is_email_verified = models.BooleanField(default=False) activation_key = models.CharField(max_length=255, blank=True, null=True) diff --git a/workshop_app/test_models.py b/workshop_app/test_models.py index 531ae4c..c9ac41c 100644 --- a/workshop_app/test_models.py +++ b/workshop_app/test_models.py @@ -1,51 +1,52 @@ from django.test import TestCase from .models import ( - Profile, User, Workshop, WorkshopType, - RequestedWorkshop, BookedWorkshop, ProposeWorkshopDate + Profile, User, Workshop, WorkshopType, + RequestedWorkshop, BookedWorkshop, ProposeWorkshopDate ) from datetime import datetime # Setup for Model Test def setUpModule(): ''' + Sets up database demo user as coordinator and test user as instructor ''' demoUser1 = User.objects.create(username='demouser1', - email='doke.akshen@gmail.com', password='pass@123') + email='test.user@gmail.com', password='pass@123') demoUser2 = User.objects.create(username='demouser2', - email='doke.akshen@gmail.com', password='pass@123') + email='test.user@gmail.com', password='pass@123') testUser1 = User.objects.create(username='testuser1', - email='doke.akshen@gmail.com',password='pass@123') + email='test.user@gmail.com',password='pass@123') testUser2 = User.objects.create(username='testuser2', - email='doke.akshen@gmail.com', password='pass@123') + email='test.user@gmail.com', password='pass@123') - ip = Profile.objects.create(user=testUser2, position='instructor', - department='cs', institute='ace', phone_number='9930011492', + instructor_profile = Profile.objects.create(user=testUser2, position='instructor', + department='cs', institute='ace', phone_number='1122334456', is_email_verified=1) - cp = Profile.objects.create(user=demoUser2, position='coordinator', - department='IT', institute='iit', phone_number='9930011492', + coordinator_profile = Profile.objects.create(user=demoUser2, position='coordinator', + department='IT', institute='iit', phone_number='1122334456', is_email_verified=1) - wt1 = WorkshopType.objects.create(workshoptype_name='ISCP', + workshoptype1 = 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 = RequestedWorkshop.objects.create( requested_workshop_instructor=testUser2, requested_workshop_coordinator=demoUser2, - requested_workshop_title=wt1, + requested_workshop_title=workshoptype1, requested_workshop_date='2017-07-24' ) - pw = ProposeWorkshopDate.objects.create( + propose_workshop = ProposeWorkshopDate.objects.create( proposed_workshop_coordinator=demoUser2, proposed_workshop_instructor=testUser2, - proposed_workshop_title=wt1, + proposed_workshop_title=workshoptype1, proposed_workshop_date='2017-07-06', condition_one=1, condition_two=1, @@ -66,26 +67,24 @@ class ProfileModelTest(TestCase): ''' def setUp(self): ''' - ip is for instructor profile and cp is for coordinator profile + setsup profile for instructor and coordinator ''' 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', + self.instructor_profile1 = Profile.objects.create(user=self.testuser1, position='instructor', + department='cs', institute='ace', phone_number='1123323344558899192', is_email_verified=1) - self.cp1 = Profile.objects.create(user=self.demouser1, position='coordinator', - department='IT', institute='iit', phone_number='9930011492', + self.coordinator_profile1 = Profile.objects.create(user=self.demouser1, position='coordinator', + department='IT', institute='iit', phone_number='112233', 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') + self.assertEqual(self.demouser1.email,'test.user@gmail.com') + self.assertEqual(self.testuser1.email,'test.user@gmail.com') + self.assertEqual(self.instructor_profile1.position,'instructor') + self.assertEqual(self.coordinator_profile1.position,'coordinator') class WorkshopTypeModelTest(TestCase): @@ -94,41 +93,40 @@ class WorkshopTypeModelTest(TestCase): ''' def setUp(self): - self.wt1 = WorkshopType.objects.create(workshoptype_name='ISCP', + self.workshoptype1 = 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', + self.workshoptype2 = 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') + self.assertEqual(self.workshoptype2.workshoptype_duration,'3days, 8hours a day') + self.assertEqual(self.workshoptype1.workshoptype_name, 'ISCP') -class WorkshopTest(TestCase): +class WorkshopModelTest(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') - + self.instructor_profile = Profile.objects.get(user=self.testuser2) + self.workshoptype = WorkshopType.objects.get(workshoptype_name='ISCP') + self.workshop = Workshop.objects.create(workshop_instructor=self.testuser2, + workshop_title=self.workshoptype, + recurrences='RRULE:FREQ=WEEKLY;UNTIL=20170629T183000Z;BYDAY=TH') + def test_workshop_model(self): - self.assertEqual(self.w.workshop_title.workshoptype_name,'ISCP' ) + self.assertEqual(self.workshop.workshop_title.workshoptype_name,'ISCP' ) + self.assertEqual(self.workshop.recurrences.rrules[0].__dict__['freq'],2) + -class RequestedWorkshopTest(TestCase): +class RequestedWorkshopModelTest(TestCase): ''' This class tests the RequestedWorkshop Model ''' @@ -136,20 +134,20 @@ class RequestedWorkshopTest(TestCase): 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( + self.workshoptype = WorkshopType.objects.get(workshoptype_name='ISCP') + self.requestedworkshop = RequestedWorkshop.objects.create( requested_workshop_instructor=self.testuser2, requested_workshop_coordinator=self.demouser2, - requested_workshop_title=self.wt, + requested_workshop_title=self.workshoptype, 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') + self.assertEqual(self.requestedworkshop.requested_workshop_date, '2017-05-24') + self.assertEqual(self.requestedworkshop.status, 'Pending') -class ProposedWorkshopDateTest(TestCase): +class ProposedWorkshopDateModelTest(TestCase): ''' This class tests the ProposeWorkshopDate Model ''' @@ -157,11 +155,11 @@ class ProposedWorkshopDateTest(TestCase): 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( + self.workshoptype = WorkshopType.objects.get(workshoptype_name='ISCP') + self.propose_workshop = ProposeWorkshopDate.objects.create( proposed_workshop_coordinator=self.demouser2, proposed_workshop_instructor=self.testuser2, - proposed_workshop_title=self.wt, + proposed_workshop_title=self.workshoptype, proposed_workshop_date='2017-06-06', condition_one=1, condition_two=1, @@ -169,22 +167,23 @@ class ProposedWorkshopDateTest(TestCase): ) def test_proposedworkshopdate_model(self): - self.assertEqual(self.pw.proposed_workshop_title.workshoptype_name,'ISCP') - self.assertEqual(self.pw.condition_three, 1) - self.assertEqual(self.pw.status, 'Pending') + self.assertEqual(self.propose_workshop.proposed_workshop_title.workshoptype_name,'ISCP') + self.assertEqual(self.propose_workshop.condition_three, 1) + self.assertEqual(self.propose_workshop.status, 'Pending') -class BookedWorkshopTest(TestCase): +class BookedWorkshopModelTest(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) + self.requestedworkshop = RequestedWorkshop.objects.get(requested_workshop_date='2017-07-24') + self.propose_workshop = ProposeWorkshopDate.objects.get(proposed_workshop_date='2017-07-06') + self.bwr = BookedWorkshop.objects.create(booked_workshop_requested=self.requestedworkshop) + self.bwp = BookedWorkshop.objects.create(booked_workshop_proposed=self.propose_workshop) def test_bookedworkshop_model(self): self.assertEqual(self.bwp.booked_workshop_proposed.condition_one,1) - self.assertEqual(self.bwr.booked_workshop_requested.requested_workshop_title.workshoptype_name,'ISCP' ) + self.assertEqual(self.bwr.booked_workshop_requested.requested_workshop_title.workshoptype_name, + 'ISCP' ) diff --git a/workshop_app/test_views.py b/workshop_app/test_views.py index 9627820..ea34f89 100644 --- a/workshop_app/test_views.py +++ b/workshop_app/test_views.py @@ -19,11 +19,11 @@ class TestProfile(TestCase): self.user1 = User.objects.create( username='demo_test_user1', password='pass@123', - email='doke.akshen@gmail.com') + email='test.user@gmail.com') self.user2 = User.objects.create( username='demo_test_user2', - email='doke.akshen@gmail.com') + email='test.user@gmail.com') self.user2.set_password('pass@123') self.user2.save() @@ -33,7 +33,7 @@ class TestProfile(TestCase): department='cs', institute='ace', position='instructor', - phone_number='9930011492', + phone_number='1122993388', is_email_verified=1 ) @@ -99,13 +99,13 @@ class TestWorkshopCreation(TestCase): self.superuser = User.objects.create_superuser( username='admin', password='pass@123', - email='doke.akshen@gmail.com') + email='test.user@gmail.com') self.mod_group = Group.objects.create(name='instructor') self.user_one = User.objects.create( username='test_user1', - email='doke.akshen@gmail.com') + email='test.user@gmail.com') self.user_one.set_password('pass@123') self.user_one.save() @@ -115,7 +115,7 @@ class TestWorkshopCreation(TestCase): department='cs', institute='IIT', position='instructor', - phone_number='9930011492', + phone_number='1122993388', is_email_verified=1 ) @@ -128,7 +128,7 @@ class TestWorkshopCreation(TestCase): self.user_two = User.objects.create( username='demo_user2', - email='doke.akshen@gmail.com') + email='test.user@gmail.com') self.user_two.set_password('pass@123') self.user_two.save() @@ -138,7 +138,7 @@ class TestWorkshopCreation(TestCase): department='cs', institute='ace', position='coordinator', - phone_number='9930011492', + phone_number='1122993388', is_email_verified=1 ) @@ -188,19 +188,16 @@ class TestWorkshopCreation(TestCase): class TestWorkshopDashboard(TestCase): def setUp(self): - ''' - demo user as coordinator and test user as instructor - ''' self.superuser = User.objects.create_superuser( username='admin', password='pass@123', - email='doke.akshen@gmail.com') + email='test.user@gmail.com') self.mod_group = Group.objects.create(name='instructor') self.user_one = User.objects.create( username='test_user1', - email='doke.akshen@gmail.com') + email='test.user@gmail.com') self.user_one.set_password('pass@123') self.user_one.save() @@ -210,20 +207,20 @@ class TestWorkshopDashboard(TestCase): department='cs', institute='IIT', position='instructor', - phone_number='9930011492', + phone_number='1122993388', is_email_verified=1 ) #Add user_one in instructor group and give required permissions self.mod_group.user_set.add(self.user_one) - self.per = (Permission.objects.all()) - self.user_one.user_permissions.add(self.per[44]) - self.user_one.user_permissions.add(self.per[43]) - self.user_one.user_permissions.add(self.per[42]) + self.permissions = Permission.objects.all() + self.user_one.user_permissions.add(self.permissions[44]) + self.user_one.user_permissions.add(self.permissions[43]) + self.user_one.user_permissions.add(self.permissions[42]) self.user_two = User.objects.create( username='demo_user2', - email='doke.akshen@gmail.com') + email='test.user@gmail.com') self.user_two.set_password('pass@123') self.user_two.save() @@ -233,7 +230,7 @@ class TestWorkshopDashboard(TestCase): department='cs', institute='ace', position='coordinator', - phone_number='9930011492', + phone_number='1122993388', is_email_verified=1 ) @@ -242,34 +239,7 @@ class TestWorkshopDashboard(TestCase): self.workshop = Workshop.objects.create(workshop_instructor=self.user_one, workshop_title=self.workshoptype, - recurrences='RRULE:FREQ=WEEKLY;UNTIL=20170624T183000Z;BYDAY=WE;') + recurrences='RRULE:FREQ=WEEKLY;UNTIL=20170624T183000Z;BYDAY=WE;' + ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
\ No newline at end of file |