Created
September 16, 2016 09:29
-
-
Save wooyek/635b4d6fbd6cc23c61f1df288cece58e to your computer and use it in GitHub Desktop.
Django interview task
This file contains hidden or 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
# Make this test pass. | |
# Make sure the get method is tested and leave the assertions as they are. | |
from django.contrib import messages | |
from django.contrib.messages import constants | |
from django.http import HttpRequest | |
from django.http import HttpResponse | |
from django.test import SimpleTestCase | |
from django.views import View | |
class SomeMessagingView(View): | |
def get(self, request, *args, **kwargs): | |
messages.info(self.request, "Lore imspum.") | |
return HttpResponse("") | |
class SomeViewTests(SimpleTestCase): | |
def test(self): | |
request = HttpRequest() | |
view = SomeMessagingView(request=request) | |
response = view.get(request) | |
self.assertEqual(200, response.status_code) | |
self.assertTrue(request._messages.add.called) | |
request._messages.add.assert_called_once_with(constants.INFO, "Lore imspum.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment