diff --git a/.vscode/settings.json b/.vscode/settings.json index 0f52bf2..c562fda 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "cSpell.words": [ + "capsys", "sadb", "scrcpy", "screencap", diff --git a/sadb.py b/sadb.py index bc65202..d4b8aca 100644 --- a/sadb.py +++ b/sadb.py @@ -1,5 +1,8 @@ +"""Module for controlling multiple android devices at once with adb""" #!/usr/bin/python3 +#pylint: disable=subprocess-run-check, unspecified-encoding + # Created by: Seamus Sloan # Last Edited: July 10, 2023 diff --git a/tests/conftest.py b/tests/conftest.py index c5160c2..f742cc7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,7 @@ +"""Test all functions are sending the correct commands""" #!/usr/bin/python3 +#pylint: disable=missing-function-docstring, wrong-import-position # Created by: Seamus Sloan # Last Edited: July 10, 2023 @@ -9,14 +11,14 @@ DEVICE_IDS = ["FA79J1A00421", "ZY223TDZ43", "HT4CJ0203660", "R58M45YME1R", "emulator-5554"] @pytest.fixture -def testDeviceList(): +def test_device_list(): return DEVICE_IDS @pytest.fixture -def testDevices(): - def _testDevices(number_of_devices): +def test_devices(): + def _test_devices(number_of_devices): result = "List of devices attached\n" for i in range(number_of_devices): result += DEVICE_IDS[i] + "\tdevice\n" return result - return _testDevices \ No newline at end of file + return _test_devices \ No newline at end of file diff --git a/tests/test_commands.py b/tests/test_commands.py index 38d2f56..a9ef544 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1,5 +1,8 @@ +"""Test all functions are sending the correct commands""" #!/usr/bin/python3 +#pylint: disable=missing-function-docstring, wrong-import-position + # Created by: Seamus Sloan # Last Edited: July 10, 2023 diff --git a/tests/test_get_devices.py b/tests/test_get_devices.py index 4c875ea..1522f94 100644 --- a/tests/test_get_devices.py +++ b/tests/test_get_devices.py @@ -1,5 +1,8 @@ +"""Test get devices is returning the correct devices""" #!/usr/bin/python3 +#pylint: disable=missing-function-docstring, wrong-import-position + # Created by: Seamus Sloan # Last Edited: July 10, 2023 @@ -7,26 +10,26 @@ sys.path.append("..") from sadb import split_get_devices -def test_get_devices_returns_correct_three_devices(testDevices): - devices = split_get_devices(testDevices(3)) +def test_get_devices_returns_correct_three_devices(test_devices): + devices = split_get_devices(test_devices(3)) print(devices) assert devices == ['FA79J1A00421', 'ZY223TDZ43', 'HT4CJ0203660'] -def test_get_devices_returns_correct_five_devices(testDevices): - devices = split_get_devices(testDevices(5)) +def test_get_devices_returns_correct_five_devices(test_devices): + devices = split_get_devices(test_devices(5)) print(devices) assert devices == ["FA79J1A00421", "ZY223TDZ43", "HT4CJ0203660", "R58M45YME1R", "emulator-5554"] -def test_get_devices_returns_correct_single_device(testDevices): - devices = split_get_devices(testDevices(1)) +def test_get_devices_returns_correct_single_device(test_devices): + devices = split_get_devices(test_devices(1)) print(devices) assert devices == ['FA79J1A00421'] -def test_get_devices_returns_correct_no_devices(testDevices): - devices = split_get_devices(testDevices(0)) +def test_get_devices_returns_correct_no_devices(test_devices): + devices = split_get_devices(test_devices(0)) print(devices) assert devices == [] diff --git a/tests/test_select_device.py b/tests/test_select_device.py index ac8374c..c7cf509 100644 --- a/tests/test_select_device.py +++ b/tests/test_select_device.py @@ -1,5 +1,8 @@ +"""Test device selection is working as expected""" #!/usr/bin/python3 +#pylint: disable=missing-function-docstring, wrong-import-position + # Created by: Seamus Sloan # Last Edited: July 10, 2023 @@ -7,25 +10,25 @@ sys.path.append("..") from sadb import select_device -def test_select_one_device(monkeypatch, testDeviceList): +def test_select_one_device(monkeypatch, test_device_list): monkeypatch.setattr('builtins.input', lambda _: 1) - device = select_device(testDeviceList) + device = select_device(test_device_list) assert device == "FA79J1A00421" -def test_select_second_device(monkeypatch, testDeviceList): +def test_select_second_device(monkeypatch, test_device_list): monkeypatch.setattr('builtins.input', lambda _: 2) - device = select_device(testDeviceList) + device = select_device(test_device_list) assert device == "ZY223TDZ43" -def test_select_all_devices(monkeypatch, testDeviceList): - monkeypatch.setattr('builtins.input', lambda _: len(testDeviceList) + 1) +def test_select_all_devices(monkeypatch, test_device_list): + monkeypatch.setattr('builtins.input', lambda _: len(test_device_list) + 1) - device = select_device(testDeviceList, allow_all=True) - assert device == testDeviceList + device = select_device(test_device_list, allow_all=True) + assert device == test_device_list def test_display_of_no_devices(capsys): @@ -34,14 +37,14 @@ def test_display_of_no_devices(capsys): assert captured.out == "No devices found\n" -def test_display_of_one_device(testDeviceList): - devices = [testDeviceList[0]] +def test_display_of_one_device(test_device_list): + devices = [test_device_list[0]] assert select_device(devices) == "FA79J1A00421" -def test_select_device_multiple_devices(monkeypatch, capsys, testDeviceList): +def test_select_device_multiple_devices(monkeypatch, capsys, test_device_list): monkeypatch.setattr('builtins.input', lambda _: "1") - select_device(testDeviceList) + select_device(test_device_list) captured = capsys.readouterr() assert captured.out == """Select a device: 1. FA79J1A00421 @@ -52,9 +55,9 @@ def test_select_device_multiple_devices(monkeypatch, capsys, testDeviceList): """ -def test_display_of_multiple_devices_allow_all(monkeypatch, capsys, testDeviceList): +def test_display_of_multiple_devices_allow_all(monkeypatch, capsys, test_device_list): monkeypatch.setattr('builtins.input', lambda _: "1") - select_device(testDeviceList, allow_all=True) + select_device(test_device_list, allow_all=True) captured = capsys.readouterr() assert captured.out == """Select a device: 1. FA79J1A00421