Skip to content

Commit

Permalink
Finished removing bad-continuation symbols.
Browse files Browse the repository at this point in the history
  • Loading branch information
keclar committed Aug 20, 2020
1 parent d663700 commit 8e918a7
Show file tree
Hide file tree
Showing 24 changed files with 118 additions and 138 deletions.
2 changes: 1 addition & 1 deletion azurelinuxagent/common/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _save(self):

__event_status__ = EventStatus()
__event_status_operations__ = [
WALAEventOperation.ReportStatus # pylint: disable=bad-continuation
WALAEventOperation.ReportStatus
]


Expand Down
14 changes: 0 additions & 14 deletions tests/common/mock_cgroup_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@
#
_default_commands = [ # pylint: disable=invalid-name
(r"^systemctl --version$",
# pylint: disable=bad-continuation
'''systemd 237
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid
'''),
# pylint: enable=bad-continuation

(r"^mount -t cgroup$",
# pylint: disable=bad-continuation
'''cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,name=systemd)
cgroup on /sys/fs/cgroup/rdma type cgroup (rw,nosuid,nodev,noexec,relatime,rdma)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
Expand All @@ -51,41 +48,30 @@
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
'''),
# pylint: enable=bad-continuation
(r"^mount -t cgroup2$",
# pylint: disable=bad-continuation
'''cgroup on /sys/fs/cgroup/unified type cgroup2 (rw,nosuid,nodev,noexec,relatime)
'''),
# pylint: enable=bad-continuation

(r"^systemctl show walinuxagent\.service --property CPUAccounting$",
# pylint: disable=bad-continuation
'''CPUAccounting=no
'''),
# pylint: enable=bad-continuation

(r"^systemctl show walinuxagent\.service --property MemoryAccounting$",
# pylint: disable=bad-continuation
'''MemoryAccounting=no
'''),
# pylint: enable=bad-continuation

(r"^systemd-run --unit=([^\s]+) --scope ([^\s]+)",
# pylint: disable=bad-continuation
'''
Running scope as unit: TEST_UNIT.scope
Thu 28 May 2020 07:25:55 AM PDT
'''),
# pylint: enable=bad-continuation

(r"^systemd-cgls.+/walinuxagent.service$",
# pylint: disable=bad-continuation
'''
Directory /sys/fs/cgroup/cpu/system.slice/walinuxagent.service:
├─27519 /usr/bin/python3 -u /usr/sbin/waagent -daemon
└─27547 python3 -u bin/WALinuxAgent-2.2.48.1-py2.7.egg -run-exthandlers
'''),
# pylint: enable=bad-continuation
]

_default_files = [ # pylint: disable=invalid-name
Expand Down
12 changes: 6 additions & 6 deletions tests/common/osutil/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def test_correct_instance_id(self):

@patch('os.path.isfile', return_value=True)
@patch('azurelinuxagent.common.utils.fileutil.read_file',
return_value="33C2F3B9-1399-429F-8EB3-BA656DF32502") # pylint: disable=bad-continuation
return_value="33C2F3B9-1399-429F-8EB3-BA656DF32502")
def test_get_instance_id_from_file(self, mock_read, mock_isfile): # pylint: disable=unused-argument
util = osutil.DefaultOSUtil()
self.assertEqual(
Expand All @@ -533,7 +533,7 @@ def test_get_instance_id_from_file(self, mock_read, mock_isfile): # pylint: disa

@patch('os.path.isfile', return_value=True)
@patch('azurelinuxagent.common.utils.fileutil.read_file',
return_value="") # pylint: disable=bad-continuation
return_value="")
def test_get_instance_id_empty_from_file(self, mock_read, mock_isfile): # pylint: disable=unused-argument
util = osutil.DefaultOSUtil()
self.assertEqual(
Expand All @@ -542,7 +542,7 @@ def test_get_instance_id_empty_from_file(self, mock_read, mock_isfile): # pylint

@patch('os.path.isfile', return_value=True)
@patch('azurelinuxagent.common.utils.fileutil.read_file',
return_value="Value") # pylint: disable=bad-continuation
return_value="Value")
def test_get_instance_id_malformed_from_file(self, mock_read, mock_isfile): # pylint: disable=unused-argument
util = osutil.DefaultOSUtil()
self.assertEqual(
Expand All @@ -551,7 +551,7 @@ def test_get_instance_id_malformed_from_file(self, mock_read, mock_isfile): # py

@patch('os.path.isfile', return_value=False)
@patch('azurelinuxagent.common.utils.shellutil.run_get_output',
return_value=[0, '33C2F3B9-1399-429F-8EB3-BA656DF32502']) # pylint: disable=bad-continuation
return_value=[0, '33C2F3B9-1399-429F-8EB3-BA656DF32502'])
def test_get_instance_id_from_dmidecode(self, mock_shell, mock_isfile): # pylint: disable=unused-argument
util = osutil.DefaultOSUtil()
self.assertEqual(
Expand All @@ -560,14 +560,14 @@ def test_get_instance_id_from_dmidecode(self, mock_shell, mock_isfile): # pylint

@patch('os.path.isfile', return_value=False)
@patch('azurelinuxagent.common.utils.shellutil.run_get_output',
return_value=[1, 'Error Value']) # pylint: disable=bad-continuation
return_value=[1, 'Error Value'])
def test_get_instance_id_missing(self, mock_shell, mock_isfile): # pylint: disable=unused-argument
util = osutil.DefaultOSUtil()
self.assertEqual("", util.get_instance_id())

