Closed gamesbook closed 3 years ago
The correct way to test is with reverse url
def test_action_create_site_activity_no_form(self):
"""create_site_activity(self, request, queryset)"""
siteA = site.make(code='SiteA')
siteB = site.make(code='SiteB')
sas = activity.make(name='ActivityTest')
queryset = models.Site.objects.filter(code__icontains='Site')
items = [site.id for site in queryset]
# run action NO data
data = {'action': 'create_site_activity', '_selected_action': items}
change_url = reverse('admin:locales_site_changelist')
response = self.client.post(change_url, data, follow=True)
print('response:', response.content)
assert response.status_code == 200
If this is a bug please specify versions you're using first.
Django version: 1.11.29 Django Suit version: 2.0a1 Python version: 3.7.7
Issue:
I am unable to test admin actions. The basic issue seems to be that the request does not contain the apps for the suit menu (via
admin.site.each_context(request)
) so the test cannot run.Below is a slightly abbreviated copy of the code as well as the stacktrace. Not sure what I need to add / change?
The action:
The test:
The test fails with this trace: