mirror of
https://github.com/ansible/awx.git
synced 2026-07-01 19:38:03 -02:30
Squash a few deprecation warnings
- inspect.getargspec() -> inspect.getfullargspec() - register pytest.mark.fixture_args - replace use of DRF's deprecated NullBooleanField - fix some usage of naive datetimes in the tests - fix some strings with backslashes that ought to be raw strings
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from . import jobs, receptor, system # noqa
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
import base64
|
||||
import json
|
||||
import re
|
||||
from datetime import datetime
|
||||
from unittest import mock
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import smart_str
|
||||
from unittest import mock
|
||||
from django.utils.timezone import now as tz_now
|
||||
|
||||
import pytest
|
||||
|
||||
from awx.api.versioning import reverse
|
||||
@@ -146,7 +147,7 @@ def test_stdout_line_range(sqlite_copy_expert, Parent, Child, relation, view, ge
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_text_stdout_from_system_job_events(sqlite_copy_expert, get, admin):
|
||||
created = datetime.utcnow()
|
||||
created = tz_now()
|
||||
job = SystemJob(created=created)
|
||||
job.save()
|
||||
for i in range(3):
|
||||
@@ -158,7 +159,7 @@ def test_text_stdout_from_system_job_events(sqlite_copy_expert, get, admin):
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_text_stdout_with_max_stdout(sqlite_copy_expert, get, admin):
|
||||
created = datetime.utcnow()
|
||||
created = tz_now()
|
||||
job = SystemJob(created=created)
|
||||
job.save()
|
||||
total_bytes = settings.STDOUT_MAX_BYTES_DISPLAY + 1
|
||||
@@ -185,7 +186,7 @@ def test_text_stdout_with_max_stdout(sqlite_copy_expert, get, admin):
|
||||
@pytest.mark.parametrize('fmt', ['txt', 'ansi'])
|
||||
@mock.patch('awx.main.redact.UriCleaner.SENSITIVE_URI_PATTERN', mock.Mock(**{'search.return_value': None})) # really slow for large strings
|
||||
def test_max_bytes_display(sqlite_copy_expert, Parent, Child, relation, view, fmt, get, admin):
|
||||
created = datetime.utcnow()
|
||||
created = tz_now()
|
||||
job = Parent(created=created)
|
||||
job.save()
|
||||
total_bytes = settings.STDOUT_MAX_BYTES_DISPLAY + 1
|
||||
@@ -267,7 +268,7 @@ def test_text_with_unicode_stdout(sqlite_copy_expert, Parent, Child, relation, v
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_unicode_with_base64_ansi(sqlite_copy_expert, get, admin):
|
||||
created = datetime.utcnow()
|
||||
created = tz_now()
|
||||
job = Job(created=created)
|
||||
job.save()
|
||||
for i in range(3):
|
||||
|
||||
@@ -788,7 +788,7 @@ class TestJobCredentials(TestJobExecution):
|
||||
password_prompts = task.get_password_prompts(passwords)
|
||||
expect_passwords = task.create_expect_passwords_data_struct(password_prompts, passwords)
|
||||
|
||||
assert expect_passwords['Vault password:\s*?$'] == 'vault-me' # noqa
|
||||
assert expect_passwords[r'Vault password:\s*?$'] == 'vault-me' # noqa
|
||||
assert '--ask-vault-pass' in ' '.join(args)
|
||||
|
||||
def test_vault_password_ask(self, private_data_dir, job, mock_me):
|
||||
@@ -803,7 +803,7 @@ class TestJobCredentials(TestJobExecution):
|
||||
password_prompts = task.get_password_prompts(passwords)
|
||||
expect_passwords = task.create_expect_passwords_data_struct(password_prompts, passwords)
|
||||
|
||||
assert expect_passwords['Vault password:\s*?$'] == 'provided-at-launch' # noqa
|
||||
assert expect_passwords[r'Vault password:\s*?$'] == 'provided-at-launch' # noqa
|
||||
assert '--ask-vault-pass' in ' '.join(args)
|
||||
|
||||
def test_multi_vault_password(self, private_data_dir, job, mock_me):
|
||||
@@ -820,10 +820,10 @@ class TestJobCredentials(TestJobExecution):
|
||||
expect_passwords = task.create_expect_passwords_data_struct(password_prompts, passwords)
|
||||
|
||||
vault_passwords = dict((k, v) for k, v in expect_passwords.items() if 'Vault' in k)
|
||||
assert vault_passwords['Vault password \(prod\):\\s*?$'] == 'pass@prod' # noqa
|
||||
assert vault_passwords['Vault password \(dev\):\\s*?$'] == 'pass@dev' # noqa
|
||||
assert vault_passwords['Vault password \(dotted.name\):\\s*?$'] == 'pass@dotted.name' # noqa
|
||||
assert vault_passwords['Vault password:\\s*?$'] == '' # noqa
|
||||
assert vault_passwords[r'Vault password \(prod\):\s*?$'] == 'pass@prod' # noqa
|
||||
assert vault_passwords[r'Vault password \(dev\):\s*?$'] == 'pass@dev' # noqa
|
||||
assert vault_passwords[r'Vault password \(dotted.name\):\s*?$'] == 'pass@dotted.name' # noqa
|
||||
assert vault_passwords[r'Vault password:\s*?$'] == '' # noqa
|
||||
assert '--ask-vault-pass' not in ' '.join(args)
|
||||
assert '--vault-id dev@prompt' in ' '.join(args)
|
||||
assert '--vault-id prod@prompt' in ' '.join(args)
|
||||
@@ -855,9 +855,9 @@ class TestJobCredentials(TestJobExecution):
|
||||
expect_passwords = task.create_expect_passwords_data_struct(password_prompts, passwords)
|
||||
|
||||
vault_passwords = dict((k, v) for k, v in expect_passwords.items() if 'Vault' in k)
|
||||
assert vault_passwords['Vault password \(prod\):\\s*?$'] == 'provided-at-launch@prod' # noqa
|
||||
assert vault_passwords['Vault password \(dev\):\\s*?$'] == 'provided-at-launch@dev' # noqa
|
||||
assert vault_passwords['Vault password:\\s*?$'] == '' # noqa
|
||||
assert vault_passwords[r'Vault password \(prod\):\s*?$'] == 'provided-at-launch@prod' # noqa
|
||||
assert vault_passwords[r'Vault password \(dev\):\s*?$'] == 'provided-at-launch@dev' # noqa
|
||||
assert vault_passwords[r'Vault password:\s*?$'] == '' # noqa
|
||||
assert '--ask-vault-pass' not in ' '.join(args)
|
||||
assert '--vault-id dev@prompt' in ' '.join(args)
|
||||
assert '--vault-id prod@prompt' in ' '.join(args)
|
||||
|
||||
@@ -198,7 +198,7 @@ def vars_validate_or_raise(vars_str):
|
||||
|
||||
|
||||
def validate_container_image_name(value):
|
||||
"""
|
||||
r"""
|
||||
from https://github.com/distribution/distribution/blob/af8ac809336c2316c81b08605d92d94f8670ad15/reference/reference.go#L4
|
||||
|
||||
Grammar
|
||||
|
||||
Reference in New Issue
Block a user