@patch('os.path.isfile', return_value=False)
@patch('azurelinuxagent.common.utils.shellutil.run_get_output',
return_value=[0, 'Unexpected Value']) # pylint: disable=bad-continuation
return_value=[0, 'Unexpected Value'])
def test_get_instance_id_unexpected(self, mock_shell, mock_isfile): # pylint: disable=unused-argument
util = osutil.DefaultOSUtil()
self.assertEqual("", util.get_instance_id())
Expand Down
2 changes: 1 addition & 1 deletion tests/common/test_cgroupconfigurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_get_processes_in_agent_cgroup_should_return_the_processes_within_the_ag
processes = configurator.get_processes_in_agent_cgroup()

self.assertTrue(len(processes) >= 2,
"The cgroup should contain at least 2 procceses (daemon and extension handler): [{0}]".format(processes)) # pylint: disable=bad-continuation
"The cgroup should contain at least 2 procceses (daemon and extension handler): [{0}]".format(processes))

daemon_present = any("waagent -daemon" in command for (pid, command) in processes)
self.assertTrue(daemon_present, "Could not find the daemon in the cgroup: [{0}]".format(processes))
Expand Down
4 changes: 2 additions & 2 deletions tests/common/test_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def setUp(self):
AgentTestCase.setUp(self)
self.conf = conf.ConfigurationProvider()
conf.load_conf_from_file(
os.path.join(data_dir, "test_waagent.conf"), # pylint: disable=bad-continuation
self.conf) # pylint: disable=bad-continuation
os.path.join(data_dir, "test_waagent.conf"),
self.conf)

def test_key_value_handling(self):
self.assertEqual("Value1", self.conf.get("FauxKey1", "Bad"))
Expand Down
16 changes: 8 additions & 8 deletions tests/common/test_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def test_save_event(self):
# checking the extension of the file created.
for filename in os.listdir(self.event_dir):
self.assertTrue(filename.endswith(AGENT_EVENT_FILE_EXTENSION),
'Event file does not have the correct extension ({0}): {1}'.format(AGENT_EVENT_FILE_EXTENSION, filename)) # pylint: disable=bad-continuation
'Event file does not have the correct extension ({0}): {1}'.format(AGENT_EVENT_FILE_EXTENSION, filename))

@staticmethod
def _get_event_message(evt):
Expand Down Expand Up @@ -523,13 +523,13 @@ def _test_create_event_function_should_create_events_that_have_all_the_parameter
event_list.events[0],
expected_parameters,
assert_timestamp=lambda timestamp:
self.assertTrue(timestamp_lower <= timestamp <= timestamp_upper, "The event timestamp (opcode) is incorrect") # pylint: disable=bad-continuation
self.assertTrue(timestamp_lower <= timestamp <= timestamp_upper, "The event timestamp (opcode) is incorrect")
)

