docstring added
This commit is contained in:
@@ -7,10 +7,13 @@ from scraibe import Diariser
|
||||
|
||||
@pytest.fixture
|
||||
def diariser_instance():
|
||||
"""Creates a instance of the Diariser Object for further testing
|
||||
"""Fixture for creating an instance of the Diariser class with mocked token.
|
||||
|
||||
This fixture is used to create an instance of the the Diariser class with a mocked token returned by the _get_token method. It patches the _get_token method of the Diariser class
|
||||
using unit.test.mock.patch.object, ensuring that it returns a predetrmined value ('personal Hugging-Face token'). The mocked Diariser object is retunrned and can be used as a dependency in otehr tests.
|
||||
|
||||
Returns:
|
||||
Object: Diariser Object for handling the diarization process of an audio file using a pretrained model from pyannote.audio. Diarization is the task of determining "who spoke when."
|
||||
Diariser(Obj): An instance of the Diariser class with a mocked token.
|
||||
"""
|
||||
with mock.patch.object(Diariser, '_get_token', return_value = 'personal Hugging-Face token')
|
||||
return Diariser('pyannote')
|
||||
@@ -18,20 +21,37 @@ def diariser_instance():
|
||||
|
||||
|
||||
def test_Diariser_init(diariser_instance):
|
||||
"""Tests if the Diariser gets initiated correctly
|
||||
"""Test the initialization of the Diariser class.
|
||||
|
||||
This test verifies that the Diariser class is correctly initialized with the specified model.
|
||||
It checks whether the 'model' attribute of the instantiated Diariser object equals 'pyannote'.
|
||||
|
||||
|
||||
Args:
|
||||
diariser_instance (obj): instance of the Diariser object
|
||||
diariser_instance (obj): instance of the Diariser class
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
assert diariser_instance.model == 'pyannote'
|
||||
|
||||
|
||||
|
||||
def test_diarisation_function(diariser_instance):
|
||||
"""tests if the Diariser works object with an example audio File
|
||||
"""Test the diarization function of the Diariser class.
|
||||
|
||||
This test verifies that the diarization function of the Diariser class correctly processes
|
||||
an audio file and returns the diarization result. It patches the apply method of the model
|
||||
attribute of the Diariser instance using unittest.mock.patch.object, ensuring that it returns
|
||||
a predetermined value ('diarization_result') when called with the audio file argument.
|
||||
It then calls the diarization function with an example audio file and checks whether the returned
|
||||
diarization output matches the expected result ('diarization_result').
|
||||
|
||||
Args:
|
||||
diariser_instance (obj): instance of the Diariser object
|
||||
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
with mock.patch.object(diariser_instance.model, 'apply', return_value='diarization_result'):
|
||||
diarization_output = diariser_instance.diarization('example_audio_file.wav')
|
||||
|
||||
Reference in New Issue
Block a user