Example #1
0
    def test_find_your_match_with_remote(self, repos):
        class Repo:
            @classmethod
            def json(cls):
                return json.loads(GITHUB_REPO_RETURN)

        self.user = create_one_account()
        self.client.force_login(self.user)
        self.post = create_one_job(self.user.id, pay=True, type=2, repo_id=0)
        self.post2 = create_one_job(self.user.id,
                                    title='Backend Engineer',
                                    pay=True,
                                    repo_id=1)
        self.post3 = create_one_job(self.user.id,
                                    title='Data Scientist',
                                    pay=True,
                                    repo_id=2)
        self.post4 = create_one_job(self.user.id,
                                    title='Frontend Engineer',
                                    pay=True,
                                    repo_id=1)
        repos.return_value = Repo
        response = self.client.get('/match/?type=remote')
        self.assertContains(response, '<a class="job-title"')
        self.assertNotContains(response, 'Senior Software Engineer')
        self.assertContains(response, 'Backend Engineer')
        self.assertContains(response, '<i class="fa fa-building building"')
Example #2
0
 def test_other_pages_not_login_redirect(self):
     # Before user login
     response = self.client.get(reverse('post_job'))
     self.assertEqual(response.status_code, 302)
     response = self.client.get(reverse('pay'))
     self.assertEqual(response.status_code, 302)
     response = self.client.get(reverse('repo_search'))
     self.assertEqual(response.status_code, 302)
     response = self.client.get(reverse('match'))
     self.assertEqual(response.status_code, 302)
     response = self.client.get(reverse('match'))
     self.assertEqual(response.status_code, 302)
     response = self.client.get(reverse('contributors'))
     self.assertEqual(response.status_code, 302)
     response = self.client.get(reverse('posted_jobs'))
     self.assertEqual(response.status_code, 302)
     # After user login
     user = create_one_account()
     self.client.force_login(user)
     self.post = create_one_job(user.id)
     response = self.client.get(reverse('contributors'))
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, SEARCH)
     response = self.client.get(reverse('posted_jobs'))
     self.assertEqual(response.status_code, 200)
     response = self.client.get(reverse('post_job'))
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, 'Job Details')
Example #3
0
 def test_browse_no_post(self):
     user = create_one_account()
     self.client.force_login(user)
     response = self.client.get(reverse('browse'))
     self.assertContains(response, JOBLIST)
     self.assertNotContains(response, 'Senior Software Engineer')
     self.assertContains(response, 'Show Remote Jobs')
     self.assertEqual(response.status_code, 200)
Example #4
0
 def test_front_page_200_with_without_login(self):
     response = self.client.get(reverse('front_page'))
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, LOGIN)
     user = create_one_account()
     self.client.force_login(user)
     response = self.client.get(reverse('front_page'))
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, MATCH)
Example #5
0
 def test_pay_post(self):
     self.user = create_one_account()
     self.client.force_login(self.user)
     self.post = create_one_job(self.user.id)
     response = views._pay_post(999)
     self.assertEqual(response.status_code, 400)
     self.assertEqual(self.post.pay, False)
     response = views._pay_post(self.post.id)
     self.post.refresh_from_db()
     self.assertEqual(self.post.pay, True)
Example #6
0
 def test_get_valid_post(self):
     self.user = create_one_account()
     self.client.force_login(self.user)
     self.post = create_one_job(self.user.id, pay=True)
     self.post2 = create_one_job(self.user.id,
                                 title='Backend Engineer',
                                 pay=True,
                                 repo_id=1,
                                 type=1)
     self.post3 = create_one_job(self.user.id,
                                 title='Data Scientist',
                                 pay=True,
                                 repo_id=2,
                                 type=2)
     post = views._get_valid_post()
     self.assertEqual(post.count(), 3)
     remote_post = views._get_valid_post(type='remote')
     self.assertEqual(remote_post.count(), 2)
Example #7
0
 def test_browse_page_200_with_without_login(self):
     user = create_one_account()
     self.client.force_login(user)
     Post.objects.create(
         user=user,
         title='Senior Software Engineer',
         job_des='You are a self-starter who can work with little',
         type=0,
         visa=0,
         salary='$100k',
         company_name='Built For Me Inc.',
         company_des='We are a small company loathe to use the word.',
         location='LA',
         website='https://www.example.com',
         apply='https://job.example.com',
         pay=1,
         pay_time=timezone.now())
     response = self.client.get(reverse('front_page'))
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, 'Jobs Posted')
     self.client.logout()
     response = self.client.get(reverse('browse'))
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, 'Senior Software Engineer')
Example #8
0
    def test_repo_search_valid_post_user(self, repos):
        class Repo:
            @classmethod
            def json(cls):
                return json.loads(GITHUB_REPO_RETURN)

        repos.return_value = Repo
        user = create_one_account()
        self.client.force_login(user)
        create_one_job(user.id, pay=True)
        response = self.client.get(reverse('match'))
        response = self.client.get("%s?repo_id=4164482" %
                                   (reverse('repo_search')))
        user_response = {
            'length':
            1,
            'data': [{
                'username':
                '******',
                'avatar_url':
                'https://avatars2.githubusercontent.com/u/14333046?v=4'
            }]
        }
        self.assertEqual(response.json(), user_response)
Example #9
0
 def test_no_card(self):
     user = create_one_account()
     self.client.force_login(user)
     response = self.client.get(
         reverse('card', kwargs={'name': user.username}))
     self.assertContains(response, 'You don\'t have any card yet.')
Example #10
0
 def test_repo_search_no_valid_post_user(self):
     user = create_one_account()
     self.client.force_login(user)
     response = self.client.get("%s?repo_id=1" % (reverse('repo_search')))
     self.assertEqual(response.status_code, 403)
     self.assertEqual(response.json(), {"length": 0, "data": []})
Example #11
0
 def test_repo_search_miss_id(self):
     user = create_one_account()
     self.client.force_login(user)
     response = self.client.get(reverse('repo_search'))
     self.assertEqual(response.status_code, 400)
Example #12
0
 def test_create_settings_model(self):
     user = create_one_account()
     self.assertEqual(user.settings.user_id, user.id)
Example #13
0
 def setUp(self):
     self.user = create_one_account()
     self.user2 = create_one_account('2testaccouont', '*****@*****.**')
     self.client.force_login(self.user)