def testCallsReport(self): from stoqlib.gui.search.callsearch import CallsSearch person = self.create_person() self.create_call() search = CallsSearch(self.store, person) search.width = 1000 # the order_by clause is only needed by the test calls = self.store.find(CallsView).order_by(CallsView.id) search.results.add_list(calls, clear=True) self._diff_expected(CallsReport, 'calls-report', search.results, list(search.results), person=person)
def test_calls_report(self): from stoqlib.gui.search.callsearch import CallsSearch person = self.create_person() self.create_call() search = CallsSearch(self.store, person) search.width = 1000 # the order_by clause is only needed by the test calls = self.store.find(CallsView) search.results.add_list(calls, clear=True) self._diff_expected(CallsReport, 'calls-report', search.results, list(search.results), person=person)
def testWithPerson(self): # 2 calls, different persons call1 = self.create_call() self.create_call(attendant=call1.attendant) search = CallsSearch(self.store, person=call1.person) search.search.refresh() self.check_search(search, 'calls-show-person')
def testShow(self): # 2 calls, different persons call1 = self.create_call() self.create_call(attendant=call1.attendant) search = CallsSearch(self.store, date=call1.date) search.search.refresh() self.check_search(search, 'calls-show')
def testActions(self): # 2 calls, different persons call1 = self.create_call() self.create_call(attendant=call1.attendant) search = CallsSearch(self.store, date=call1.date, reuse_store=True) self.assertNotSensitive(search, ['csv_button', 'print_button']) search.search.refresh() self.assertSensitive(search, ['csv_button', 'print_button']) self.assertNotSensitive(search._toolbar, ['edit_button']) selected = search.results[0] search.results.select(selected) self.assertSensitive(search._toolbar, ['edit_button']) with mock.patch( 'stoqlib.gui.search.callsearch.print_report') as print_report: self.click(search.print_button) self.assertEquals(print_report.call_count, 1) with mock.patch( 'stoqlib.gui.search.callsearch.SpreadSheetExporter.export' ) as export: self.click(search.csv_button) self.assertEquals(export.call_count, 1) with mock.patch( 'stoqlib.gui.search.callsearch.run_dialog') as run_dialog: self.click(search._toolbar.edit_button) self.assertEquals(run_dialog.call_count, 1) args, kwargs = run_dialog.call_args editor, parent, store, model, person, person_type = args self.assertEquals(editor, CallsEditor) self.assertEquals(parent, search) self.assertEquals(model, selected.call) self.assertEquals(person, None) with mock.patch( 'stoqlib.gui.search.callsearch.run_dialog') as run_dialog: self.click(search._toolbar.new_button) self.assertEquals(run_dialog.call_count, 1) args, kwargs = run_dialog.call_args editor, parent, store, model, person, person_type = args self.assertEquals(editor, CallsEditor) self.assertEquals(parent, search) self.assertEquals(model, None) self.assertEquals(person, None)