コード例 #1
0
def customer(config, content, get_csrf_request_with_db, company):
    config.add_route('customer', '/')
    request = get_csrf_request_with_db()
    request.context = company
    request.user = Dummy()
    view = CustomerAdd(request)
    view.submit_success(APPSTRUCT)
    return getOne()
コード例 #2
0
 def test_is_company_form(self, get_csrf_request_with_db):
     pyramid_request = get_csrf_request_with_db(
         post={'__formid__': 'company'}
     )
     view = CustomerAdd(pyramid_request)
     assert view.is_company_form()
     pyramid_request.POST = {'__formid__': 'individual'}
     view = CustomerAdd(pyramid_request)
     assert not view.is_company_form()
コード例 #3
0
def customer(config, content, get_csrf_request_with_db):
    config.add_route('customer', '/')
    request = get_csrf_request_with_db()
    comp = Company.query().first()
    comp.__name__ = 'company'
    request.context = comp
    request.user = Dummy()
    view = CustomerAdd(request)
    view.submit_success(APPSTRUCT)
    return getOne()
コード例 #4
0
ファイル: test_customer.py プロジェクト: w3bcr4ft/autonomie
def customer(config, content, get_csrf_request_with_db):
    config.add_route('customer', '/')
    request = get_csrf_request_with_db()
    comp = Company.query().first()
    comp.__name__ = 'company'
    request.context = comp
    request.user = get_user()
    view = CustomerAdd(request)
    view.submit_success(APPSTRUCT)
    return getOne()
コード例 #5
0
    def test_schema(self, get_csrf_request_with_db):
        pyramid_request = get_csrf_request_with_db(
            post={'__formid__': 'company'})
        view = CustomerAdd(pyramid_request)
        schema = view.schema
        assert schema['name'].missing == colander.required

        pyramid_request.POST = {'__formid__': 'individual'}
        view = CustomerAdd(pyramid_request)
        schema = view.schema
        assert schema['civilite'].missing == colander.required
コード例 #6
0
    def test_submit_company_success(self, config, get_csrf_request_with_db,
                                    company):
        config.add_route('customer', '/')
        pyramid_request = get_csrf_request_with_db(
            post={'__formid__': 'company'})
        pyramid_request.context = company

        view = CustomerAdd(pyramid_request)
        view.submit_success(COMPANY_APPSTRUCT)
        customer = get_company_customer()
        for key, value in COMPANY_APPSTRUCT.items():
            assert getattr(customer, key) == value
        assert customer.type_ == 'company'
        assert customer.company == company
コード例 #7
0
    def test_submit_individual_success(self, config, get_csrf_request_with_db,
                                       company):
        config.add_route('customer', '/')
        pyramid_request = get_csrf_request_with_db(
            post={'__formid__': 'individual'})
        pyramid_request.context = company

        view = CustomerAdd(pyramid_request)
        view.submit_success(INDIVIDUAL_APPSTRUCT)
        customer = get_individual_customer()
        for key, value in INDIVIDUAL_APPSTRUCT.items():
            assert getattr(customer, key) == value
        assert customer.type_ == 'individual'
        assert customer.company == company
        assert customer.label == customer._get_label()
コード例 #8
0
    def test_submit_company_success(
        self, config, get_csrf_request_with_db, company
    ):
        config.add_route('customer', '/')
        pyramid_request = get_csrf_request_with_db(
            post={'__formid__': 'company'}
        )
        pyramid_request.context = company

        view = CustomerAdd(pyramid_request)
        view.submit_success(COMPANY_APPSTRUCT)
        customer = get_company_customer()
        for key, value in COMPANY_APPSTRUCT.items():
            assert getattr(customer, key) == value
        assert customer.type_ == 'company'
        assert customer.company == company
コード例 #9
0
    def test_submit_individual_success(
        self, config, get_csrf_request_with_db, company
    ):
        config.add_route('customer', '/')
        pyramid_request = get_csrf_request_with_db(
            post={'__formid__': 'individual'}
        )
        pyramid_request.context = company

        view = CustomerAdd(pyramid_request)
        view.submit_success(INDIVIDUAL_APPSTRUCT)
        customer = get_individual_customer()
        for key, value in INDIVIDUAL_APPSTRUCT.items():
            assert getattr(customer, key) == value
        assert customer.type_ == 'individual'
        assert customer.company == company
        assert customer.label == customer._get_label()
コード例 #10
0
 def test_is_company_form(self, get_csrf_request_with_db):
     pyramid_request = get_csrf_request_with_db(
         post={'__formid__': 'company'})
     view = CustomerAdd(pyramid_request)
     assert view.is_company_form()
     pyramid_request.POST = {'__formid__': 'individual'}
     view = CustomerAdd(pyramid_request)
     assert not view.is_company_form()