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'

c0re Magazine – free mag about: software testing, software quality, process quality

c0re mag is a quite new magazine about testing, but it doesn’t mean that it’s not a professional one.
First issue in Polish was published on May and in English last October.

Quote from magazine home-site:

We are a new magazine for Testers and IT Experts. Our aim is to create a free magazine for all people interested in the field of Software Quality.

More info at:
http://www.coremag.eu/
http://twitter.com/c0remag

ps. if you like the mag, please spread the word ! 🙂

Robot attack!!!!!!! A short story about two test tools

I’ve just found out about two tools that can be really helpful for web testers.

According to authors:

Robot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD).

You can find more about Robot Framework at:
http://code.google.com/p/robotframework/wiki/IntroductionSlides

and about RIDE = Robot framework Integrated Development Environment (a Robot editor) at:
http://code.google.com/p/robotframework-ride/

RIDE - Robot IDE

Functional Test Automation

http://functionaltestautomation.blogspot.com/

[EN]
Above mentioned blog is dedicated to software functional test automation of web apps and not only. with special stress on selenium suite of tools, frameworks, methodologies and approach. It’s focused of usage of tools like: Selenium czy TestNG. I must say that in general author put quite a lot of his time for explore the area of web testing.  Concerning the blog essence you’ve to rate it yourself.


[PL]
Strona poświęcania automatyzacji funkcjonalnego testowania aplikacji webowych i nie tylko. Skupia się na wykorzysaniu narzędziach takich jak: Selenium czy TestNG. Generalnie widać, że autor zainwestował trochę czasu w zgłębienie tematu, co do merytoryki musicie ocenić sami.