Пример #1
0
    def test_form_widgets(self):
        from seantisinvoice.views.company import CompanyController

        request = testing.DummyRequest()
        view = CompanyController(None, request)
        widgets = view.form_widgets(view.form_fields())
        self.assertEquals(2, len(widgets["invoice_template"].options))
Пример #2
0
 def test_form_fields(self):
     from seantisinvoice.views.company import CompanyController
     from seantisinvoice.views.company import CompanySchema
     request = testing.DummyRequest()
     view = CompanyController(None, request)
     fields = view.form_fields()
     self.assertEquals(CompanySchema.attrs, fields)
Пример #3
0
    def test_form_fields(self):
        from seantisinvoice.views.company import CompanyController
        from seantisinvoice.views.company import CompanySchema

        request = testing.DummyRequest()
        view = CompanyController(None, request)
        fields = view.form_fields()
        self.assertEquals(CompanySchema.attrs, fields)
Пример #4
0
 def test_handle_cancel(self):
     from seantisinvoice.views.company import CompanyController
     from seantisinvoice import statusmessage
     # Register route for redirect in company form actions
     testing.registerRoute('/', 'invoices', factory=None)
     request = testing.DummyRequest()
     request.environ['qc.statusmessage'] = []
     view = CompanyController(None, request)
     view.handle_cancel()
     msgs = statusmessage.messages(request)
     self.assertEquals(1, len(msgs))
     self.assertEquals(u"No changes saved.", msgs[0].msg)
Пример #5
0
    def test_handle_cancel(self):
        from seantisinvoice.views.company import CompanyController
        from seantisinvoice import statusmessage

        # Register route for redirect in company form actions
        testing.registerRoute("/", "invoices", factory=None)
        request = testing.DummyRequest()
        request.environ["qc.statusmessage"] = []
        view = CompanyController(None, request)
        view.handle_cancel()
        msgs = statusmessage.messages(request)
        self.assertEquals(1, len(msgs))
        self.assertEquals(u"No changes saved.", msgs[0].msg)
Пример #6
0
 def test_call(self):
     from seantisinvoice.views.company import CompanyController
     request = testing.DummyRequest()
     view = CompanyController(None, request)
     result = view()
     self.failUnless('main' in result.keys())
     self.failUnless('msgs' in result.keys())
Пример #7
0
    def test_handle_submit(self):
        from seantisinvoice.views.company import CompanyController
        from seantisinvoice import statusmessage

        # Register route for redirect in company form actions
        testing.registerRoute("/company", "company", factory=None)
        request = testing.DummyRequest()
        request.environ["qc.statusmessage"] = []
        view = CompanyController(None, request)
        # All defaults must initially be empty
        default_values = view.form_defaults()
        self.assertEquals(None, default_values["name"])
        # Set all required fields
        self._set_company_profile()
        # Defaults must be set
        default_values = view.form_defaults()
        self.assertEquals(u"Example Inc.", default_values["name"])
        # Change company name through the form
        view.handle_submit(dict(name=u"Seantis GmbH"))
        default_values = view.form_defaults()
        self.assertEquals(u"Seantis GmbH", default_values["name"])
        # Check status message
        msgs = statusmessage.messages(request)
        self.assertEquals(1, len(msgs))
        self.assertEquals(u"Changes saved.", msgs[0].msg)
        # Submit without changing anything
        view.handle_submit(default_values)
        msgs = statusmessage.messages(request)
        self.assertEquals(1, len(msgs))
        self.assertEquals(u"No changes saved.", msgs[0].msg)
        # Logo upload
        from os.path import join, dirname
        from schemaish.type import File

        logo_path = join(dirname(__file__), "views", "templates", "static", "uploads", "test_logo.jpg")
        default_values["logo"] = File(open(logo_path, "rb"), "logo.jpg", "image/jpeg")
        view.handle_submit(default_values)
Пример #8
0
 def test_form_widgets(self):
     from seantisinvoice.views.company import CompanyController
     request = testing.DummyRequest()
     view = CompanyController(None, request)
     widgets = view.form_widgets(view.form_fields())
     self.assertEquals(2, len(widgets['invoice_template'].options))
Пример #9
0
 def test_handle_submit(self):
     from seantisinvoice.views.company import CompanyController
     from seantisinvoice import statusmessage
     # Register route for redirect in company form actions
     testing.registerRoute('/company', 'company', factory=None)
     request = testing.DummyRequest()
     request.environ['qc.statusmessage'] = []
     view = CompanyController(None, request)
     # All defaults must initially be empty
     default_values = view.form_defaults()
     self.assertEquals(None, default_values['name'])
     # Set all required fields
     self._set_company_profile()
     # Defaults must be set
     default_values = view.form_defaults()
     self.assertEquals(u'Example Inc.', default_values['name'])
     # Change company name through the form
     view.handle_submit(dict(name=u'Seantis GmbH'))
     default_values = view.form_defaults()
     self.assertEquals(u'Seantis GmbH', default_values['name'])
     # Check status message
     msgs = statusmessage.messages(request)
     self.assertEquals(1, len(msgs))
     self.assertEquals(u"Changes saved.", msgs[0].msg)
     # Submit without changing anything
     view.handle_submit(default_values)
     msgs = statusmessage.messages(request)
     self.assertEquals(1, len(msgs))
     self.assertEquals(u"No changes saved.", msgs[0].msg)
     # Logo upload
     from os.path import join, dirname
     from schemaish.type import File
     logo_path = join(dirname(__file__), 'views', 'templates', 'static',
                      'uploads', 'test_logo.jpg')
     default_values['logo'] = File(open(logo_path, 'rb'), 'logo.jpg',
                                   'image/jpeg')
     view.handle_submit(default_values)