Exemple #1
0
    def test_job_gets_created(self):
        path = '/job'

        data = {
            'title': 'Joberia AI Engineer',
            'created_by': '1',
            'description': 'Hello',
            'short_description': 'asdfaf',
            'desired_profile': ['self reliant', 'docker skills', 'aws', '4 years experience'],
            'offers': ['home office', 'high salary', 'budget', 'vacations'],
            'bonuses': [{'salary': '13', 'pets allowed': True}],
            'location_tags': ['munich'],
            'skill_tags': ['postgres', 'docker', 'nodejs', 'react'],
        }

        auth_headers = {
            'HTTP_AUTHORIZATION': 'JWT ' + get_default_user_token()
        }

        response = self.client.post(path=path, data=data, content_type='application/json',
                                    **auth_headers)
        # check that job was created

        jobs = Job.objects.all()
        job = jobs.first()
        self.assertNotEqual(job, None)
        self.assertEqual(job.title, data['title'])
        self.assertEqual(list(job.comments.all()), [])
        self.assertEqual(job.description, data['description'])
        self.assertEqual(job.short_description, data['short_description'])
        self.assertEqual(len(job.desired_profile.all()), len(data['desired_profile']))
Exemple #2
0
    def test_comment_gets_edited(self):
        comment = create_default_comment(self.client,
                                         text='Born to be deleted.')
        path = '/job/comment?id={comment_id}&?job={job_id}'.format(
            job_id='1', comment_id=comment['id'])
        auth_headers = {
            'HTTP_AUTHORIZATION': 'JWT ' + get_default_user_token()
        }

        response = self.client.delete(path=path, **auth_headers)
        response_data = json.loads(str(response.content, encoding='utf-8'))
Exemple #3
0
    def test_deletes_single_eleemnt(self):
        path = '/job?id=1'
        auth_headers = {
            'HTTP_AUTHORIZATION': 'JWT ' + get_default_user_token()
        }

        response = self.client.delete(path=path, **auth_headers)

        result = json.loads(str(response.content, encoding='utf-8'))

        self.assertEqual(result, {"success": {"message": "1 was deleted successfully."}})
Exemple #4
0
    def test_deletes_single_eleemnt(self):
        path = '/job'
        auth_headers = {
            'HTTP_AUTHORIZATION': 'JWT ' + get_default_user_token()
        }

        data = {
            'id': '4',
            'description': 'This is an edited description!'
        }

        response = self.client.put(path=path, data=data, **auth_headers, content_type='application/json')
        response_data = json.loads(str(response.content, encoding='utf-8'))
        self.assertEqual(response_data['description'], data['description'])
Exemple #5
0
    def test_comment_gets_edited(self):
        data = {'author': '1', 'text': 'Hula Hula Hup', 'job': '1', 'id': '1'}

        path = '/job/comment'
        auth_headers = {
            'HTTP_AUTHORIZATION': 'JWT ' + get_default_user_token()
        }

        response = self.client.put(path=path,
                                   data=data,
                                   content_type='application/json',
                                   **auth_headers)

        response_data = json.loads(str(response.content, encoding='utf-8'))
        self.assertEqual(response_data['text'], data['text'])
Exemple #6
0
    def test_creates_comment(self):
        data = {
            'text': 'Are you hiring?',
            'job_id': '1',
        }

        path = '/job/comment'
        auth_headers = {
            'HTTP_AUTHORIZATION': 'JWT ' + get_default_user_token()
        }

        response = self.client.post(path=path,
                                    data=data,
                                    content_type='application/json',
                                    **auth_headers)

        self.assertEqual(
            json.loads(str(response.content, encoding='utf-8'))['text'],
            'Are you hiring?')