def test_Observation_validate(raw_obs): obs = model.Observation(**raw_obs) assert obs.SCHEMA assert obs.validate() raw_obs['audio_file'] = "dummy_philharmonia/www.philharmonia.co.uk/"\ "assets/audio/samples/instruments/cello.zip" obs = model.Observation(**raw_obs) assert not obs.validate()
def test_Observation_validate(rwc_root, rwc_obs, test_obs): obs = model.Observation(**rwc_obs) assert obs.SCHEMA assert not obs.validate() assert obs.validate(check_files=False) rwc_obs['audio_file'] = os.path.join(rwc_root, rwc_obs['audio_file']) obs = model.Observation(**rwc_obs) assert obs.validate() rwc_obs['audio_file'] = ("dummy_philharmonia/www.philharmonia.co.uk/" "assets/audio/samples/instruments/cello.zip") obs = model.Observation(**rwc_obs) assert not obs.validate() for o in test_obs: assert model.Observation(**o).validate(verbose=True, check_files=False)
def test_Collection___init__(test_obs, rwc_obs, rwc_root): dset = model.Collection(test_obs) assert dset is not None with pytest.raises(model.MissingDataException): dset = model.Collection(test_obs, strict=True) obs = model.Observation(**rwc_obs) with pytest.raises(model.MissingDataException): dset = model.Collection([obs], audio_root='', strict=True) dset = model.Collection([obs], audio_root=rwc_root, strict=True) assert dset is not None
def test_Observation___init__(raw_obs): obs = model.Observation(**raw_obs) assert obs
def test_Observation___get_item__(rwc_obs): obs = model.Observation(**rwc_obs) assert obs['index'] == obs.index == rwc_obs['index']
def test_Observation_to_dict(rwc_obs): obs = model.Observation(**rwc_obs) rec_obs = obs.to_dict() assert rec_obs == rwc_obs
def test_Observation_to_series(rwc_obs): obs = model.Observation(**rwc_obs) rec = obs.to_series() assert rec.name == rwc_obs['index'] assert rec.instrument == rwc_obs['instrument']
def test_Observation_to_builtin(rwc_obs): obs = model.Observation(**rwc_obs) assert obs.to_builtin() == rwc_obs