@pytest.mark.parametrize('sp_model,extra_inputs', [(CustomCarrier, []), (CustomPaymentProcessor, ['rounding_quantize']), (PseudoPaymentProcessor, ['bg_color', 'fg_color'])])
def test_service_provide_edit_view(rf, admin_user, sp_model, extra_inputs):
 with override_settings(LANGUAGES=[('en', 'en')]):
  base_inputs = ['csrfmiddlewaretoken', 'name__en', 'enabled', 'logo']
  get_default_shop()
  view = ServiceProviderEditView.as_view()
  provider_name = 'some name'
  service_provider = sp_model.objects.create(name=provider_name)
  soup = get_bs_object_for_view(rf.get('/'), view, admin_user, object=service_provider)
  provider_form = soup.find('form', attrs={'id': 'service_provider_form'})
  rendered_fields = []
  for input_field in provider_form.findAll('input'):
   rendered_fields.append(input_field['name'])
  assert (rendered_fields == (base_inputs + extra_inputs))
  assert (provider_form.find('input', attrs={'name': 'name__en'})['value'] == provider_name)

@ pytest . mark . parametrize ( 'sp_model,extra_inputs' , [ ( CustomCarrier , [ ] ) , ( CustomPaymentProcessor , [ 'rounding_quantize' ] ) , ( PseudoPaymentProcessor , [ 'bg_color' , 'fg_color' ] ) ] ) def test_service_provide_edit_view ( rf , admin_user , sp_model , extra_inputs ) : with override_settings ( LANGUAGES = [ ( 'en' , 'en' ) ] ) : base_inputs = [ 'csrfmiddlewaretoken' , 'name__en' , 'enabled' , 'logo' ] get_default_shop ( ) view = ServiceProviderEditView . as_view ( ) provider_name = 'some name' service_provider = sp_model . objects . create ( name = provider_name ) soup = get_bs_object_for_view ( rf . get ( '/' ) , view , admin_user , object = service_provider ) provider_form = soup . find ( 'form' , attrs = { 'id' : 'service_provider_form' } ) rendered_fields = [ ] for input_field in provider_form . findAll ( 'input' ) : rendered_fields . append ( input_field [ 'name' ] ) assert ( rendered_fields == ( base_inputs + extra_inputs ) ) assert ( provider_form . find ( 'input' , attrs = { 'name' : 'name__en' } ) [ 'value' ] == provider_name )
test that serviceprovideeditview works with existing serviceprovider subclasses to make things little bit more simple lets use only english as an language .