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:

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

and your function based view looks like this:

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['field'] ==  'value'

Test your knowledge

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.

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]

[java script / jQuery quizzes]