def test_test_get_owner_user(self): """testing get API of test.""" question_object = QuestionFactory.build() self.client.login(email='*****@*****.**', password='******') _ = self.client.post('/interview/test/', { 'title': 'Dev Test', 'duration': 60, 'question': question_object }) response = self.client.get('/interview/test/') self.assertEqual(response.status_code, 200)
def test_test_creation(self): """testing create API of test.""" question_object = QuestionFactory.build() self.client.login(email='*****@*****.**', password='******') self.assertEqual(Test.objects.count(), 0) response = self.client.post('/interview/test/', { 'title': 'Dev Test', 'duration': 60, 'question': question_object }) self.assertEqual(response.status_code, 201) self.assertEqual(Test.objects.count(), 1)
def test_test_get_owner_user(self): """testing get API of test.""" question_object = QuestionFactory.build() self.client.login(email=self.config['login']['email'], password=self.config['login']['password']) _ = self.client.post('/interview/test/', {'title': self.config['testPostData']['title'], 'duration': self.config['testPostData'][ 'duration'], 'question': question_object}) response = self.client.get('/interview/test/') self.assertEqual(response.status_code, 200)
def test_test_delete_owner_user(self): """testing delete API of test.""" question_object = QuestionFactory.build() self.client.login(email='*****@*****.**', password='******') response = self.client.post('/interview/test/', { 'title': 'Dev Test', 'duration': 60, 'question': question_object }) test_id = response.data['id'] response = self.client.delete('/interview/test/%s/' % test_id) self.assertEqual(response.status_code, 204) self.assertEqual(Test.objects.count(), 0)
def test_test_retrieve_owner_user(self): """testing retrieval of test.""" question_object = QuestionFactory.build() self.client.login(email='*****@*****.**', password='******') response = self.client.post('/interview/test/', { 'title': 'Dev Test', 'duration': 60, 'question': question_object }) test_id = response.data['id'] response = self.client.get('/interview/test/%s/' % test_id) self.assertEqual(response.data['title'], 'Dev Test') self.assertEqual(response.status_code, 200)
def test_test_creation(self): """testing create API of test.""" question_object = QuestionFactory.build() self.client.login(email=self.config['login']['email'], password=self.config['login']['password']) self.assertEqual(Test.objects.count(), 0) response = self.client.post('/interview/test/', {'title': self.config['testPostData'][ 'title'], 'duration': self.config['testPostData'][ 'duration'], 'question': question_object}) self.assertEqual(response.status_code, 201) self.assertEqual(Test.objects.count(), 1)
def test_test_delete_owner_user(self): """testing delete API of test.""" question_object = QuestionFactory.build() self.client.login(email=self.config['login']['email'], password=self.config['login']['password']) response = self.client.post('/interview/test/', {'title': self.config['testPostData'][ 'title'], 'duration': self.config['testPostData'][ 'duration'], 'question': question_object}) test_id = response.data['id'] response = self.client.delete('/interview/test/%s/' % test_id) self.assertEqual(response.status_code, 204) self.assertEqual(Test.objects.count(), 0)
def test_test_update_another_user(self): """testing update API of test using another user.""" question_object = QuestionFactory.build() self.client.login(email='*****@*****.**', password='******') response = self.client.post('/interview/test/', { 'title': 'Dev Test', 'duration': 60, 'question': question_object }) test_id = response.data['id'] self.client.login(email='*****@*****.**', password='******') response = self.client.put( '/interview/test/%s/' % test_id, { 'title': 'Development Test', 'duration': 60, 'question': question_object }) self.assertEqual(response.status_code, 403)
def test_candidate_with_testid(self): """To test candidate user type with test.""" self.client.login(email='*****@*****.**', password='******') question_object = QuestionFactory.build() _ = self.client.post('/interview/test/', { 'title': 'Dev Test', 'duration': 60, 'question': question_object }) test_id = _.data['id'] response = self.client.post( '/interview/user/', { 'email': '*****@*****.**', 'password': '******', 'user_type': 'CANDIDATE', 'test_id': test_id }) self.assertEqual(response.status_code, 201) self.assertEqual(CandidateTestMapping.objects.count(), 0)
def test_test_retrieve_another_user(self): """testing retrieval of test using another user.""" question_object = QuestionFactory.build() self.client.login(email=self.config['login']['email'], password=self.config['login']['password']) response = self.client.post('/interview/test/', {'title': self.config['testPostData'][ 'title'], 'duration': self.config[ 'testPostData']['duration'], 'question': question_object}) test_id = response.data['id'] self.client.login(email=self.config['login']['another_email'], password=self.config['login']['another_password']) response = self.client.get('/interview/test/%s/' % test_id) self.assertEqual(response.data['title'], self.config[ 'testPostData']['title']) self.assertEqual(response.status_code, 200)
def test_candidate_with_testid(self): """To test candidate user type with test.""" self.client.login(email=self.config['login']['email'], password=self.config['login']['password']) question_object = QuestionFactory.build() _ = self.client.post('/interview/test/', {'title': self.config[ 'testPostData']['title'], 'duration': self.config['testPostData'][ 'duration'], 'question': question_object}) test_id = _.data['id'] response = self.client.post('/interview/user/', {'email': self.config['userPostData'][ 'email'], 'password': self.config[ 'userPostData']['password'], 'user_type': self.config['userPostData'][ 'candidate'], 'test': test_id, 'schedule': datetime.now()}) self.assertEqual(response.status_code, 201) self.assertEqual(CandidateTestMapping.objects.count(), 1)