How to unit test Django’s Function Based Views

Let’s assume than the URL pattern to your Function Based View is defined like that:
urls.py

urlpatterns = patterns(
    ...,
    url(r'^$', views.index, name='index'),
    ...
)

and your function based view looks like this:
views.py

@api_view(['GET'])
@permission_classes((AllowAny,))
def index(request):
    data = {
        'field': 'value'
    }
    return Response(data)

Then you can unit test such view by creating a minimal instance
of the HttpRequest and pass it to that view.
I tried to mock to test such view with the Mock library, by with no luck!!!
If case you know how to do it with Mock, then let me know!

def test_index_function_based_view():
    _request = HttpRequest()
    _request.method = 'GET'
    request = Request(_request)
    response = index(request)
    assert response.data['field'] ==  'value'

Test your knowledge

[EN]
During my current job search, I wanted to check what can they they ask me during job interviews in companies that are looking for an web/front-end developer etc. After browsing few post like “js/html/css interview questions”, I started to seek some knowledge tests, that can help me with rating my current knowledge and deficiencies in it. Below you can find list of few selected tests, I’ve encountered somewhere in net.


[PL]
Podczas moich obecnych poszukiwań pracy, chciałem sprawdzić czego wymaga się na rozmowach na stanowiska web / front-end developera itp.  Po przeszukaniu paru postów z serii “js/html/css/ interview questions”, zabrałem się za szukanie gotowych quizów, które ocenią obecny stan wiedzy i braki. Poniżej znajduje się lista wybranych testów na różnym poziomie zaawansowania, które uznałem za warte wymienienia.

[CSS quiz]
http://www.w3schools.com/quiztest/quiztest.asp?qtest=CSS

[java script / jQuery quizzes]
http://dhtmlkitchen.com/jstest/jquery/quiz.jsp
http://www.planetpdf.com/developer/article.asp?ContentID=6337
http://www.w3schools.com/js/js_quiz.asp
http://dean.edwards.name/weblog/2006/06/levels/