Skip to content

Commit

Permalink
Added simplistic test to executors
Browse files Browse the repository at this point in the history
  • Loading branch information
lorinkoz committed Apr 21, 2020
1 parent cedc058 commit e38dab6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
3 changes: 2 additions & 1 deletion django_pgschemas/management/commands/whowill.py
Expand Up @@ -6,4 +6,5 @@

class Command(TenantCommand):
def handle_tenant(self, tenant, *args, **options):
self.stdout.write(str(tenant.get_primary_domain() or tenant.schema_name))
if options["verbosity"] >= 1:
self.stdout.write(str(tenant.get_primary_domain() or tenant.schema_name))
37 changes: 37 additions & 0 deletions dpgs_sandbox/tests/test_executors.py
@@ -0,0 +1,37 @@
from django.conf import settings
from django.core import management
from django.db import connections
from django.test import TransactionTestCase

from django_pgschemas.utils import get_tenant_model, get_domain_model

TenantModel = get_tenant_model()
DomainModel = get_domain_model()


class ExecutorsTestCase(TransactionTestCase):
"""
Tests the executors.
"""

@classmethod
def setUpClass(cls):
for i in range(10):
tenant = TenantModel(schema_name="tenant{}".format(i + 1))
tenant.save(verbosity=0)
DomainModel.objects.create(tenant=tenant, domain="tenant{}.test.com".format(i + 1), is_primary=True)

@classmethod
def tearDownClass(cls):
for tenant in TenantModel.objects.all():
tenant.delete(force_drop=True)

def test_all_schemas_in_sequential(self):
# If there are no errors, then this test passed
management.call_command("migrate", all_schemas=True, executor="sequential", verbosity=0)
connections.close_all()

def test_all_schemas_in_parallel(self):
# If there are no errors, then this test passed
management.call_command("migrate", all_schemas=True, executor="parallel", verbosity=0)
connections.close_all()
1 change: 0 additions & 1 deletion dpgs_sandbox/tests/test_whowill_command.py
@@ -1,7 +1,6 @@
from io import StringIO

from django.core import management
from django.core.management.base import CommandError
from django.test import TransactionTestCase

from django_pgschemas.utils import get_tenant_model, get_domain_model
Expand Down

0 comments on commit e38dab6

Please sign in to comment.