"""Run from the supplied project's lessons folder; data is temporary.""" from pathlib import Path import sys lesson_folder = Path(__file__).resolve().parent # A lesson filename must not shadow an installed package such as whitenoise. sys.path = [entry for entry in sys.path if Path(entry or ".").resolve() != lesson_folder] sys.path.insert(0, str(lesson_folder.parent)) from lab_support import start start() from workshops.models import Venue, Workshop, Reservation from django.test import Client, RequestFactory, override_settings # Lesson code: the shared lab is ready, with three fictional workshops. from django.db import connection from django.db.migrations.executor import MigrationExecutor executor = MigrationExecutor(connection) executor.migrate([("workshops", "0001_initial")]) old_apps = executor.loader.project_state([("workshops", "0001_initial")]).apps old_venue = old_apps.get_model("workshops", "Venue") print(old_venue.objects.get(code="river-hall").name) MigrationExecutor(connection).migrate([("workshops", "0002_venue_access_note")]) print(Venue.objects.get(code="river-hall").access_note == "")