コード例 #1
0
class HamQTHClientSearchCallsignTestCase(TestCase):
    def setUp(self):
        self.client = HamQTHClient(
            session_id='09b0ae90050be03c452ad235a1f2915ad684393c')

    def test_search_callsign(self):
        query = 'ok2cqr'
        with patch.object(
                HamQTHClient, 'request',
                return_value=SearchCallsignResponse()) as mock_method:
            self.client.search_callsign(query)
        mock_method.assert_called_once_with(
            'https://www.hamqth.com/xml.php',
            payload={
                'id': '09b0ae90050be03c452ad235a1f2915ad684393c',
                'callsign': 'ok2cqr',
                'prg': 'HamQTHClient'
            })

    def test_search_callsign_not_found(self):
        query = 'ok2cqr'
        with patch.object(
                HamQTHClient,
                'request',
                return_value=SearchCallsignNotFoundResponse()) as mock_method:
            with self.assertRaises(HamQTHClientNotFoundError):
                self.client.search_callsign(query)
        mock_method.assert_called_once_with(
            'https://www.hamqth.com/xml.php',
            payload={
                'id': '09b0ae90050be03c452ad235a1f2915ad684393c',
                'callsign': 'ok2cqr',
                'prg': 'HamQTHClient'
            })
コード例 #2
0
class HamQTHClientNotAuthenticatedTestCase(TestCase):
    def setUp(self):
        self.client = HamQTHClient()

    def test_is_authenticated_is_false(self):
        self.assertFalse(self.client.is_authenticated)

    def test_search_callsign_raises_error(self):
        with self.assertRaises(HamQTHClientError):
            self.client.search_callsign('abc123')

    def test_search_callsign_bio_raises_error(self):
        with self.assertRaises(HamQTHClientError):
            self.client.search_callsign_bio('abc123')

    def test_search_callsign_recent_activity_raises_error(self):
        with self.assertRaises(HamQTHClientError):
            self.client.search_callsign_recent_activity('abc123')