Example #1
0
 def test_form_defaults(self):
     from seantisinvoice.views.reports import ReportsController
     request = testing.DummyRequest()
     view = ReportsController(None, request)
     defaults = view.form_defaults()
     self.assertEquals(None, defaults['from_date'])
     self.assertEquals(None, defaults['to_date'])
     # Add an invoice
     invoice = self._add_invoice()
     invoice.date = datetime.date(2010, 3, 1)
     view = ReportsController(None, request)
     defaults = view.form_defaults()
     self.assertEquals(datetime.date(2010, 3, 1), defaults['from_date'])
     self.assertEquals(datetime.date(2010, 3, 1), defaults['to_date'])
     # Add a second invoice
     invoice2 = self._add_invoice()
     invoice2.date = datetime.date(2010, 4, 1)
     view = ReportsController(None, request)
     defaults = view.form_defaults()
     self.assertEquals(datetime.date(2010, 3, 1), defaults['from_date'])
     self.assertEquals(datetime.date(2010, 4, 1), defaults['to_date'])
Example #2
0
    def test_form_defaults(self):
        from seantisinvoice.views.reports import ReportsController

        request = testing.DummyRequest()
        view = ReportsController(None, request)
        defaults = view.form_defaults()
        self.assertEquals(None, defaults["from_date"])
        self.assertEquals(None, defaults["to_date"])
        # Add an invoice
        invoice = self._add_invoice()
        invoice.date = datetime.date(2010, 3, 1)
        view = ReportsController(None, request)
        defaults = view.form_defaults()
        self.assertEquals(datetime.date(2010, 3, 1), defaults["from_date"])
        self.assertEquals(datetime.date(2010, 3, 1), defaults["to_date"])
        # Add a second invoice
        invoice2 = self._add_invoice()
        invoice2.date = datetime.date(2010, 4, 1)
        view = ReportsController(None, request)
        defaults = view.form_defaults()
        self.assertEquals(datetime.date(2010, 3, 1), defaults["from_date"])
        self.assertEquals(datetime.date(2010, 4, 1), defaults["to_date"])
Example #3
0
    def test_handle_submit(self):
        from seantisinvoice.views.reports import ReportsController

        request = testing.DummyRequest()
        view = ReportsController(None, request)
        data = view.form_defaults()
        results = view.handle_submit(data)
        self.assertEquals([], results["invoices"])
        data["from_date"] = datetime.date(2010, 1, 1)
        data["to_date"] = datetime.date(2010, 12, 31)
        results = view.handle_submit(data)
        self.assertEquals([], results["invoices"])
        # Add two invoices
        invoice1 = self._add_invoice()
        invoice1.date = datetime.date(2010, 3, 1)
        invoice2 = self._add_invoice()
        invoice2.date = datetime.date(2010, 4, 25)
        data["from_date"] = datetime.date(2010, 3, 1)
        data["to_date"] = datetime.date(2010, 3, 31)
        results = view.handle_submit(data)
        self.assertEquals([invoice1], results["invoices"])
        data["from_date"] = datetime.date(2010, 3, 1)
        data["to_date"] = datetime.date(2010, 4, 30)
        results = view.handle_submit(data)
        self.assertEquals([invoice2, invoice1], results["invoices"])
        data["from_date"] = datetime.date(2010, 4, 25)
        data["to_date"] = datetime.date(2010, 4, 25)
        results = view.handle_submit(data)
        self.assertEquals([invoice2], results["invoices"])
        data["customer"] = invoice2.contact.customer.id
        results = view.handle_submit(data)
        self.assertEquals([invoice2], results["invoices"])
        # Add a second customer
        customer2 = self._add_customer()
        invoice2.contact = customer2.contacts[0]
        results = view.handle_submit(data)
        self.assertEquals([], results["invoices"])
Example #4
0
 def test_handle_submit(self):
     from seantisinvoice.views.reports import ReportsController
     request = testing.DummyRequest()
     view = ReportsController(None, request)
     data = view.form_defaults()
     results = view.handle_submit(data)
     self.assertEquals([], results['invoices'])
     data['from_date'] = datetime.date(2010, 1, 1)
     data['to_date'] = datetime.date(2010, 12, 31)
     results = view.handle_submit(data)
     self.assertEquals([], results['invoices'])
     # Add two invoices
     invoice1 = self._add_invoice()
     invoice1.date = datetime.date(2010, 3, 1)
     invoice2 = self._add_invoice()
     invoice2.date = datetime.date(2010, 4, 25)
     data['from_date'] = datetime.date(2010, 3, 1)
     data['to_date'] = datetime.date(2010, 3, 31)
     results = view.handle_submit(data)
     self.assertEquals([invoice1], results['invoices'])
     data['from_date'] = datetime.date(2010, 3, 1)
     data['to_date'] = datetime.date(2010, 4, 30)
     results = view.handle_submit(data)
     self.assertEquals([invoice2, invoice1], results['invoices'])
     data['from_date'] = datetime.date(2010, 4, 25)
     data['to_date'] = datetime.date(2010, 4, 25)
     results = view.handle_submit(data)
     self.assertEquals([invoice2], results['invoices'])
     data['customer'] = invoice2.contact.customer.id
     results = view.handle_submit(data)
     self.assertEquals([invoice2], results['invoices'])
     # Add a second customer
     customer2 = self._add_customer()
     invoice2.contact = customer2.contacts[0]
     results = view.handle_submit(data)
     self.assertEquals([], results['invoices'])