-
Notifications
You must be signed in to change notification settings - Fork 56
[WIP] Added test case for Chat sessstion View, Contest Form #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,10 @@ | |
| from django.contrib.auth.models import User | ||
| from django.test import SimpleTestCase, TestCase | ||
| from django.urls import reverse | ||
| from main.models import Contest, chatSession | ||
| import datetime | ||
| from django.utils import timezone | ||
| from django.test import Client | ||
|
|
||
|
|
||
| class HomeViewTests(TestCase): | ||
|
|
@@ -18,3 +22,79 @@ class RequestSessionViewTests(SimpleTestCase): | |
| def test_get_request(self): | ||
| response = self.client.get(reverse('request_session')) | ||
| self.assertEqual(response.status_code, 200) | ||
|
|
||
|
|
||
| class ChatSessionCreateTestCase(TestCase): | ||
| def setUp(self): | ||
| self.start_date = timezone.make_aware(datetime.datetime(2017, 11, 6, 12, 10, 5)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (88 > 79 characters) |
||
| self.end_date = timezone.make_aware(datetime.datetime(2017, 12, 15, 22, 45, 50)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (88 > 79 characters) |
||
| chatSession.objects.create(title="oshc-session", profile_name="test_name", profile_url="http://google.com/", description="This is a sample description", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (160 > 79 characters) |
||
| start_date=self.start_date, end_date=self.end_date, register_url="http://google.com/") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (121 > 79 characters) |
||
|
|
||
| def test_title(self): | ||
| SessionTitle = chatSession.objects.get(title="oshc-session") | ||
| self.assertEqual(SessionTitle.title, 'oshc-session') | ||
|
|
||
| def test_profile_name(self): | ||
| SessionProfileName = chatSession.objects.get(profile_name="test_name") | ||
| self.assertEqual(SessionProfileName.profile_name, "test_name") | ||
|
|
||
| def test_profile_url(self): | ||
| SessionProfileUrl = chatSession.objects.get( | ||
| profile_url="http://google.com/") | ||
| self.assertEqual(SessionProfileUrl.profile_url, "http://google.com/") | ||
|
|
||
| def test_description(self): | ||
| SessionDescription = chatSession.objects.get( | ||
| description="This is a sample description") | ||
| self.assertEqual(SessionDescription.description, | ||
| "This is a sample description") | ||
|
|
||
| def test_start_date(self): | ||
| ContestStartDate = chatSession.objects.get(start_date=self.start_date) | ||
| self.assertEqual(ContestStartDate.start_date, self.start_date) | ||
|
|
||
| def test_end_date(self): | ||
| ContestEndDate = chatSession.objects.get(end_date=self.end_date) | ||
| self.assertEqual(ContestEndDate.end_date, self.end_date) | ||
|
|
||
| def test_register_url(self): | ||
| SessionRegisterUrl = chatSession.objects.get( | ||
| register_url="http://google.com/") | ||
| self.assertEqual(SessionRegisterUrl.register_url, "http://google.com/") | ||
|
|
||
|
|
||
| class ContestCreateTestCase(TestCase): | ||
| def setUp(self): | ||
| Contest.objects.create(name="oshc", link="http://google.com/", description="This is a sample description", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (114 > 79 characters) |
||
| start_date="2014-04-03", end_date="2014-04-04", approved=True) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (93 > 79 characters) |
||
|
|
||
| def test_name(self): | ||
| ContestName = Contest.objects.get(name="oshc") | ||
| self.assertEqual(ContestName.name, 'oshc') | ||
|
|
||
| def test_link(self): | ||
| ContestLink = Contest.objects.get(link="http://google.com/") | ||
| self.assertEqual(ContestLink.link, "http://google.com/") | ||
|
|
||
| def test_description(self): | ||
| ContestDescription = Contest.objects.get( | ||
| description="This is a sample description") | ||
| self.assertEqual(ContestDescription.description, | ||
| "This is a sample description") | ||
|
|
||
| def test_start_date(self): | ||
| ContestStartDate = Contest.objects.get(start_date="2014-04-03") | ||
| self.assertEqual(ContestStartDate.start_date, | ||
| datetime.date(2014, 4, 3)) | ||
|
|
||
| def test_end_date(self): | ||
| ContestEndDate = Contest.objects.get(end_date="2014-04-04") | ||
| self.assertEqual(ContestEndDate.end_date, datetime.date(2014, 4, 4)) | ||
|
|
||
|
|
||
| class ContestCreateValidation(TestCase): | ||
| def test_contest_create(self): | ||
| c = Client() | ||
| response = c.post('/contest_new/', {'name': 'oshc', 'link': 'http://google.com/', 'description': 'This is a sample description', 'start_date': '2014-04-03', 'end_date': '2014-04-04', 'approved': 'True'}) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line too long (211 > 79 characters) |
||
| self.assertEqual(response.status_code, 200) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'django.utils.timezone' imported but unused