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.
This commit is contained in:
Emmanuel Cazenave 2021-01-11 17:33:42 +01:00
parent 7eedc0bbcc
commit 446788ece6
2 changed files with 6 additions and 5 deletions

View File

@ -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')

View File

@ -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