<commit_before>import madam.audio


def test_create_asset_from_wav():
    asset = madam.audio.WaveProcessor()._read('tests/resources/16-bit-mono.wav')
    assert asset.mime_type == 'audio/wav'
    assert asset.framerate == 48000
    assert asset.channels == 1
    assert asset.essence is not None


def test_create_asset_from_mp3():
    mp3_file_path = 'tests/resources/64kbits.mp3'
    with open(mp3_file_path, 'rb') as mp3_file:
        asset = madam.audio.MutagenProcessor()._read(mp3_file)
    assert asset.mime_type == 'audio/mpeg'
    assert asset.duration == 0.1
    assert asset.essence is not None

    # Assert that essence was stripped from metadata
    with open(mp3_file_path, 'rb') as mp3_file:
        assert asset.essence != mp3_file.read()


def test_mp3_reader_does_not_change_file():
    mp3_file_path = 'tests/resources/64kbits.mp3'
    with open(mp3_file_path, 'rb') as mp3_file:
        expected_data = mp3_file.read()
    with open(mp3_file_path, 'rb') as mp3_file:
        madam.audio.MutagenProcessor()._read(mp3_file)
    with open(mp3_file_path, 'rb') as mp3_file:
        actual_data = mp3_file.read()
    assert expected_data == actual_data<commit_msg>Grouped test cases for WaveProcessor and MutagenProcessor in test classes.<commit_after>import pytest

import madam.audio


class TestWaveProcessor:
    @pytest.fixture(name='processor')
    def wave_processor(self):
        return madam.audio.WaveProcessor()

    def test_create_asset_from_wav(self, processor):
        asset = processor._read('tests/resources/16-bit-mono.wav')
        assert asset.mime_type == 'audio/wav'
        assert asset.framerate == 48000
        assert asset.channels == 1
        assert asset.essence is not None
        assert asset.essence.read()


class TestMutagenProcessor:
    @pytest.fixture(name='processor')
    def mutagen_processor(self):
        return madam.audio.MutagenProcessor()

    def test_create_asset_from_mp3(self, processor):
        mp3_file_path = 'tests/resources/64kbits.mp3'
        with open(mp3_file_path, 'rb') as mp3_file:
            asset = processor._read(mp3_file)
        assert asset.mime_type == 'audio/mpeg'
        assert asset.duration == 0.1
        assert asset.essence is not None
        assert asset.essence.read()

        # Assert that essence was stripped from metadata
        with open(mp3_file_path, 'rb') as mp3_file:
            assert asset.essence.read() != mp3_file.read()

    def test_mp3_reader_does_not_change_file(self, processor):
        mp3_file_path = 'tests/resources/64kbits.mp3'
        with open(mp3_file_path, 'rb') as mp3_file:
            expected_data = mp3_file.read()
        with open(mp3_file_path, 'rb') as mp3_file:
            processor._read(mp3_file)
        with open(mp3_file_path, 'rb') as mp3_file:
            actual_data = mp3_file.read()
        assert expected_data == actual_data
{'fraction_non_alphanumeric': 0.09882108183079057, 'fraction_numerical': 0.024271844660194174, 'mean_word_length': 3.224011713030747, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 42, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5353947', 'n_tokens_mistral': 980, 'n_tokens_neox': 945, 'n_words': 199}