File: test_postgresql_specific.py

package info (click to toggle)
django-dirtyfields 1.3.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 276 kB
  • sloc: python: 812; makefile: 168
file content (22 lines) | stat: -rw-r--r-- 618 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pytest

from tests.utils import is_postgresql_env_with_json_field


@pytest.mark.skipif(not is_postgresql_env_with_json_field(),
                    reason="requires postgresql and Django 1.9+")
@pytest.mark.django_db
def test_dirty_json_field():
    from tests.models import TestModelWithJSONField

    tm = TestModelWithJSONField.objects.create(json_field={'data': [1, 2, 3]})

    data = tm.json_field['data']
    data.append(4)

    assert tm.get_dirty_fields(verbose=True) == {
        'json_field': {
            'current': {'data': [1, 2, 3, 4]},
            'saved': {'data': [1, 2, 3]}
        }
    }