Пример #1
0
 def test_add_institution_command_valid_inputs(self):
     """
     Ensures command works as expected for valid inputs
     """
     call_command("add_institution", "Test", "https://www.example.com")
     call_command("add_institution", "Other Inst", "http://fed.foobar.edu/")
     actual = Institution.objects.order_by("slug")
     expected = [
             Institution(name="Other Inst", slug="other-inst",
                 cas_server_url="http://fed.foobar.edu/"),
             Institution(name="Test", slug="test",
                 cas_server_url="https://www.example.com"),
     ]
     self._check_institutions(actual, expected)
Пример #2
0
 def test_remove_institution_command_invalid_inputs(self, mock_get_input):
     """
     Ensures command fails gracefully for invalid inputs
     """
     self.assertRaisesRegex(CommandError, "argument", call_command,
             "remove_institution")
     self.assertRaisesRegex(CommandError, "slug", call_command,
             "remove_institution", "dne")
     mock_get_input.return_value = "yes"
     call_command("remove_institution", "yale")
     self.assertRaisesRegex(CommandError, "exists", call_command,
             "remove_institution", "yale")
     actual = Institution.objects.order_by("slug")
     expected = [
             Institution(name="Harvard", slug="harvard",
                     cas_server_url="https://fake.harvardcas.edu/"),
             Institution(name="Penn State", slug="penn-state",
                     cas_server_url="https://fake.penncas.edu/")
     ]
     self._check_institutions(actual, expected)
Пример #3
0
 def test_remove_institution_command_valid_inputs(self, mock_get_input):
     """
     Ensures command works as expected for valid inputs
     """
     mock_get_input.return_value = "yes"
     call_command("remove_institution", "penn-state")
     mock_get_input.return_value = "y"
     call_command("remove_institution", "harvard")
     mock_get_input.return_value = "n"
     call_command("remove_institution", "yale")
     mock_get_input.return_value = "other"
     call_command("remove_institution", "yale")
     actual = Institution.objects.order_by("slug")
     expected = [Institution(name="Yale", slug="yale",
             cas_server_url="https://fake.yalecas.edu/")]
     self._check_institutions(actual, expected)