File: test_timestamped_model.py

package info (click to toggle)
python-django-extensions 4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,820 kB
  • sloc: python: 18,601; javascript: 7,354; makefile: 108; xml: 17
file content (25 lines) | stat: -rw-r--r-- 583 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- coding: utf-8 -*-
import time
from django.test import TestCase

from .testapp.models import TimestampedTestModel


class ModifiedFieldTest(TestCase):
    def test_update(self):
        t = TimestampedTestModel.objects.create()
        modified = t.modified

        time.sleep(1)

        t.save()
        self.assertNotEqual(modified, t.modified)

    def test_update_no_modified(self):
        t = TimestampedTestModel.objects.create()
        modified = t.modified

        time.sleep(1)

        t.save(update_modified=False)
        self.assertEqual(modified, t.modified)