From ecdc0be8259104a576166b3f2d99a6c70da47ae8 Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Fri, 8 Mar 2024 17:06:53 -0300 Subject: [PATCH] Refactor directory_component.build() and add tests for loading projects and mdx files --- tests/test_data_components.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/test_data_components.py b/tests/test_data_components.py index 3d8838514..0a7cee8b6 100644 --- a/tests/test_data_components.py +++ b/tests/test_data_components.py @@ -153,7 +153,17 @@ def test_directory_without_mocks(): # the directory component can be used to load the projects # and we can validate if the contents are the same as the projects variable setup_path = Path(setup.__file__).parent / "starter_projects" - result = directory_component.build( - str(setup_path), types=["json"], use_multithreading=False - ) - assert len(result) == len(projects) + results = directory_component.build(str(setup_path), use_multithreading=False) + assert len(results) == len(projects) + # each result is a Record that contains the content attribute + # each are dict that are exactly the same as one of the projects + for result in results: + assert result.text in projects + + # in ../docs/docs/components there are many mdx files + # check if the directory component can load them + # just check if the number of results is the same as the number of files + docs_path = Path(__file__).parent.parent / "docs" / "docs" / "components" + results = directory_component.build(str(docs_path), use_multithreading=False) + docs_files = list(docs_path.glob("*.mdx")) + assert len(results) == len(docs_files)