@pytest.mark.django_db
def test_campaign_edit_save(rf, admin_user):
 with override_settings(LANGUAGES=[(u'en', u'en')]):
  shop = get_default_shop()
  object = CatalogCampaign.objects.create(name=u'test campaign', active=True, shop=shop)
  object.save()
  view = CatalogCampaignEditView.as_view()
  new_name = u'Test Campaign'
  new_end_datetime = datetime.datetime(year=2016, month=6, day=20)
  assert (object.name != new_name)
  assert (object.end_datetime is None)
  data = {u'base-name': new_name, u'base-public_name__en': u'Test Campaign', u'base-shop': get_default_shop().id, u'base-active': True, u'base-basket_line_text': u'Test campaign activated!', u'base-start_datetime': datetime.datetime(year=2016, month=6, day=19), u'base-end_datetime': new_end_datetime}
  methods_before = CatalogCampaign.objects.count()
  with override_provides(u'campaign_context_condition', []):
   with override_provides(u'campaign_catalog_filter', []):
    with override_provides(u'campaign_product_discount_effect_form', []):
     request = apply_request_middleware(rf.post(u'/', data=data), user=admin_user)
     response = view(request, pk=object.pk)
     assert (response.status_code in [200, 302])
  assert (CatalogCampaign.objects.count() == methods_before)
  updated_object = CatalogCampaign.objects.get(pk=object.pk)
  assert (updated_object.name == new_name)
  assert (updated_object.end_datetime == new_end_datetime.replace(tzinfo=pytz.UTC))

@ pytest . mark . django_db def test_campaign_edit_save ( rf , admin_user ) : with override_settings ( LANGUAGES = [ ( u'en' , u'en' ) ] ) : shop = get_default_shop ( ) object = CatalogCampaign . objects . create ( name = u'test campaign' , active = True , shop = shop ) object . save ( ) view = CatalogCampaignEditView . as_view ( ) new_name = u'Test Campaign' new_end_datetime = datetime . datetime ( year = 2016 , month = 6 , day = 20 ) assert ( object . name != new_name ) assert ( object . end_datetime is None ) data = { u'base-name' : new_name , u'base-public_name__en' : u'Test Campaign' , u'base-shop' : get_default_shop ( ) . id , u'base-active' : True , u'base-basket_line_text' : u'Test campaign activated!' , u'base-start_datetime' : datetime . datetime ( year = 2016 , month = 6 , day = 19 ) , u'base-end_datetime' : new_end_datetime } methods_before = CatalogCampaign . objects . count ( ) with override_provides ( u'campaign_context_condition' , [ ] ) : with override_provides ( u'campaign_catalog_filter' , [ ] ) : with override_provides ( u'campaign_product_discount_effect_form' , [ ] ) : request = apply_request_middleware ( rf . post ( u'/' , data = data ) , user = admin_user ) response = view ( request , pk = object . pk ) assert ( response . status_code in [ 200 , 302 ] ) assert ( CatalogCampaign . objects . count ( ) == methods_before ) updated_object = CatalogCampaign . objects . get ( pk = object . pk ) assert ( updated_object . name == new_name ) assert ( updated_object . end_datetime == new_end_datetime . replace ( tzinfo = pytz . UTC ) )
to make things little bit more simple lets use only english as a language .