Example #1
0
def test_codec_dumps_raises_exception_on_invalid_schema():
    """
     Verify that codec dumps() with invalid schema raise exception
    """
    csp_config = csp_config_for_test()
    csp_config.interface = 'http://schema.skatelescope.org/ska-csp-configure/3.0'
    with pytest.raises(JsonValidationError):
        CODEC.dumps(csp_config)
Example #2
0
def test_configure_request_raises_exception_on_invalid_csp_object():
    """
     Verify that codec dumps() with invalid schema raise exception
    """
    configure_request = CODEC.loads(ConfigureRequest, VALID_CONFIGURE_REQUEST)
    configure_request.csp.interface = \
        'http://schema.skatelescope.org/ska-csp-configure/3.0'

    with pytest.raises(JsonValidationError):
        CODEC.dumps(configure_request, strictness=2)
Example #3
0
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)
Example #4
0
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)