コード例 #1
0
    def test_template_with_dx_record(self):
        qrz = QRZRecord()
        qrz.is_authenticated = True
        qrz.error = None
        qrz.country = 'France'
        qrz.fname = 'Foo'
        qrz.name = 'Bar'
        qrz.addr2 = 'Paris'
        qrz.grid = 'AB01LD'
        qrz.licence_class = None

        self.assertEquals( u'\n\n<p>Foo Bar<br/>\n\nParis, France\n<br/>\nOther | AB01LD <br/>\n<a href="http://qrz.com/db/?callsign=None" target="_qrz">View on QRZ.com</a>\n</p>\n\n\n',render_to_string('callsign_lookup.html',{'qrz': qrz}))
コード例 #2
0
ファイル: tests.py プロジェクト: moosepod/jt65_hf_logwatch
    def test_is_dx(self):
        qrz = QRZRecord()
        qrz.country = 'United States'
        self.assertFalse(qrz.is_dx())

        qrz.country = 'united states'
        self.assertFalse(qrz.is_dx())
    
        qrz.country = 'Canada'
        self.assertTrue(qrz.is_dx())
コード例 #3
0
    def setup_context(self, session, **kwargs):
        context = {'error': None,
                   'qrz': None}
        
        session_id = session.get('qrz_session_id')
        if not session_id:
	    username,password = session.get('qrz_info')
	    session_id = self.login(username,password)
            session['qrz_session_id'] = session_id
	    
        callsign = kwargs.get('callsign')

        if not callsign:
            qrz= QRZRecord()
            qrz.error = 'Missing callsign.'
        else:
            if callsign == 'TESTING' and settings.DEBUG:
                # Some kind of dependency injection would probably work better here, but this is 
                # the expedient way to do things
                data = 'asdfa'
            else:
                data = self.get_qrz_data(callsign,session_id)
            
            if data:
                qrz = QRZRecord(xml_data=data)
            else:
                qrz = QRZRecord()
                qrz.is_authenticated = False
                qrz.error = 'Unable to connect to QRZ.com'
        
        context['qrz'] = qrz

        return context
コード例 #4
0
ファイル: tests.py プロジェクト: moosepod/jt65_hf_logwatch
 def test_licence_class_expanded(self):
     qrz = QRZRecord()
     qrz.license_class = None
     self.assertEquals('Other', qrz.license_class_expanded())
     qrz.license_class = 'G'
     self.assertEquals('General', qrz.license_class_expanded())
     qrz.license_class = 'A'
     self.assertEquals('Advanced', qrz.license_class_expanded())
     qrz.license_class = 'N'
     self.assertEquals('Novice', qrz.license_class_expanded())
     qrz.license_class = 'T'
     self.assertEquals('Technician', qrz.license_class_expanded())
     qrz.license_class = 'E'
     self.assertEquals('Extra', qrz.license_class_expanded())
コード例 #5
0
    def test_template_with_us_record(self):
        qrz = QRZRecord()
        qrz.is_authenticated = True
        qrz.error = None
        qrz.country = 'United States'
        qrz.fname = 'Foo'
        qrz.name = 'Bar'
        qrz.state = 'MI'
        qrz.addr2 = 'Paris'
        qrz.zip = '12345'
        qrz.grid = 'AB01LD'
        qrz.license_class = 'E'
        qrz.will_qsl = True
        qrz.will_eqsl = True

        self.assertEquals( u'\n\n<p>Foo Bar<br/>\nParis, MI 12345<br/>\nExtra | AB01LD | Will QSL | Will eQSL<br/>\n<a href="http://qrz.com/db/?callsign=None" target="_qrz">View on QRZ.com</a>\n</p>\n\n\n',render_to_string('callsign_lookup.html',{'qrz': qrz}))
コード例 #6
0
 def test_template_noauth(self):
     qrz = QRZRecord()
     qrz.is_authenticated = False
     qrz.error = None
     self.assertEquals(u'\n<p>You need to log into QRZ.com to use this feature.</p>\n\n',render_to_string('callsign_lookup.html',{'qrz': qrz}))      
コード例 #7
0
 def test_template_error(self):
     qrz = QRZRecord()
     qrz.error = 'Cannot foo.'
     self.assertEquals( u'<b>Error:</b> Cannot foo.\n',render_to_string('callsign_lookup.html',{'qrz': qrz}))