def test_codec_loads_from_file_without_schema_validation_for_old_json(mock_fn): """ Verify that the schema validation does not apply when it is set to false for pre ADR-18 JSON schema """ cwd, _ = os.path.split(__file__) test_new_json_data = os.path.join(cwd, "testfile_sample_configure.json") CODEC.load_from_file(ConfigureRequest, test_new_json_data, False) assert mock_fn.call_count == 0 mock_fn.assert_not_called()
def test_loads_from_file_with_invalid_schema_and_validation_set_to_true(): """ Verify that the codec unmarshalls objects correctly with schema validation and Test it with loading a invalid ADR18-configure request from a JSON file """ cwd, _ = os.path.split(__file__) test_new_json_data = os.path.join( cwd, "testfile_invalid_configure_ADR_18.json") with pytest.raises(JsonValidationError): CODEC.load_from_file(ConfigureRequest, test_new_json_data)
def test_read_a_file_from_disk(): """ Test for loading a configure request from a JSON file """ cwd, _ = os.path.split(__file__) test_data = os.path.join(cwd, "testfile_sample_configure.json") result = CODEC.load_from_file(ConfigureRequest, test_data) dish_config = DishConfiguration(ReceiverBand.BAND_1) assert result.dish == dish_config test_new_json_data = os.path.join(cwd, "testfile_sample_configure_ADR_18.json") result_data = CODEC.load_from_file(ConfigureRequest, test_new_json_data) dish_config = DishConfiguration(ReceiverBand.BAND_1) assert result_data.dish == dish_config
def oet_compose_sub(): cdm_file_path = 'resources/test_data/OET_integration/example_allocate.json' LOGGER.info("cdm_file_path :" + str(cdm_file_path)) update_resource_config_file(cdm_file_path) cdm_request_object = cdm_CODEC.load_from_file(AssignResourcesRequest, cdm_file_path) cdm_request_object.dish.receptor_ids = [str(x).zfill(4) for x in range(1, 5)] subarray = SubArray(1) LOGGER.info("Allocated Subarray is :" + str(subarray)) return subarray.allocate_from_cdm(cdm_request_object)
def assign(): sdp_block = update_resource_config_file(file) resource_request: AssignResourcesRequest = cdm_CODEC.load_from_file( AssignResourcesRequest, file) resource_request.dish.receptor_ids = [ str(x).zfill(4) for x in range(1, dishes + 1) ] self.SubArray.allocate_from_cdm(resource_request) return sdp_block
def test_codec_loads_from_file_with_schema_validation(mock_fn): """ Verify that the codec unmarshalls objects correctly with schema validation and Test it with loading a valid ADR18-configure request from a JSON file """ csp_config = csp_config_for_test() cwd, _ = os.path.split(__file__) test_new_json_data = os.path.join(cwd, "testfile_sample_configure_ADR_18.json") result_data = CODEC.load_from_file(ConfigureRequest, test_new_json_data) assert result_data.csp == csp_config assert mock_fn.call_count == 1 mock_fn.assert_called_once()
def test_loads_from_file_with_invalid_schema_and_validation_set_to_false( mock_fn): """ Verify that the codec unmarshalls objects correctly without schema validation and Test it with loading a invalid ADR18-configure request from a JSON file """ cwd, _ = os.path.split(__file__) test_new_json_data = os.path.join( cwd, "testfile_invalid_configure_ADR_18.json") result_data = CODEC.load_from_file(ConfigureRequest, test_new_json_data, False) assert result_data.csp.subarray_config is None assert mock_fn.call_count == 0 mock_fn.assert_not_called()