def test_add_event_should_create_events_that_have_all_the_parameters_in_the_telemetry_schema(self):
self._test_create_event_function_should_create_events_that_have_all_the_parameters_in_the_telemetry_schema(
create_event_function=lambda:
add_event( # pylint: disable=bad-continuation
add_event(
name="TestEvent",
op=WALAEventOperation.AgentEnabled,
is_success=True,
Expand All @@ -548,7 +548,7 @@ def test_add_event_should_create_events_that_have_all_the_parameters_in_the_tele
def test_add_periodic_should_create_events_that_have_all_the_parameters_in_the_telemetry_schema(self):
self._test_create_event_function_should_create_events_that_have_all_the_parameters_in_the_telemetry_schema(
create_event_function=lambda:
add_periodic( # pylint: disable=bad-continuation
add_periodic(
delta=logger.EVERY_MINUTE,
name="TestPeriodicEvent",
op=WALAEventOperation.HostPlugin,
Expand Down Expand Up @@ -639,7 +639,7 @@ def test_collect_events_should_add_all_the_parameters_in_the_telemetry_schema_to
CommonTelemetryEventSchema.TaskName: "ALegacyTask",
CommonTelemetryEventSchema.KeywordName: "ALegacyKeywordName"},
assert_timestamp=lambda timestamp:
self.assertEquals(timestamp, '1970-01-01 12:00:00', "The event timestamp (opcode) is incorrect") # pylint: disable=deprecated-method,bad-continuation
self.assertEquals(timestamp, '1970-01-01 12:00:00', "The event timestamp (opcode) is incorrect") # pylint: disable=deprecated-method
)

def test_collect_events_should_use_the_file_creation_time_for_legacy_agent_events_missing_a_timestamp(self):
Expand Down Expand Up @@ -669,7 +669,7 @@ def test_collect_events_should_use_the_file_creation_time_for_legacy_agent_event
CommonTelemetryEventSchema.TaskName: "ALegacyTask",
CommonTelemetryEventSchema.KeywordName: "ALegacyKeywordName"},
assert_timestamp=lambda timestamp:
self.assertEquals(timestamp, event_creation_time, "The event timestamp (opcode) is incorrect") # pylint: disable=deprecated-method,bad-continuation
self.assertEquals(timestamp, event_creation_time, "The event timestamp (opcode) is incorrect") # pylint: disable=deprecated-method
)

def _assert_extension_event_includes_all_parameters_in_the_telemetry_schema(self, event_file):
Expand All @@ -694,7 +694,7 @@ def _assert_extension_event_includes_all_parameters_in_the_telemetry_schema(self
GuestAgentExtensionEventsSchema.Duration: 150000,
GuestAgentExtensionEventsSchema.ExtensionType: 'json'},
assert_timestamp=lambda timestamp:
self.assertEquals(timestamp, event_creation_time, "The event timestamp (opcode) is incorrect") # pylint: disable=deprecated-method,bad-continuation
self.assertEquals(timestamp, event_creation_time, "The event timestamp (opcode) is incorrect") # pylint: disable=deprecated-method
)

def test_collect_events_should_add_all_the_parameters_in_the_telemetry_schema_to_extension_events(self):
Expand Down Expand Up @@ -723,7 +723,7 @@ def get_event_message_from_event_file(event_file):
def get_event_message_from_http_request_body(event_body):
# The XML for the event is sent over as a CDATA element ("Event") in the request's body
http_request_body = event_body if (
event_body is None or type(event_body) is ustr) else textutil.str_to_encoded_ustr(event_body) # pylint: disable=unidiomatic-typecheck,bad-continuation
event_body is None or type(event_body) is ustr) else textutil.str_to_encoded_ustr(event_body) # pylint: disable=unidiomatic-typecheck
request_body_xml_doc = textutil.parse_doc(http_request_body)

event_node = textutil.find(request_body_xml_doc, "Event")
Expand Down
2 changes: 1 addition & 1 deletion tests/common/test_logcollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def test_log_collector_should_update_archive_when_files_are_new_or_modified_or_d
file = os.path.join(self.root_collect_dir, "waagent.log") # pylint: disable=redefined-builtin
new_file_size = self._get_uncompressed_file_size(file)
self.assertEquals(LARGE_FILE_SIZE, new_file_size, "File {0} hasn't been updated! Size in archive is {1}, but " # pylint: disable=deprecated-method
"should be {2}.".format(file, new_file_size, LARGE_FILE_SIZE)) # pylint: disable=bad-continuation
"should be {2}.".format(file, new_file_size, LARGE_FILE_SIZE))

no_files = self._get_number_of_files_in_archive()
self.assertEquals(6, no_files, "Expected 6 files in archive, found {0}!".format(no_files)) # pylint: disable=deprecated-method
Expand Down
4 changes: 2 additions & 2 deletions tests/common/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def test_telemetry_logger_add_log_event(self, mock_lib_dir, *_):
self.assertIn("Test Log - Warning", logcontent)
except Exception as e: # pylint: disable=invalid-name
self.assertFalse(True, "The log file looks like it isn't correctly setup for this test. Take a look. " # pylint: disable=redundant-unittest-assert
"{0}".format(e)) # pylint: disable=bad-continuation
"{0}".format(e))

@skip_if_predicate_true(lambda: True, "Enable this test when SEND_LOGS_TO_TELEMETRY is enabled")
@patch("azurelinuxagent.common.logger.StdoutAppender.write")
Expand Down Expand Up @@ -458,7 +458,7 @@ def test_telemetry_logger_check_all_file_logs_written_when_events_gt_MAX_NUMBER_
self.event_dir))
except Exception as e: # pylint: disable=invalid-name
self.assertFalse(True, "The log file looks like it isn't correctly setup for this test. " # pylint: disable=redundant-unittest-assert
"Take a look. {0}".format(e)) # pylint: disable=bad-continuation
"Take a look. {0}".format(e))


class TestAppender(AgentTestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/common/test_telemetryevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


def get_test_event(name="DummyExtension", op="Unknown", is_success=True, duration=0, version="foo", evt_type="", is_internal=False, # pylint: disable=invalid-name,too-many-arguments
message="DummyMessage", eventId=1): # pylint: disable=bad-continuation
message="DummyMessage", eventId=1):
event = TelemetryEvent(eventId, "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
event.parameters.append(TelemetryEventParam(GuestAgentExtensionEventsSchema.Name, name))
event.parameters.append(TelemetryEventParam(GuestAgentExtensionEventsSchema.Version, str(version)))
Expand Down
Loading

0 comments on commit 8e918a7

Please sign in to comment.