def test_instantiate(): global requestors, printerManagerInstance # verify adding single requestor works printerManagerInstance = PrinterManager(requestors[0]) assert printerManagerInstance.requestors[0] == requestors[0] assert len(printerManagerInstance.requestors) == 1 # verify adding whole array of requestors works printerManagerInstance = PrinterManager(requestors) assert printerManagerInstance.requestors == requestors assert len(printerManagerInstance.requestors) == len(requestors)
def getCCPPrinters(self): if self._ccp_printers is None: td = time.time() ccp_printers = [] for p in PrinterManager(self.getRequestors()).getPrinters(): ccp_printers.append( AddPrinterDialogPrinter( p.getURI(), p.getDisplayName(), p.getLocation(), '%s %s' % (p.getDisplayName().lower(), p.getLocation().lower()), p)) td = time.time() - td print 'get ccp printers took %.2f seconds' % td self._ccp_printers = sorted(ccp_printers) return self._ccp_printers
def setup_function(function): # setup mock requestors global printers, printerManagerInstance mockRequestorInstance = MockRequestor() mockRequestorInstance.setAccount('*****@*****.**') mockRequestorInstance.printers = [ { 'name': 'Save to Google Drive', 'id': '__test_save_docs', 'capabilities': testCapabilities1 }, { 'name': 'Save to Google Drive 2', 'displayName': 'Save to Google Drive 2 DisplayName', 'id': '__test_save_docs_2' }, ] printerManagerInstance = PrinterManager(mockRequestorInstance) printers = printerManagerInstance.getPrinters()
# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. if __name__ == '__main__': # pragma: no cover import sys from auth import Auth from printermanager import PrinterManager from ccputils import Utils Utils.SetupLogging() # line below is replaced on commit CCPVersion = "20140501 203545" Utils.ShowVersion(CCPVersion) requestors, storage = Auth.SetupAuth(True) printer_manager = PrinterManager(requestors) printers = printer_manager.getPrinters() if printers is None: print "No Printers Found" sys.exit(1) for printer in printers: print printer.getListDescription()