File: test_config.py

package info (click to toggle)
python-django-pgtransaction 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 504 kB
  • sloc: python: 551; makefile: 101; sh: 9
file content (23 lines) | stat: -rw-r--r-- 604 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
try:
    import psycopg.errors as psycopg_errors
except ImportError:
    import psycopg2.errors as psycopg_errors

from pgtransaction import config


def test_retry_exceptions(settings):
    assert config.retry_exceptions() == (
        psycopg_errors.SerializationFailure,
        psycopg_errors.DeadlockDetected,
    )

    settings.PGTRANSACTION_RETRY_EXCEPTIONS = [psycopg_errors.DeadlockDetected]
    assert config.retry_exceptions() == [psycopg_errors.DeadlockDetected]


def test_retry(settings):
    assert config.retry() == 0

    settings.PGTRANSACTION_RETRY = 1
    assert config.retry() == 1