def test_rfi_get_size() -> None: integration = Integration() session_object = { "Session": { "S": { "Buffer_Size": { "Default": 1024, "Global": { "Y": 2048, "Z": 512, }, "Local": { "S": { "Y": 8192, } }, } } } } error = RecordFluxError() # pylint: disable = protected-access integration._add_integration_object(Path("p.rfi"), session_object, error) error.propagate() assert integration.get_size(ID("P::S"), None, None) == 1024 assert integration.get_size(ID("P::S"), ID("X"), ID("S")) == 1024 assert integration.get_size(ID("P::S"), ID("X"), ID("S")) == 1024 assert integration.get_size(ID("P::S"), ID("X"), None) == 1024 assert integration.get_size(ID("P::S2"), ID("X"), None) == 4096 assert integration.get_size(ID("P::S"), ID("Y"), None) == 2048 assert integration.get_size(ID("P::S"), ID("Y"), ID("S")) == 8192 assert integration.get_size(ID("P::S"), ID("Z"), None) == 512 assert integration.get_size(ID("P::S"), ID("Z"), ID("S")) == 512
def test_rfi_add_integration(rfi_content: str, match_error: str) -> None: # pydantic messages end with the type of the error in parentheses. regex = re.compile( ( "^test.rfi:0:0: parser: error: 1 validation error for " rf"IntegrationFile.*{match_error} \([^()]*\)$" ), re.DOTALL, ) yaml = YAML() content = yaml.load(rfi_content) error = RecordFluxError() integration = Integration() with pytest.raises(RecordFluxError, match=regex): # pylint: disable = protected-access integration._add_integration_object(Path("test.rfi"), content, error) error.propagate()