diff options
author | prathamesh | 2017-11-13 17:19:11 +0530 |
---|---|---|
committer | prathamesh | 2017-11-13 17:19:11 +0530 |
commit | a3a94ded76f02820b3a1536055dad0dc2dac81c5 (patch) | |
tree | c474bc7d251b0e43eb2e48f5af1906ebcf053909 /yaksh/test_views.py | |
parent | 847c24c0fe3c9d9f31ae4e5c3c0a68b783873592 (diff) | |
download | online_test-a3a94ded76f02820b3a1536055dad0dc2dac81c5.tar.gz online_test-a3a94ded76f02820b3a1536055dad0dc2dac81c5.tar.bz2 online_test-a3a94ded76f02820b3a1536055dad0dc2dac81c5.zip |
Added test case for add, update and remove
Diffstat (limited to 'yaksh/test_views.py')
-rw-r--r-- | yaksh/test_views.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 9f46ba9..2dddcef 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -1815,6 +1815,33 @@ class TestCourseDetail(TestCase): self.assertIn('upload_details', response.context) self.assertTemplateUsed(response, 'yaksh/course_detail.html') + def test_upload_users_add_update_reject(self): + # Given + self.client.login( + username=self.user1.username, + password=self.user1_plaintext_pass + ) + csv_file_path = os.path.join(FIXTURES_DIR_PATH, + "users_add_update_reject.csv") + csv_file = open(csv_file_path, 'rb') + upload_file = SimpleUploadedFile(csv_file_path, csv_file.read()) + + # When + response = self.client.post(reverse('yaksh:upload_users', + kwargs={'course_id': self.user1_course.id}), + data={'csv_file': upload_file}) + csv_file.close() + + # Then + uploaded_user = User.objects.filter(username="test") + user = uploaded_user[0] + self.assertEqual(uploaded_user.count(), 1) + self.assertEqual(user.first_name, "test2") + self.assertIn(user, self.user1_course.get_rejected()) + self.assertEqual(response.status_code, 200) + self.assertIn('upload_details', response.context) + self.assertTemplateUsed(response, 'yaksh/course_detail.html') + def test_upload_users_with_wrong_csv(self): # Given self.client.login( |