Example #1
0
    def test_validate_ticket_success_with_groups(self, mock_urlopen):
        self.response.read.return_value = "yes\nanders\ngroup1\ngroup2"
        mock_urlopen.return_value = self.response

        self.assertEqual(
            validate_wind_ticket("foo"),
            (True, 'anders', ['anders', 'group1', 'group2']))
        mock_urlopen.assert_called_with(
            'https://wind.columbia.edu/validate?ticketid=foo')
Example #2
0
    def test_validate_ticket_fail(self, mock_urlopen):
        self.response.read.return_value = 'no\nanders'
        mock_urlopen.return_value = self.response

        self.assertEqual(
            validate_wind_ticket("foo"),
            (False, "The ticket was already used or was invalid.", []))
        mock_urlopen.assert_called_with(
            'https://wind.columbia.edu/validate?ticketid=foo')
Example #3
0
    def test_validate_ticket_alternate_wind_base(self, mock_urlopen):
        self.response.read.return_value = 'yes\nanders'
        mock_urlopen.return_value = self.response

        with self.settings(WIND_BASE="https://foo.example.com/"):
            self.assertEqual(
                validate_wind_ticket("foo"),
                (True, 'anders', ['anders']))
            mock_urlopen.assert_called_with(
                'https://foo.example.com/validate?ticketid=foo')
Example #4
0
    def test_validate_ticket_invalid_response(self, mock_urlopen):
        self.response.read.return_value = \
            "holy crap! I'm not a valid WIND response!"
        mock_urlopen.return_value = self.response

        self.assertEqual(
            validate_wind_ticket("foo"),
            (False, "WIND did not return a valid response.", []))
        mock_urlopen.assert_called_with(
            'https://wind.columbia.edu/validate?ticketid=foo')
Example #5
0
 def test_no_ticket(self, mock_urlopen):
     self.assertEqual(
         validate_wind_ticket(""),
         (False, 'no ticketid', ''))