Created
November 22, 2017 15:20
-
-
Save dlyapun/b06d4622ec7c34d4025b102a4ecb6d5c to your computer and use it in GitHub Desktop.
Test Django admin actions save_model save_related
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.urlresolvers import reverse | |
from django.test import TestCase, Client | |
from django.contrib.admin.sites import AdminSite | |
from gloodny.models import * | |
from django.forms.models import model_to_dict | |
class ChangeHistoryTests(TestCase): | |
fixtures = ['init_gloodny.json'] | |
def setUp(self): | |
self.site = AdminSite() | |
self.meal = Meal.objects.first() | |
self.client = Client() | |
self.client.login(username='root', password='qwerty1003') | |
def test_change_meal(self): | |
"""Check that the endpoint correctly adds a voucher.""" | |
print self.meal | |
url = reverse('admin:gloodny_meal_change', args=(self.meal.id,)) | |
data = model_to_dict(self.meal) | |
data['_save'] = 'save' | |
data['title'] = 'NEW TITLE' | |
response = self.client.post(url, data) | |
print self.meal | |
self.assertEqual(1, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment