Example #1
0
    def test_start_authenticate_v1_fail(self):
        response = mocked_response('something_terrible', status_code=400)
        (flexmock(requests).should_receive('get').with_args(
            'https://www.box.com/api/1.0/rest?action=get_ticket&api_key=my_api_key'
        ).and_return(response))

        with self.assertRaises(
                BoxAuthenticationException) as expected_exception:
            self.assertEqual(start_authenticate_v1('my_api_key'),
                             'https://www.box.com/api/1.0/auth/golden_ticket')

        self.assertEqual('something_terrible',
                         expected_exception.exception.message)

        response = mocked_response(
            '<response><status>something_terrible</status></response>')
        (flexmock(requests).should_receive('get').with_args(
            'https://www.box.com/api/1.0/rest?action=get_ticket&api_key=my_api_key'
        ).and_return(response))

        with self.assertRaises(
                BoxAuthenticationException) as expected_exception:
            self.assertEqual(start_authenticate_v1('my_api_key'),
                             'https://www.box.com/api/1.0/auth/golden_ticket')

        self.assertEqual('something_terrible',
                         expected_exception.exception.message)
Example #2
0
    def test_start_authenticate_v1(self):
        response = mocked_response('<response><status>get_ticket_ok</status><ticket>golden_ticket</ticket></response>')
        (flexmock(requests)
            .should_receive('get')
            .with_args('https://www.box.com/api/1.0/rest?action=get_ticket&api_key=my_api_key')
            .and_return(response))

        self.assertEqual(start_authenticate_v1('my_api_key'), 'https://www.box.com/api/1.0/auth/golden_ticket')
Example #3
0
    def test_start_authenticate_v1(self):
        response = mocked_response(
            '<response><status>get_ticket_ok</status><ticket>golden_ticket</ticket></response>'
        )
        (flexmock(requests).should_receive('get').with_args(
            'https://www.box.com/api/1.0/rest?action=get_ticket&api_key=my_api_key'
        ).and_return(response))

        self.assertEqual(start_authenticate_v1('my_api_key'),
                         'https://www.box.com/api/1.0/auth/golden_ticket')
Example #4
0
    def test_start_authenticate_v1_fail(self):
        response = mocked_response('something_terrible', status_code=400)
        (flexmock(requests)
            .should_receive('get')
            .with_args('https://www.box.com/api/1.0/rest?action=get_ticket&api_key=my_api_key')
            .and_return(response))

        with self.assertRaises(BoxAuthenticationException) as expected_exception:
            self.assertEqual(start_authenticate_v1('my_api_key'), 'https://www.box.com/api/1.0/auth/golden_ticket')

        self.assertEqual('something_terrible', expected_exception.exception.message)

        response = mocked_response('<response><status>something_terrible</status></response>')
        (flexmock(requests)
            .should_receive('get')
            .with_args('https://www.box.com/api/1.0/rest?action=get_ticket&api_key=my_api_key')
            .and_return(response))

        with self.assertRaises(BoxAuthenticationException) as expected_exception:
            self.assertEqual(start_authenticate_v1('my_api_key'), 'https://www.box.com/api/1.0/auth/golden_ticket')

        self.assertEqual('something_terrible', expected_exception.exception.message)