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')
class HamQTHClientSearchCallsignRecentActivityTestCase(TestCase):
    def setUp(self):
        self.client = HamQTHClient(
            session_id='09b0ae90050be03c452ad235a1f2915ad684393c')

    def test_search_callsign_bio(self):
        query = 'ok2cqr'
        with patch.object(HamQTHClient,
                          'request',
                          return_value=SearchCallsignRecentActivityResponse()
                          ) as mock_method:
            self.client.search_callsign_recent_activity(query)
        mock_method.assert_called_once_with(
            'https://www.hamqth.com/xml.php',
            payload={
                'id': '09b0ae90050be03c452ad235a1f2915ad684393c',
                'callsign': 'ok2cqr',
                'rec_activity': 1,
                'log_activity': 1,
                'logbook': 1
            })

    def test_search_callsign_bio_rec_activity(self):
        query = 'ok2cqr'
        with patch.object(HamQTHClient,
                          'request',
                          return_value=SearchCallsignRecentActivityResponse()
                          ) as mock_method:
            self.client.search_callsign_recent_activity(query,
                                                        rec_activity=False)
        mock_method.assert_called_once_with(
            'https://www.hamqth.com/xml.php',
            payload={
                'id': '09b0ae90050be03c452ad235a1f2915ad684393c',
                'callsign': 'ok2cqr',
                'rec_activity': 0,
                'log_activity': 1,
                'logbook': 1
            })

    def test_search_callsign_bio_log_activity(self):
        query = 'ok2cqr'
        with patch.object(HamQTHClient,
                          'request',
                          return_value=SearchCallsignRecentActivityResponse()
                          ) as mock_method:
            self.client.search_callsign_recent_activity(query,
                                                        log_activity=False)
        mock_method.assert_called_once_with(
            'https://www.hamqth.com/xml.php',
            payload={
                'id': '09b0ae90050be03c452ad235a1f2915ad684393c',
                'callsign': 'ok2cqr',
                'rec_activity': 1,
                'log_activity': 0,
                'logbook': 1
            })

    def test_search_callsign_bio_logbook(self):
        query = 'ok2cqr'
        with patch.object(HamQTHClient,
                          'request',
                          return_value=SearchCallsignRecentActivityResponse()
                          ) as mock_method:
            self.client.search_callsign_recent_activity(query, logbook=False)
        mock_method.assert_called_once_with(
            'https://www.hamqth.com/xml.php',
            payload={
                'id': '09b0ae90050be03c452ad235a1f2915ad684393c',
                'callsign': 'ok2cqr',
                'rec_activity': 1,
                'log_activity': 1,
                'logbook': 0
            })

    def test_search_callsign_bio_not_found(self):
        query = 'ok2cqr'
        with patch.object(
                HamQTHClient,
                'request',
                return_value=SearchCallsignRecentActivityNotFoundResponse(
                )) as mock_method:
            with self.assertRaises(HamQTHClientNotFoundError):
                self.client.search_callsign_recent_activity(query)
        mock_method.assert_called_once_with(
            'https://www.hamqth.com/xml.php',
            payload={
                'id': '09b0ae90050be03c452ad235a1f2915ad684393c',
                'callsign': 'ok2cqr',
                'rec_activity': 1,
                'log_activity': 1,
                'logbook': 1
            })