mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 15:21:13 +03:00
Remove some unneeded func tests for instances
This commit is contained in:
parent
27ddb7392b
commit
5186e7d8b4
@ -11,7 +11,6 @@ from django.core.management import call_command
|
||||
from awx.main.models import Instance
|
||||
|
||||
from awx.main.management.commands.update_password import UpdatePassword
|
||||
from awx.main.management.commands.remove_instance import Command as RemoveInstance
|
||||
|
||||
def run_command(name, *args, **options):
|
||||
command_runner = options.pop('command_runner', call_command)
|
||||
@ -54,22 +53,3 @@ def test_update_password_command(mocker, username, password, expected, changed):
|
||||
assert stdout == expected
|
||||
else:
|
||||
assert str(result) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"primary,hostname,startswith,exception", [
|
||||
(True, "127.0.0.1", "Cannot remove primary", None),
|
||||
(False, "127.0.0.2", "Successfully removed", None),
|
||||
(False, "127.0.0.3", "No matching instance", Instance.DoesNotExist),
|
||||
]
|
||||
)
|
||||
def test_remove_instance_command(mocker, primary, hostname, startswith, exception):
|
||||
mock_instance = mocker.MagicMock(primary=primary, enforce_unique_find=True)
|
||||
with mocker.patch.object(Instance.objects, 'get', return_value=mock_instance, side_effect=exception):
|
||||
with mocker.patch.object(RemoveInstance, 'include_option_hostname_uuid_find'):
|
||||
with mocker.patch.object(RemoveInstance, 'get_unique_fields', return_value={'hostname':hostname, 'uuid':1}):
|
||||
result, stdout, stderr = run_command("remove_instance", hostname=hostname)
|
||||
if result is None:
|
||||
assert stdout.startswith(startswith)
|
||||
else:
|
||||
assert str(result).startswith(startswith)
|
||||
|
Loading…
Reference in New Issue
Block a user