def test_empty(): """Test that an empty dataframe is valid (As long as the required columns exist!) """ empty = empty_signals() check_signal_specification(empty)
def test_unknown_version(signals): """Test only the current specification version If a new version of the signals specification is implemented, this unit test should be updated to the next version. """ with pytest.raises(ValueError): # This should fail because version='2' does not exist yet check_signal_specification(signals, version='2')
def postconditions(self, results): super().postconditions(results) if not isinstance(results, FileAdapter): raise PostconditionFailed('Output was not a file') # Postcondition: file is empty if results.empty: return # Postcondition: when file is not empty, it follows the signal spec key = self.output_hdf5_key with pd.HDFStore(str(results.file.resolve()), 'r') as store: dataframe = pd.read_hdf(store, key) check_signal_specification(dataframe)
def _check_and_assert_raises(signal_obj, annotation_obj, code): with pytest.raises(SignalSpecificationError) as ex_info: check_signal_specification(signal_obj, annotation_obj) exception = ex_info.value assert exception.code == code
def test_sample_number_integer(signals): """Test that sample_number with integer does not fail""" signals['sample_number'] = np.arange(signals.shape[0]) check_signal_specification(signals)
def test_correct_signal_example_dataframe(example_signals_annotations): """Test that the signal example shown in the docs conforms to the specs""" signals, annotations = example_signals_annotations check_signal_specification(signals, annotations)
def test_correct_signal_dataframe(signals): """Test a correct event dataframe""" # This should not raise anything check_signal_specification(signals)