Skip to content

Instantly share code, notes, and snippets.

View bastien34's full-sized avatar

Bastien Roques bastien34

View GitHub Profile
@dkarchmer
dkarchmer / django_request_factory_test.py
Last active September 20, 2023 06:19
Sample code for using RequestFactory to do Django Unit Testing - Get and Post
from django.test import TestCase, RequestFactory
from django.utils.importlib import import_module
from django.contrib.auth import get_user_model
from django.core.urlresolvers import reverse
from django.contrib.sessions.middleware import SessionMiddleware
from django.contrib.messages.middleware import MessageMiddleware
from rest_framework import status
from .models import *
@davebridges
davebridges / django-view-tests.py
Created September 7, 2012 13:48
Sample View Tests for a Django App
"""This file contains tests for views."""
import datetime
from django.test import TestCase
from django.test.client import Client
from django.contrib.auth.models import User
from app.models import SampleModel