Skip to content
Learn Netverks

Lesson

Step 31/36 86% through track

testing-intro

Testing introduction

Last reviewed May 28, 2026 Content v20260528
Track mode
server_script
Means
Server runner
Reading
~1 min
Level
advanced

This lesson

An orientation to the Django track—how the server playground works, core vocabulary, and what you will practice next.

You need a clear map of the Django track so MVT, the ORM, and project layout do not feel like magic.

You will apply Testing introduction in contexts like: SaaS dashboards, CMS-style products, internal tools, and APIs paired with React or mobile clients.

Write Python 3 in the editor and click Run on server—the dev runner executes your script; Django framework lessons also use local startproject for full MVT (LEARNING_RUNNER_ENABLED=true). Also read the interview prep blocks.

After HTML fundamentals and basic programming concepts—before or alongside SQL.

Django includes a test framework built on Python's unittest (and pytest-django in many teams). Test models, views, forms, and APIs to catch regressions before deploy.

Test client

from django.test import TestCase, Client

class ArticleTests(TestCase):
    def test_index_returns_200(self):
        response = self.client.get("/")
        self.assertEqual(response.status_code, 200)

What to test

  • Model methods and validation
  • Forms—valid/invalid data
  • Views—status codes, redirects, context
  • Permissions—anonymous vs authenticated

Important interview questions and answers

  1. Q: Test database?
    A: Django creates a separate test DB—tests can run transactions rolled back per test.
  2. Q: fixtures vs factories?
    A: Fixtures are static JSON; factories (factory_boy) generate test data programmatically—factories scale better.
  3. Q: Integration vs unit?
    A: Unit tests isolate logic; integration tests hit DB and URL routing—balance speed and confidence.

Self-check

  1. What does Django's test Client simulate?
  2. Why test permission rules?

Tip: Test permission denials (403/redirect) alongside happy paths—auth bugs are common and cheap to catch with Client tests.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs on the configured server runner (dev: npm run runner with LEARNING_RUNNER_ENABLED=true). Output appears below the editor.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Client test POST?
  • Factory for fixtures?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump