@pytest.mark.django_db
def test_campaign_creation(rf, admin_user):
 with override_settings(LANGUAGES=[('en', 'en')]):
  view = BasketCampaignEditView.as_view()
  data = {'base-name': 'Test Campaign', 'base-public_name__en': 'Test Campaign', 'base-shop': get_default_shop().id, 'base-active': True, 'base-basket_line_text': 'Test campaign activated!'}
  campaigns_before = BasketCampaign.objects.count()
  request = apply_request_middleware(rf.post('/', data=data), user=admin_user)
  response = view(request, pk=None)
  assert (response.status_code in [200, 302])
  assert (BasketCampaign.objects.count() == (campaigns_before + 1))

@ pytest . mark . django_db def test_campaign_creation ( rf , admin_user ) : with override_settings ( LANGUAGES = [ ( 'en' , 'en' ) ] ) : view = BasketCampaignEditView . as_view ( ) data = { 'base-name' : 'Test Campaign' , 'base-public_name__en' : 'Test Campaign' , 'base-shop' : get_default_shop ( ) . id , 'base-active' : True , 'base-basket_line_text' : 'Test campaign activated!' } campaigns_before = BasketCampaign . objects . count ( ) request = apply_request_middleware ( rf . post ( '/' , data = data ) , user = admin_user ) response = view ( request , pk = None ) assert ( response . status_code in [ 200 , 302 ] ) assert ( BasketCampaign . objects . count ( ) == ( campaigns_before + 1 ) )
to make things little bit more simple lets use only english as a language .