mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-31 17:36:21 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -16,11 +16,13 @@ from ansible_collections.community.general.plugins.module_utils.ocapi_utils impo
|
|||
class TestOcapiUtils(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tempdir = tempfile.mkdtemp()
|
||||
self.utils = OcapiUtils(creds={"user": "a_user", "pswd": "a_password"},
|
||||
base_uri="fakeUri",
|
||||
proxy_slot_number=None,
|
||||
timeout=30,
|
||||
module=None)
|
||||
self.utils = OcapiUtils(
|
||||
creds={"user": "a_user", "pswd": "a_password"},
|
||||
base_uri="fakeUri",
|
||||
proxy_slot_number=None,
|
||||
timeout=30,
|
||||
module=None,
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tempdir)
|
||||
|
|
@ -29,8 +31,8 @@ class TestOcapiUtils(unittest.TestCase):
|
|||
# Generate a binary file and save it
|
||||
filename = "fake_firmware.bin"
|
||||
filepath = os.path.join(self.tempdir, filename)
|
||||
file_contents = b'\x00\x01\x02\x03\x04'
|
||||
with open(filepath, 'wb+') as f:
|
||||
file_contents = b"\x00\x01\x02\x03\x04"
|
||||
with open(filepath, "wb+") as f:
|
||||
f.write(file_contents)
|
||||
|
||||
# Call prepare_mutipart_firmware_upload
|
||||
|
|
@ -43,10 +45,10 @@ class TestOcapiUtils(unittest.TestCase):
|
|||
|
||||
# Check the returned binary data
|
||||
boundary = m.group(1)
|
||||
expected_content_text = f'--{boundary}\r\n'
|
||||
expected_content_text = f"--{boundary}\r\n"
|
||||
expected_content_text += f'Content-Disposition: form-data; name="FirmwareFile"; filename="{filename}"\r\n'
|
||||
expected_content_text += 'Content-Type: application/octet-stream\r\n\r\n'
|
||||
expected_content_bytes = bytearray(expected_content_text, 'utf-8')
|
||||
expected_content_text += "Content-Type: application/octet-stream\r\n\r\n"
|
||||
expected_content_bytes = bytearray(expected_content_text, "utf-8")
|
||||
expected_content_bytes += file_contents
|
||||
expected_content_bytes += bytearray(f'\r\n--{boundary}--', 'utf-8')
|
||||
expected_content_bytes += bytearray(f"\r\n--{boundary}--", "utf-8")
|
||||
self.assertEqual(expected_content_bytes, b_form_data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue