def test_get_is_active(self):
     is_active = JudgingRoundFactory.create(is_active=True)
     is_not_active = JudgingRoundFactory.create(is_active=False)
     with self.login(email=self.basic_user().email):
         all_response = self.client.get(self.url)
         all_results = all_response.data["results"]
         active_response = self.client.get(self.url + "?is_active=True")
         active_results = active_response.data["results"]
         assert len(active_results) < len(all_results)
         active_ids = [item["id"] for item in active_results]
         assert is_active.id in active_ids
         assert is_not_active.id not in active_ids
 def test_get_by_round_type(self):
     online = JudgingRoundFactory.create(
         round_type=ONLINE_JUDGING_ROUND_TYPE)
     in_person = JudgingRoundFactory.create(
         round_type=IN_PERSON_JUDGING_ROUND_TYPE)
     with self.login(email=self.basic_user().email):
         all_response = self.client.get(self.url)
         all_results = all_response.data["results"]
         online_response = self.client.get(
             self.url + "?round_type={}".format(ONLINE_JUDGING_ROUND_TYPE))
         online_results = online_response.data["results"]
         assert len(online_results) < len(all_results)
         online_ids = [item["id"] for item in online_results]
         assert online.id in online_ids
         assert in_person.id not in online_ids
Пример #3
0
 def test_get_is_active(self):
     active_judging_round = JudgingRoundFactory.create(is_active=True)
     inactive_judging_round = JudgingRoundFactory.create(is_active=False)
     user = self.basic_user()
     _add_clearance(user, active_judging_round)
     _add_clearance(user, inactive_judging_round)
     with self.login(email=user.email):
         all_response = self.client.get(self.url)
         all_results = all_response.data["results"]
         active_response = self.client.get(self.url + "?is_active=True")
         active_results = active_response.data["results"]
         assert len(active_results) < len(all_results)
         active_ids = [item["id"] for item in active_results]
         assert active_judging_round.id in active_ids
         assert inactive_judging_round.id not in active_ids
Пример #4
0
 def test_get(self):
     judging_round = JudgingRoundFactory()
     with self.login(email=self.basic_user().email):
         url = reverse(JudgingRoundDetailView.view_name,
                       args=[judging_round.id])
         response = self.client.get(url)
         assert response.data["name"] == judging_round.name
         assert (response.data["program_id"] == judging_round.program_id)
 def test_user_became_confirmed_judge_with_cycle_based_judging_round(self):
     prg = ProgramRoleGrantFactory(
         program_role__user_role__name=UserRole.JUDGE)
     jr = JudgingRoundFactory(
         confirmed_judge_label=prg.program_role.user_label,
         cycle_based_round=True)
     with self.login(email=self.basic_user().email):
         url = reverse(UserHistoryView.view_name, args=[prg.person.id])
         response = self.client.get(url)
         events = find_events(response.data["results"],
                              UserBecameConfirmedJudgeEvent.EVENT_TYPE)
         self.assertEqual(1, len(events))
         format_string = UserBecameConfirmedJudgeEvent.JUDGING_ROUND_FORMAT
         self.assertEqual(
             format_string.format(
                 role_name=UserBecameConfirmedJudgeEvent.ROLE_NAME,
                 name=jr.short_name(),
                 id=jr.id), events[0]["description"])
Пример #6
0
 def test_options(self):
     judging_round = JudgingRoundFactory()
     with self.login(email=self.basic_user().email):
         url = reverse(JudgingRoundDetailView.view_name,
                       args=[judging_round.id])
         response = self.client.options(url)
         assert response.status_code == 200
         get_options = response.data["actions"]["GET"]["properties"]
         assert_fields(JUDGING_ROUND_GET_FIELDS, get_options)
 def test_get(self):
     count = 5
     program_families = JudgingRoundFactory.create_batch(count)
     with self.login(email=self.basic_user().email):
         response = self.client.get(self.url)
         assert response.data["count"] == count
         assert all([
             JudgingRoundListView.serialize(judging_round)
             in response.data["results"]
             for judging_round in program_families
         ])
Пример #8
0
 def test_staff_user_can_view(self):
     judging_round = JudgingRoundFactory()
     email = self.staff_user().email
     with self.login(email=email):
         url = reverse(JudgingRoundDetailView.view_name,
                       args=[judging_round.id])
         response = self.client.get(url)
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.data["name"], judging_round.name)
         self.assertEqual(response.data["program_id"],
                          judging_round.program_id)
Пример #9
0
 def test_dont_show_to_user_without_clearance(self):
     the_round = JudgingRoundFactory.create(
         round_type=ONLINE_JUDGING_ROUND_TYPE)
     url = self.url + "?round_type={}".format(ONLINE_JUDGING_ROUND_TYPE)
     user = self.basic_user()
     # User doesn't have clearance for the JudgingRound's ProgramFamily
     with self.login(email=user.email):
         response = self.client.get(url)
         results = response.data["results"]
         round_ids = [item["id"] for item in results]
         self.assertFalse(the_round.id in round_ids)
Пример #10
0
    def test_options_against_get(self):
        judging_round = JudgingRoundFactory()
        with self.login(email=self.basic_user().email):
            url = reverse(JudgingRoundDetailView.view_name,
                          args=[judging_round.id])

            options_response = self.client.options(url)
            get_response = self.client.get(url)

            schema = options_response.data["actions"]["GET"]
            validator = Draft4Validator(schema)
            assert validator.is_valid(json.loads(get_response.content))
Пример #11
0
 def test_ignore_clearance_request_param_works(self):
     the_round = JudgingRoundFactory.create(
         round_type=ONLINE_JUDGING_ROUND_TYPE)
     url = self.url + "?round_type={}&ignore_clearance=true".format(
         ONLINE_JUDGING_ROUND_TYPE)
     user = self.basic_user()
     # The user doesn't have clearance, but PF should be displayed anyway
     with self.login(email=user.email):
         response = self.client.get(url)
         results = response.data["results"]
         round_ids = [item["id"] for item in results]
         self.assertTrue(the_round.id in round_ids)
Пример #12
0
 def test_do_show_to_user_with_clearance(self):
     the_round = JudgingRoundFactory.create(
         round_type=ONLINE_JUDGING_ROUND_TYPE)
     url = self.url + "?round_type={}".format(ONLINE_JUDGING_ROUND_TYPE)
     user = self.basic_user()
     # Give user clearance for JudgingRound's ProgramFamily
     _add_clearance(user, the_round)
     with self.login(email=user.email):
         response = self.client.get(url)
         results = response.data["results"]
         round_ids = [item["id"] for item in results]
         self.assertTrue(the_round.id in round_ids)
 def test_post_new_object(self):
     jr = JudgingRoundFactory()
     data = {
         'name': 'Posted Criterion',
         'type': 'sans serif',
         'judging_round_id': jr.pk
     }
     with self.login(email=self.basic_user().email):
         url = reverse(self.view.view_name)
         response = self.client.post(url, data)
         criterion_id = json.loads(response.content)['id']
         criterion = Criterion.objects.get(id=criterion_id)
         assert_data_is_consistent_with_instance(data, criterion)
Пример #14
0
 def test_get(self):
     count = 5
     judging_rounds = JudgingRoundFactory.create_batch(count)
     user = self.basic_user()
     for judging_round in judging_rounds:
         _add_clearance(user, judging_round)
     with self.login(email=user.email):
         response = self.client.get(self.url)
         assert response.data["count"] == count
         assert all([
             JudgingRoundListView.serialize(judging_round)
             in response.data["results"] for judging_round in judging_rounds
         ])