mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Cleanup: remove unicode prefix, remove explicit inheritance from object (#11015)
* Address UP025: remove unicode literals from strings. * Address UP004: class inherits from 'object'.
This commit is contained in:
@@ -45,7 +45,7 @@ def access_mock(path, can_access=True):
|
||||
return access
|
||||
|
||||
|
||||
class HistoryEntry(object):
|
||||
class HistoryEntry:
|
||||
def __init__(self):
|
||||
self.SEQ = '384'
|
||||
self.HOSTNAME = 'sam-691-sam'
|
||||
@@ -57,7 +57,7 @@ class HistoryEntry(object):
|
||||
self.ACTION = '0'
|
||||
|
||||
|
||||
class HistoryRecords(object):
|
||||
class HistoryRecords:
|
||||
def __init__(self):
|
||||
self.HISTORY = [HistoryEntry()]
|
||||
|
||||
|
||||
@@ -84,33 +84,33 @@ VALID_QUOTES = ((test, VALID[test]) for test in sorted(VALID))
|
||||
INVALID_QUOTES = ((test[0], test[1], INVALID[test]) for test in sorted(INVALID))
|
||||
|
||||
IS_STRINGS_DANGEROUS = (
|
||||
(u'', False),
|
||||
(u' ', False),
|
||||
(u'alternative database', False),
|
||||
(u'backup of TRUNCATED table', False),
|
||||
(u'bob.dropper', False),
|
||||
(u'd\'artagnan', False),
|
||||
(u'user_with_select_update_truncate_right', False),
|
||||
(u';DROP DATABASE fluffy_pets_photos', True),
|
||||
(u';drop DATABASE fluffy_pets_photos', True),
|
||||
(u'; TRUNCATE TABLE his_valuable_table', True),
|
||||
(u'; truncate TABLE his_valuable_table', True),
|
||||
(u'\'--', True),
|
||||
(u'"--', True),
|
||||
(u'\' union select username, password from admin_credentials', True),
|
||||
(u'\' UNION SELECT username, password from admin_credentials', True),
|
||||
(u'\' intersect select', True),
|
||||
(u'\' INTERSECT select', True),
|
||||
(u'\' except select', True),
|
||||
(u'\' EXCEPT select', True),
|
||||
(u';ALTER TABLE prices', True),
|
||||
(u';alter table prices', True),
|
||||
(u"; UPDATE products SET price = '0'", True),
|
||||
(u";update products SET price = '0'", True),
|
||||
(u"; DELETE FROM products", True),
|
||||
(u"; delete FROM products", True),
|
||||
(u"; SELECT * FROM products", True),
|
||||
(u" ; select * from products", True),
|
||||
('', False),
|
||||
(' ', False),
|
||||
('alternative database', False),
|
||||
('backup of TRUNCATED table', False),
|
||||
('bob.dropper', False),
|
||||
('d\'artagnan', False),
|
||||
('user_with_select_update_truncate_right', False),
|
||||
(';DROP DATABASE fluffy_pets_photos', True),
|
||||
(';drop DATABASE fluffy_pets_photos', True),
|
||||
('; TRUNCATE TABLE his_valuable_table', True),
|
||||
('; truncate TABLE his_valuable_table', True),
|
||||
('\'--', True),
|
||||
('"--', True),
|
||||
('\' union select username, password from admin_credentials', True),
|
||||
('\' UNION SELECT username, password from admin_credentials', True),
|
||||
('\' intersect select', True),
|
||||
('\' INTERSECT select', True),
|
||||
('\' except select', True),
|
||||
('\' EXCEPT select', True),
|
||||
(';ALTER TABLE prices', True),
|
||||
(';alter table prices', True),
|
||||
("; UPDATE products SET price = '0'", True),
|
||||
(";update products SET price = '0'", True),
|
||||
("; DELETE FROM products", True),
|
||||
("; delete FROM products", True),
|
||||
("; SELECT * FROM products", True),
|
||||
(" ; select * from products", True),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ CAUSE_CHG_DECO_IDS = sorted(CAUSE_CHG_DECO.keys())
|
||||
ids=CAUSE_CHG_DECO_IDS)
|
||||
def test_cause_changes_deco(deco_args, expect_exception, expect_changed):
|
||||
|
||||
class MockMH(object):
|
||||
class MockMH:
|
||||
changed = None
|
||||
|
||||
@cause_changes(**deco_args)
|
||||
|
||||
@@ -11,36 +11,36 @@ from ansible_collections.community.general.plugins.module_utils.saslprep import
|
||||
|
||||
|
||||
VALID = [
|
||||
(u'', u''),
|
||||
(u'\u00A0', u' '),
|
||||
(u'a', u'a'),
|
||||
(u'й', u'й'),
|
||||
(u'\u30DE\u30C8\u30EA\u30C3\u30AF\u30B9', u'\u30DE\u30C8\u30EA\u30C3\u30AF\u30B9'),
|
||||
(u'The\u00ADM\u00AAtr\u2168', u'TheMatrIX'),
|
||||
(u'I\u00ADX', u'IX'),
|
||||
(u'user', u'user'),
|
||||
(u'USER', u'USER'),
|
||||
(u'\u00AA', u'a'),
|
||||
(u'\u2168', u'IX'),
|
||||
(u'\u05BE\u00A0\u05BE', u'\u05BE\u0020\u05BE'),
|
||||
('', ''),
|
||||
('\u00A0', ' '),
|
||||
('a', 'a'),
|
||||
('й', 'й'),
|
||||
('\u30DE\u30C8\u30EA\u30C3\u30AF\u30B9', '\u30DE\u30C8\u30EA\u30C3\u30AF\u30B9'),
|
||||
('The\u00ADM\u00AAtr\u2168', 'TheMatrIX'),
|
||||
('I\u00ADX', 'IX'),
|
||||
('user', 'user'),
|
||||
('USER', 'USER'),
|
||||
('\u00AA', 'a'),
|
||||
('\u2168', 'IX'),
|
||||
('\u05BE\u00A0\u05BE', '\u05BE\u0020\u05BE'),
|
||||
]
|
||||
|
||||
INVALID = [
|
||||
(None, TypeError),
|
||||
(b'', TypeError),
|
||||
(u'\u0221', ValueError),
|
||||
(u'\u0007', ValueError),
|
||||
(u'\u0627\u0031', ValueError),
|
||||
(u'\uE0001', ValueError),
|
||||
(u'\uE0020', ValueError),
|
||||
(u'\uFFF9', ValueError),
|
||||
(u'\uFDD0', ValueError),
|
||||
(u'\u0000', ValueError),
|
||||
(u'\u06DD', ValueError),
|
||||
(u'\uFFFFD', ValueError),
|
||||
(u'\uD800', ValueError),
|
||||
(u'\u200E', ValueError),
|
||||
(u'\u05BE\u00AA\u05BE', ValueError),
|
||||
('\u0221', ValueError),
|
||||
('\u0007', ValueError),
|
||||
('\u0627\u0031', ValueError),
|
||||
('\uE0001', ValueError),
|
||||
('\uE0020', ValueError),
|
||||
('\uFFF9', ValueError),
|
||||
('\uFDD0', ValueError),
|
||||
('\u0000', ValueError),
|
||||
('\u06DD', ValueError),
|
||||
('\uFFFFD', ValueError),
|
||||
('\uD800', ValueError),
|
||||
('\u200E', ValueError),
|
||||
('\u05BE\u00AA\u05BE', ValueError),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class Failure(Exception):
|
||||
return str(self.details)
|
||||
|
||||
|
||||
class Session(object):
|
||||
class Session:
|
||||
def __init__(self, uri, transport=None, encoding=None, verbose=0,
|
||||
allow_none=1, ignore_ssl=False):
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class Failure(Exception):
|
||||
return str(self.details)
|
||||
|
||||
|
||||
class Session(object):
|
||||
class Session:
|
||||
def __init__(self, uri, transport=None, encoding=None, verbose=0,
|
||||
allow_none=1, ignore_ssl=False):
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ from httmock import urlmatch # noqa
|
||||
import gitlab
|
||||
|
||||
|
||||
class FakeAnsibleModule(object):
|
||||
class FakeAnsibleModule:
|
||||
def __init__(self, module_params=None):
|
||||
self.check_mode = False
|
||||
self.params = module_params if module_params else {}
|
||||
|
||||
@@ -14,7 +14,7 @@ from .oneview_module_loader import ONEVIEW_MODULE_UTILS_PATH
|
||||
from hpOneView.oneview_client import OneViewClient
|
||||
|
||||
|
||||
class OneViewBaseTest(object):
|
||||
class OneViewBaseTest:
|
||||
@pytest.fixture(autouse=True)
|
||||
def setUp(self, mock_ansible_module, mock_ov_client, request):
|
||||
marker = request.node.get_marker('resource')
|
||||
@@ -88,7 +88,7 @@ class FactsParamsTest(OneViewBaseTest):
|
||||
self.resource.get_all.assert_called_once_with()
|
||||
|
||||
|
||||
class OneViewBaseTestCase(object):
|
||||
class OneViewBaseTestCase:
|
||||
mock_ov_client_from_json_file = None
|
||||
testing_class = None
|
||||
mock_ansible_module = None
|
||||
|
||||
@@ -12,7 +12,7 @@ from ansible_collections.community.general.plugins.modules import alerta_custome
|
||||
from ansible_collections.community.internal_test_tools.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args
|
||||
|
||||
|
||||
class MockedReponse(object):
|
||||
class MockedReponse:
|
||||
def __init__(self, data):
|
||||
self.data = data
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ class TestCirconusAnnotation(ModuleTestCase):
|
||||
'_last_modified': 1502236928,
|
||||
'_last_modified_by': '/user/1000',
|
||||
# use res['annotation']['category'].encode('latin1').decode('utf8')
|
||||
'category': u'new cat\xc3\xa9gor\xc3\xbf',
|
||||
'category': 'new cat\xc3\xa9gor\xc3\xbf',
|
||||
'description': 'test description',
|
||||
'rel_metrics': [],
|
||||
'start': 1502236927,
|
||||
|
||||
@@ -21,7 +21,7 @@ def pass_function(*args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
GITHUB_DATA = {"url": u'https://api.github.com/repos/ansible/ansible',
|
||||
GITHUB_DATA = {"url": 'https://api.github.com/repos/ansible/ansible',
|
||||
"response": b"""
|
||||
{
|
||||
"id": 3638964,
|
||||
|
||||
@@ -46,7 +46,7 @@ class PagerDutyAlertsTest(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
class Response(object):
|
||||
class Response:
|
||||
def read(self):
|
||||
return '{"incidents":[{"id": "incident_id", "status": "triggered"}]}'
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ def patch_rhsm_repository(mocker):
|
||||
return_value=0)
|
||||
|
||||
|
||||
class Repos(object):
|
||||
class Repos:
|
||||
"""
|
||||
Helper class to represent a list of repositories
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import yaml
|
||||
import pytest
|
||||
|
||||
|
||||
class UTHelper(object):
|
||||
class UTHelper:
|
||||
TEST_SPEC_VALID_SECTIONS = ["anchors", "test_cases"]
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -21,14 +21,14 @@ from ansible_collections.community.general.plugins.plugin_utils.unsafe import (
|
||||
|
||||
TEST_MAKE_UNSAFE = [
|
||||
(
|
||||
_make_trusted(u'text'),
|
||||
_make_trusted('text'),
|
||||
[],
|
||||
[
|
||||
(),
|
||||
],
|
||||
),
|
||||
(
|
||||
_make_trusted(u'{{text}}'),
|
||||
_make_trusted('{{text}}'),
|
||||
[
|
||||
(),
|
||||
],
|
||||
@@ -116,7 +116,7 @@ def test_make_unsafe_idempotence():
|
||||
|
||||
def test_make_unsafe_dict_key():
|
||||
value = {
|
||||
_make_trusted(u'test'): 2,
|
||||
_make_trusted('test'): 2,
|
||||
}
|
||||
if not SUPPORTS_DATA_TAGGING:
|
||||
value[_make_trusted(b"test")] = 1
|
||||
@@ -126,7 +126,7 @@ def test_make_unsafe_dict_key():
|
||||
assert _is_trusted(obj)
|
||||
|
||||
value = {
|
||||
_make_trusted(u'{{test}}'): 2,
|
||||
_make_trusted('{{test}}'): 2,
|
||||
}
|
||||
if not SUPPORTS_DATA_TAGGING:
|
||||
value[_make_trusted(b"{{test}}")] = 1
|
||||
@@ -137,7 +137,7 @@ def test_make_unsafe_dict_key():
|
||||
|
||||
|
||||
def test_make_unsafe_set():
|
||||
value = set([_make_trusted(u'test')])
|
||||
value = set([_make_trusted('test')])
|
||||
if not SUPPORTS_DATA_TAGGING:
|
||||
value.add(_make_trusted(b"test"))
|
||||
unsafe_value = make_unsafe(value)
|
||||
@@ -145,7 +145,7 @@ def test_make_unsafe_set():
|
||||
for obj in unsafe_value:
|
||||
assert _is_trusted(obj)
|
||||
|
||||
value = set([_make_trusted(u'{{test}}')])
|
||||
value = set([_make_trusted('{{test}}')])
|
||||
if not SUPPORTS_DATA_TAGGING:
|
||||
value.add(_make_trusted(b"{{test}}"))
|
||||
unsafe_value = make_unsafe(value)
|
||||
|
||||
Reference in New Issue
Block a user