@pytest.mark.django_db
@pytest.mark.parametrize('view,model,get_object,service_provider_attr', [(PaymentMethodEditView, PaymentMethod, get_default_payment_method, 'payment_processor'), (ShippingMethodEditView, ShippingMethod, get_default_shipping_method, 'carrier')])
def test_behavior_add_save(rf, admin_user, view, model, get_object, service_provider_attr):
 get_default_shop()
 with override_settings(LANGUAGES=[('en', 'en')]):
  object = get_object()
  view = view.as_view()
  service_provider_attr_field = ('base-%s' % service_provider_attr)
  data = get_default_data(object, service_provider_attr, service_provider_attr_field)
  components_before = object.behavior_components.count()
  assert (not components_before)
  request = apply_request_middleware(rf.post('/', data=data, user=admin_user))
  view(request, pk=object.pk)
  components_after = object.behavior_components.count()
  assert (components_after == len(get_default_behavior_settings()))

@ pytest . mark . django_db @ pytest . mark . parametrize ( 'view,model,get_object,service_provider_attr' , [ ( PaymentMethodEditView , PaymentMethod , get_default_payment_method , 'payment_processor' ) , ( ShippingMethodEditView , ShippingMethod , get_default_shipping_method , 'carrier' ) ] ) def test_behavior_add_save ( rf , admin_user , view , model , get_object , service_provider_attr ) : get_default_shop ( ) with override_settings ( LANGUAGES = [ ( 'en' , 'en' ) ] ) : object = get_object ( ) view = view . as_view ( ) service_provider_attr_field = ( 'base-%s' % service_provider_attr ) data = get_default_data ( object , service_provider_attr , service_provider_attr_field ) components_before = object . behavior_components . count ( ) assert ( not components_before ) request = apply_request_middleware ( rf . post ( '/' , data = data , user = admin_user ) ) view ( request , pk = object . pk ) components_after = object . behavior_components . count ( ) assert ( components_after == len ( get_default_behavior_settings ( ) ) )
to make things little bit more simple lets use only english as a language .