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()
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()
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()
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()
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
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
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()
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
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()
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()