From 73f7107d6237016f5b1d99d37c940b52315dc4f7 Mon Sep 17 00:00:00 2001
From: Emmanuel Cazenave <ecazenave@entrouvert.com>
Date: Mon, 11 Jan 2021 17:33:42 +0100
Subject: [PATCH 4/7] change command parser option or invocation (#49283)

To be compliant with https://code.djangoproject.com/ticket/27787 : parser arguments now gets introspected when using call_command.
---
 hobo/multitenant/management/commands/__init__.py |  1 +
 tests_authentic/test_provisionning.py            | 10 +++++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/hobo/multitenant/management/commands/__init__.py b/hobo/multitenant/management/commands/__init__.py
index 5d6b70d..e51cb10 100644
--- a/hobo/multitenant/management/commands/__init__.py
+++ b/hobo/multitenant/management/commands/__init__.py
@@ -153,6 +153,7 @@ class SyncCommon(BaseCommand):
                     help=('Database state will be brought to the state after that '
                           'migration. Use the name "zero" to unapply all migrations.'))
         parser.add_argument("-d", "--domain", dest="domain")
+        parser.add_argument("-s", "--schema", dest="schema_name")
 
     def handle(self, *args, **options):
         self.domain = options.get('domain')
diff --git a/tests_authentic/test_provisionning.py b/tests_authentic/test_provisionning.py
index 211079a..f0dd7ab 100644
--- a/tests_authentic/test_provisionning.py
+++ b/tests_authentic/test_provisionning.py
@@ -475,7 +475,7 @@ def test_provision_createsuperuser(transactional_db, tenant, caplog):
                                        entity_id='http://provider.com',
                                        protocol_conformance=lasso.PROTOCOL_SAML_2_0)
     with patch('hobo.agent.authentic2.provisionning.notify_agents') as notify_agents:
-        call_command('createsuperuser', domain=tenant.domain_url, uuid='coin',
+        call_command('createsuperuser', domain=tenant.domain_url,
                      username='coin', email='coin@coin.org', interactive=False)
         assert notify_agents.call_count == 1
 
@@ -549,14 +549,14 @@ def test_provision_using_http(transactional_db, tenant, settings, caplog):
                                        entity_id='http://example.com',
                                        protocol_conformance=lasso.PROTOCOL_SAML_2_0)
     with patch('hobo.agent.authentic2.provisionning.notify_agents') as notify_agents:
-        call_command('createsuperuser', domain=tenant.domain_url, uuid='coin',
+        call_command('createsuperuser', domain=tenant.domain_url,
                      username='coin', email='coin@coin.org', interactive=False)
         assert notify_agents.call_count == 1
         assert set(notify_agents.call_args[0][0]['audience']) == {'http://example.org', 'http://example.com'}
 
     settings.HOBO_HTTP_PROVISIONNING = True
     with patch('hobo.agent.authentic2.provisionning.notify_agents') as notify_agents:
-        call_command('createsuperuser', domain=tenant.domain_url, uuid='coin2',
+        call_command('createsuperuser', domain=tenant.domain_url,
                      username='coin2', email='coin2@coin.org', interactive=False)
         assert notify_agents.call_count == 1
         assert set(notify_agents.call_args[0][0]['audience']) == {'http://example.org', 'http://example.com'}
@@ -574,7 +574,7 @@ def test_provision_using_http(transactional_db, tenant, settings, caplog):
     }
     with patch('hobo.agent.authentic2.provisionning.notify_agents') as notify_agents:
         with patch('hobo.agent.authentic2.provisionning.requests.put') as requests_put:
-            call_command('createsuperuser', domain=tenant.domain_url, uuid='coin2',
+            call_command('createsuperuser', domain=tenant.domain_url,
                          username='coin2', email='coin2@coin.org', interactive=False)
             assert notify_agents.call_count == 1
             assert notify_agents.call_args[0][0]['audience'] == ['http://example.com']
@@ -591,7 +591,7 @@ def test_provision_using_http(transactional_db, tenant, settings, caplog):
     }
     with patch('hobo.agent.authentic2.provisionning.notify_agents') as notify_agents:
         with patch('hobo.agent.authentic2.provisionning.requests.put') as requests_put:
-            call_command('createsuperuser', domain=tenant.domain_url, uuid='coin2',
+            call_command('createsuperuser', domain=tenant.domain_url,
                          username='coin2', email='coin2@coin.org', interactive=False)
             assert notify_agents.call_count == 0
             assert requests_put.call_count == 2
-- 
2.20.1

