def test_marshal(schema_cls, instance, expected): """ Verify that instances are marshaled to JSON correctly. """ schema = schema_cls() marshaled = schema.dumps(instance) assert json_is_equal(expected, marshaled)
def test_marshal(schema_cls, instance, valid_json): """ Verify that an object instance is marshaled to JSON correctly. """ schema = get_schema(schema_cls, strictness=2) json_str = schema.dumps(instance) assert json_is_equal(json_str, valid_json)
def test_marshall_target_to_json(): """ Verify that PointingConfiguration Target is marshalled to JSON correctly. """ target = Target(ra="12h34m56.78s", dec="+12d34m56.78s", name="NGC123") expected = VALID_TARGET_JSON json_str = TargetSchema().dumps(target) assert json_is_equal(json_str, expected)
def test_codec_dumps_with_schema_validation_for_csp(): """ Verify that the codec marshalls csp objects to JSON with schema validation. """ expected = VALID_CSP_SCHEMA csp_config = csp_config_for_test() marshalled = CODEC.dumps(csp_config) assert json_is_equal(marshalled, expected)
def test_marshall_sdp_scan_type(): """ Verify that JSON can be marshalled to JSON correctly """ scan_type = "science_A" sdp_configure = SDPConfiguration(scan_type) schema = SDPConfigurationSchema() result = schema.dumps(sdp_configure) assert json_is_equal(result, VALID_SDP_SCAN_TYPE)
def test_codec_dumps(): """ Verify that the codec marshalls dish & sdp objects to JSON. """ sdp_config = VALID_SDP_OBJECT expected = VALID_MID_ASSIGNRESOURCESREQUEST_JSON obj = AssignResourcesRequest( subarray_id=1, dish_allocation=DishAllocation(receptor_ids=["0001", "0002"]), sdp_config=sdp_config) marshalled = CODEC.dumps(obj) assert json_is_equal(marshalled, expected)