File: test_executors.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 (35 lines) | stat: -rw-r--r-- 967 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
30
31
32
33
34
35
import pytest
from django.core import management


@pytest.fixture(autouse=True)
def _setup(TenantModel, DomainModel, db):
    if TenantModel is None:
        pytest.skip("Dynamic tenants are not in use")

    tenants = []

    for i in range(10, 20):
        tenant = TenantModel(schema_name=f"tenant{i + 1}")
        tenant.save(verbosity=0)
        if DomainModel:
            DomainModel.objects.create(
                tenant=tenant, domain=f"tenant{i + 1}.localhost", is_primary=True
            )

        tenants.append(tenant)

    yield

    for tenant in tenants:
        tenant.delete(force_drop=True)


def test_all_schemas_in_sequential():
    # If there are no errors, then this test passed
    management.call_command("migrate", all_schemas=True, parallel=False, verbosity=0)


def test_all_schemas_in_parallel():
    # If there are no errors, then this test passed
    management.call_command("migrate", all_schemas=True, parallel=True, verbosity=0)