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_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)
Пример #5
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)
Пример #6
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)