def test_failures(): test_object = type('', (), {})() with pytest.raises(AssertionError): validate(test_object) with pytest.raises(ValueError): _check_param(test_object, SimpleObservation)
def test_validate_observation(): obs = SimpleObservation('test_collection', 'test_obs_id', Algorithm('test_name')) validate(obs) obs = DerivedObservation('test_collection', 'test_obs_id', Algorithm('test_name'), proposal=Proposal('test_proposal'), telescope=Telescope('test_telescope'), instrument=Instrument('test_instrument'), target=Target('test_targets')) obs.algorithm.keywords = 'foo' obs.proposal.keywords = set('foo=42') obs.telescope.keywords = set('foo:42') obs.instrument.keywords.add("tick'marks") obs.target.keywords = set('has multiple spaces') test_plane = Plane('test_plane') test_plane.provenance = Provenance('test_provenance') test_plane.provenance.keywords.add('pipe|denied') obs.planes['test_plane'] = test_plane with pytest.raises(AssertionError): validate(obs)
def test_compatibility(): # tests a previously generated observation and validates the # entities, and the entities with children source_file_path = os.path.join(THIS_DIR, TEST_DATA, 'SampleComposite-CAOM-2.3.xml') reader = ObservationReader(True) with open(source_file_path): obs = reader.read(source_file_path) # shallow validates first for plane in obs.planes.values(): for artifact in plane.artifacts.values(): for part in artifact.parts.values(): for chunk in part.chunks: validate(chunk, False) validate(part, False) validate(artifact, False) validate(plane, False) validate(obs, False) # deep validate validate(obs, True)