Working with databases always have some challenges. The main problem is if we run tests against real database it can get flooded with fake data and yes you going to run apps against test environments which includes database specifically for that. But in Django there is cleaner way of doing it.

So instead of using test environments which mainly used by QA team lets create a test where on each run we going to spin up test database and once the tests finish we going to destroy it. In our test we going to use AAA (Arrange Act Assert) model, so here is how to do it:

# report/tests.py
from django.test import TestCase
from .models import Report

class ReportModelTest(TestCase):
    
    def setUp(self):
        Report.objects.create(fake_report='here is your report')
     
    def test_fake_report_content(self):
        report=Report.objects.get(id=1)
        expected_object_text = f'{report.fake_report}'
        self.assertEqual(expected_object_text, 'here is your report')

Lets take a closer look what we doing here. In our report app we have a file named tests.py, which we testing our report database model we name the test class ReportModelTest which extends TestCase class provided by Django. First thing first we need set up our fake data base, in the setUp function we call it fake_report and adding text field in it. Now we are ready to test our model. Get report object with id=1, then we need to retrieve expected object text from database. And last step is to compare expected_object_text with the text we provided.