File: test_cache.py

package info (click to toggle)
python-django-pgschemas 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 848 kB
  • sloc: python: 3,887; makefile: 33; sh: 10; sql: 2
file content (29 lines) | stat: -rw-r--r-- 728 bytes parent folder | download | duplicates (2)
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
26
27
28
29
from django_pgschemas.contrib.cache import make_key, reverse_key
from django_pgschemas.schema import Schema


def test_make_key_with_dynamic_tenant(tenant1):
    with tenant1:
        key = make_key(key="foo", key_prefix="", version=1)

    chunks = key.split(":")

    assert len(chunks) == 4
    assert str(tenant1.schema_name) == chunks[0]


def test_make_key_with_static_tenant():
    with Schema.create(schema_name="www"):
        key = make_key(key="foo", key_prefix="", version=1)

    chunks = key.split(":")

    assert len(chunks) == 4
    assert "www" == chunks[0]


def test_reverse_key(tenant1):
    key = "some-key"

    with tenant1:
        assert key == reverse_key(make_key(key=key, key_prefix="", version=1))