mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
* created the amixer first skeleton
* push testing and integrate this commit and branch with issue: #591
* #591 checks the input data with jc utils
* created the data parser of the sget control of the amixer sget <controller> command.
* test commit - just for tests
* another test commit
* another test commit
* created a dedicated pseudo algorithm for the amixer sget and tried various of strings.
* orginized the docstring with general explanation about the tool and the amixer tool output and algorithm of the input parsing and input examples.
* created raw implementation, but it's raw either or either.
* orginized the content inside the amixer parser
* removed endpoint name
* added amixer to the jc parser in lib
* more explanations
* added tests for the amixer sget
* added tests for the amixer sget
* fine versioning fix
* created docstring+another explanations seperated.
* created the amixer parser docu
* added the amixer in alphabet order to the json convert lib
* Fix PEP 8: E302 violation as part of boy scout principle
* deleted not necessary file
* fixed the spaces between sections in the amixer description
* resolved commits such as amixer module docstring and preperations for parser for raw=False.
* Revert "Fix PEP 8: E302 violation as part of boy scout principle"
This reverts commit 241d1a1c63
.
* created the dedicated _process for raw=False
* created the dedicated _process for raw=False
* added tests for the _process raw=False.
* changed keys to be lowercase snake-case - Change 'dB' to 'db'
* added more dB -> db changes and used int convertor of the jc utils
---------
Co-authored-by: EdenRafael <eden.refael@kazuar.com>
Co-authored-by: Eden Refael <edeenraf@hotmail.com>
Co-authored-by: Kelly Brazil <kellyjonbrazil@gmail.com>
49 lines
2.2 KiB
Python
49 lines
2.2 KiB
Python
import unittest
|
|
import jc.parsers.amixer
|
|
import os
|
|
import json
|
|
|
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
|
class AmixerTests(unittest.TestCase):
|
|
AMIXER_CMD = 'amixer'
|
|
UBUNTU_22_04_TEST_FIXTURES_PATH = f'{THIS_DIR}/fixtures/ubuntu-22.04/'
|
|
AMIXER_CONTROL_PATH = f'{UBUNTU_22_04_TEST_FIXTURES_PATH}amixer-control-'
|
|
TEST_FILES_NAME = [
|
|
f"{AMIXER_CONTROL_PATH}capture",
|
|
f'{AMIXER_CONTROL_PATH}headphone',
|
|
f'{AMIXER_CONTROL_PATH}master',
|
|
f'{AMIXER_CONTROL_PATH}speakers',
|
|
]
|
|
|
|
def setUp(self):
|
|
self.test_files_out = [f'{file}.out' for file in self.TEST_FILES_NAME]
|
|
self.test_files_json = [f'{file}.json' for file in self.TEST_FILES_NAME]
|
|
self.test_files_processed_json = [f'{file}-processed.json' for file in self.TEST_FILES_NAME]
|
|
|
|
def test_amixer_sget(self):
|
|
for file_out, file_json, file_processed_json in zip(self.test_files_out, self.test_files_json,
|
|
self.test_files_processed_json):
|
|
with open(file_out, 'r') as f:
|
|
amixer_sget_raw_output: str = f.read()
|
|
with open(file_json, 'r') as f:
|
|
expected_amixer_sget_json_output: str = f.read()
|
|
expected_amixer_sget_json_map: dict = json.loads(expected_amixer_sget_json_output)
|
|
with open(file_processed_json, 'r') as f:
|
|
expected_amixer_sget_processed_json_output: str = f.read()
|
|
expected_amixer_sget_processed_json_map: dict = json.loads(expected_amixer_sget_processed_json_output)
|
|
|
|
# Tests for raw=True
|
|
amixer_sget_json_map: dict = jc.parse(self.AMIXER_CMD, amixer_sget_raw_output, raw=True,
|
|
quiet=True)
|
|
self.assertEqual(amixer_sget_json_map, expected_amixer_sget_json_map)
|
|
# Tests for raw=False process
|
|
amixer_sget_json_processed_map: dict = jc.parse(self.AMIXER_CMD, amixer_sget_raw_output, raw=False,
|
|
quiet=True)
|
|
self.assertEqual(amixer_sget_json_processed_map, expected_amixer_sget_processed_json_map)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|