def test_create_job(self):
     job_count = Job.objects.count()
     request_data = create_request_body({
         "company_name":
         "smart",
         "date_from":
         '2006-10-25',
         "date_to":
         '2007-10-25',
         "position_name":
         "software engineer",
         "project_ids":
         [self.projects[0].id, self.projects[1].id, self.projects[2].id],
         "responsibility": [{
             'name': 'res1'
         }, {
             'name': 'res2'
         }, {
             'name': 'res3'
         }, {
             'name': 'res4'
         }]
     })
     url = reverse_url("job-list", {})
     url += '?action=save'
     response = self.client.post(url,
                                 request_data,
                                 content_type="application/json")
     self.assertEqual(response.status_code, 200)
     self.assertEqual(Job.objects.count(), job_count + 1)
     created_job_instance = Job.objects.last()
     self.assertEqual(created_job_instance.projects.count(), 3)
     self.assertEqual(created_job_instance.responsibilities.count(), 4)
 def test_update_job_end_date(self):
     request_data = create_request_body({
         'id': self.updated_job.id,
         'date_to': '2008-10-25'
     })
     response = self.send_data_to_update_job_api(request_data)
     self.assertEqual(response.status_code, 200)
     self.validate_update_job_end_date(date(2008, 10, 25))
 def test_update_job_projects(self):
     new_projects_quantity = 2
     project_ids = self.get_list_of_project_ids(new_projects_quantity)
     job_projects_count = self.get_updated_job_projects_count()
     request_data = create_request_body({
         'id': self.updated_job.id,
         'project_ids': project_ids
     })
     response = self.send_data_to_update_job_api(request_data)
     self.assertEqual(response.status_code, 200)
     self.validate_updated_job_projects_count(job_projects_count,
                                              new_projects_quantity)
 def test_update_job_end_date_and_job_responsibilities(self):
     new_responsibilities_count = 2
     responsibility_names = self.get_dict_of_responsibility_names(
         new_responsibilities_count)
     job_responsibilities_count = self.get_update_job_responsibilities_count(
     )
     request_data = create_request_body({
         'id':
         self.updated_job.id,
         'date_to':
         '2010-10-25',
         'responsibility':
         responsibility_names
     })
     response = self.send_data_to_update_job_api(request_data)
     self.assertEqual(response.status_code, 200)
     self.validate_update_job_end_date(date(2010, 10, 25))
     self.validate_updated_job_responsibilities_count(
         job_responsibilities_count, new_responsibilities_count)
 def create_post_request_body(self):
     self.post_request_body = create_request_body({
         'title': 'how to effectively study clean code book',
         'markdown_content': self.markdown_content,
         'tag_ids': self.tag_ids
     })
 def create_request_body(self):
     return create_request_body({
         'id': self.post.id,
         'tag_ids': self.get_new_tags_ids()
     })
 def create_request_body(self):
     return create_request_body({
         'title': self.post.title,
         'markdown_content': self.new_markdown_content,
         'created_date': '2008-10-25',
     })