Пример #1
0
    def test_parse_pcap(self):
        """Test get_hesiod_print_server's ability to parse pcap records"""
        self.mox.StubOutWithMock(common, '_hesiod_lookup')

        common._hesiod_lookup('ajax', 'pcap').AndReturn(
            ['ajax:rp=ajax:rm=GET-PRINT.MIT.EDU:ka#0:mc#0:'])

        self.mox.ReplayAll()

        self.assertEqual(common.get_hesiod_print_server('ajax'),
                         'GET-PRINT.MIT.EDU')
Пример #2
0
    def test_enoent(self):
        """Test _hesiod_lookup on nonexistent record"""
        hesiod.Lookup('doesnt_exist', 'pcap').AndRaise(
            IOError(2, 'No such file or directory'))

        self.mox.ReplayAll()

        self.assertEqual(common._hesiod_lookup('doesnt_exist', 'pcap'),
                         [])
Пример #3
0
    def test(self):
        """Test printing to a printer that is not in Hesiod.

        Taken from -c debathena, reported by quentin on May 14, 2010."""
        # We now call common.find_queue twice
        common._hesiod_lookup('stark', 'pcap').AndReturn([])
        common.get_cups_uri('stark').AndReturn(None)
        common.get_default_printer().AndReturn(None)
        common._hesiod_lookup('stark', 'pcap').AndReturn([])
        common.get_cups_uri('stark').AndReturn(None)
        common.get_cups_uri('stark').AndReturn(None)

        # Result:
        os.execvp('cups-lpr', ['lpr', '-Uquentin', '-Pstark', '-m', 'puppies biting nose.jpg'])

        self.mox.ReplayAll()

        lpr._main(['lpr', '-Pstark', 'puppies biting nose.jpg'])
Пример #4
0
    def test(self):
        """Test printing to a printer that is not in Hesiod.

        Taken from -c debathena, reported by quentin on May 14, 2010."""
        # We now call common.find_queue twice
        common._hesiod_lookup('stark', 'pcap').AndReturn([])
        common.get_cups_uri('stark').AndReturn(None)
        common.get_default_printer().AndReturn(None)
        common._hesiod_lookup('stark', 'pcap').AndReturn([])
        common.get_cups_uri('stark').AndReturn(None)
        common.get_cups_uri('stark').AndReturn(None)

        # Result:
        os.execvp(
            'cups-lpr',
            ['lpr', '-Uquentin', '-Pstark', '-m', 'puppies biting nose.jpg'])

        self.mox.ReplayAll()

        lpr._main(['lpr', '-Pstark', 'puppies biting nose.jpg'])
Пример #5
0
    def test_valid(self):
        """Test _hesiod_lookup on a record that exists"""
        class FakeResults(object): pass
        h = FakeResults()
        h.results = ['ajax:rp=ajax:rm=GET-PRINT.MIT.EDU:ka#0:mc#0:']

        hesiod.Lookup('ajax', 'pcap').AndReturn(h)

        self.mox.ReplayAll()

        self.assertEqual(common._hesiod_lookup('ajax', 'pcap'),
                         h.results)
Пример #6
0
    def test(self):
        """Test printing with LPROPT unset.

        Taken from Trac #509, reported on Mar 12, 2010."""
        # We now call common.find_queue twice
        common._hesiod_lookup('ajax', 'pcap').AndReturn(['ajax:rp=ajax:rm=GET-PRINT.MIT.EDU:ka#0:mc#0:'])
        common.get_default_printer().AndReturn(None)
        common.get_cups_uri('ajax').AndReturn(None)
        # We no longer call "is_cups_server"
        # common.is_cups_server('GET-PRINT.MIT.EDU').AndReturn(True)
        common._hesiod_lookup('ajax', 'pcap').AndReturn(['ajax:rp=ajax:rm=GET-PRINT.MIT.EDU:ka#0:mc#0:'])
        common.get_cups_uri('ajax').AndReturn(None)
        # We no longer call "is_cups_server"
        # common.is_cups_server('GET-PRINT.MIT.EDU').AndReturn(True)

        # Result:
        os.execvp('cups-lpr', ['lpr', '-Ujdreed', '-Pajax', '-m'])

        self.mox.ReplayAll()

        lpr._main(['lpr', '-P', 'ajax'])
Пример #7
0
    def test(self):
        """Test printing with LPROPT unset.

        Taken from Trac #509, reported on Mar 12, 2010."""
        # We now call common.find_queue twice
        common._hesiod_lookup('ajax', 'pcap').AndReturn(
            ['ajax:rp=ajax:rm=GET-PRINT.MIT.EDU:ka#0:mc#0:'])
        common.get_default_printer().AndReturn(None)
        common.get_cups_uri('ajax').AndReturn(None)
        # We no longer call "is_cups_server"
        # common.is_cups_server('GET-PRINT.MIT.EDU').AndReturn(True)
        common._hesiod_lookup('ajax', 'pcap').AndReturn(
            ['ajax:rp=ajax:rm=GET-PRINT.MIT.EDU:ka#0:mc#0:'])
        common.get_cups_uri('ajax').AndReturn(None)
        # We no longer call "is_cups_server"
        # common.is_cups_server('GET-PRINT.MIT.EDU').AndReturn(True)

        # Result:
        os.execvp('cups-lpr', ['lpr', '-Ujdreed', '-Pajax', '-m'])

        self.mox.ReplayAll()

        lpr._main(['lpr', '-P', 'ajax'])