-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NEAT-219] Moved legacy tests π΄ (#428)
* refactor: moved all tests into legacy * refactor: Moved ExcelImporter rules to the correct place
- Loading branch information
Showing
42 changed files
with
796 additions
and
830 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 40 additions & 40 deletions
80
tests/tests_unit/test_package.py β .../tests_unit/test_neat_package_metadata.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
import re | ||
import sys | ||
|
||
from cognite import neat | ||
from tests.config import PYPROJECT_TOML, ROOT | ||
|
||
if sys.version_info >= (3, 11): | ||
import tomllib | ||
else: | ||
import tomli as tomllib | ||
|
||
|
||
def _extract_version_from_file(filename, search_pattern, error_message): | ||
changelog = (ROOT / filename).read_text() | ||
if not (changelog_version_result := re.search(search_pattern, changelog)): | ||
raise ValueError(error_message) | ||
return changelog_version_result.groups()[0] | ||
|
||
|
||
def test_consistent_version_variables(): | ||
pyproject = tomllib.loads(PYPROJECT_TOML.read_text()) | ||
pyproject_toml = pyproject["tool"]["poetry"]["version"] | ||
|
||
changelog_version = _extract_version_from_file( | ||
"./docs/CHANGELOG.md", | ||
r"\[(\d+\.\d+\.\d+)\]", | ||
"Failed to obtain changelog version", | ||
) | ||
docker_version = _extract_version_from_file( | ||
"Makefile", | ||
r'version="(\d+\.\d+\.\d+)"', | ||
"Failed to obtain docker version", | ||
) | ||
assert neat.__version__ == changelog_version == pyproject_toml == docker_version, "Inconsistent version variables" | ||
|
||
|
||
def test_no_spaces_in_sub_folders() -> None: | ||
name_by_location = {path: path.name for path in (ROOT / "cognite").rglob("*") if path.is_dir() and " " in path.name} | ||
|
||
assert not name_by_location, f"Subfolders with spaces found: {name_by_location}" | ||
import re | ||
import sys | ||
|
||
from cognite import neat | ||
from tests.config import PYPROJECT_TOML, ROOT | ||
|
||
if sys.version_info >= (3, 11): | ||
import tomllib | ||
else: | ||
import tomli as tomllib | ||
|
||
|
||
def _extract_version_from_file(filename, search_pattern, error_message): | ||
changelog = (ROOT / filename).read_text() | ||
if not (changelog_version_result := re.search(search_pattern, changelog)): | ||
raise ValueError(error_message) | ||
return changelog_version_result.groups()[0] | ||
|
||
|
||
def test_consistent_version_variables(): | ||
pyproject = tomllib.loads(PYPROJECT_TOML.read_text()) | ||
pyproject_toml = pyproject["tool"]["poetry"]["version"] | ||
|
||
changelog_version = _extract_version_from_file( | ||
"./docs/CHANGELOG.md", | ||
r"\[(\d+\.\d+\.\d+)\]", | ||
"Failed to obtain changelog version", | ||
) | ||
docker_version = _extract_version_from_file( | ||
"Makefile", | ||
r'version="(\d+\.\d+\.\d+)"', | ||
"Failed to obtain docker version", | ||
) | ||
assert neat.__version__ == changelog_version == pyproject_toml == docker_version, "Inconsistent version variables" | ||
|
||
|
||
def test_no_spaces_in_sub_folders() -> None: | ||
name_by_location = {path: path.name for path in (ROOT / "cognite").rglob("*") if path.is_dir() and " " in path.name} | ||
|
||
assert not name_by_location, f"Subfolders with spaces found: {name_by_location}" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 19 additions & 19 deletions
38
...raph/extractors/test_rules2graph_sheet.py β ...raph/extractors/test_rules2graph_sheet.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
from cognite.neat.legacy.graph import extractors as graph_extractor | ||
from cognite.neat.legacy.graph.extractors._graph_capturing_sheet import rules2graph_capturing_sheet | ||
from cognite.neat.legacy.rules.importers import ExcelImporter | ||
from tests import config | ||
|
||
|
||
def test_graph_capturing_sheet(tmp_path, simple_rules): | ||
extractor = graph_extractor.GraphCapturingSheet( | ||
simple_rules, config.GRAPH_CAPTURING_SHEET, store_graph_capturing_sheet=True | ||
) | ||
_ = extractor.extract() | ||
graph_capturing_sheet = extractor.sheet | ||
tmp_sheet = tmp_path / "temp_graph_capturing.xlsx" | ||
|
||
rules2graph_capturing_sheet(simple_rules, tmp_sheet, add_drop_down_list=True, auto_identifier_type="uuid") | ||
resulting_sheet = ExcelImporter(tmp_sheet).to_tables() | ||
assert resulting_sheet.keys() == graph_capturing_sheet.keys() | ||
for sheet_name in resulting_sheet.keys(): | ||
assert list(resulting_sheet[sheet_name].columns) == list(graph_capturing_sheet[sheet_name].columns) | ||
from cognite.neat.legacy.graph import extractors as graph_extractor | ||
from cognite.neat.legacy.graph.extractors._graph_capturing_sheet import rules2graph_capturing_sheet | ||
from cognite.neat.legacy.rules.importers import ExcelImporter | ||
from tests import config | ||
|
||
|
||
def test_graph_capturing_sheet(tmp_path, simple_rules): | ||
extractor = graph_extractor.GraphCapturingSheet( | ||
simple_rules, config.GRAPH_CAPTURING_SHEET, store_graph_capturing_sheet=True | ||
) | ||
_ = extractor.extract() | ||
graph_capturing_sheet = extractor.sheet | ||
tmp_sheet = tmp_path / "temp_graph_capturing.xlsx" | ||
|
||
rules2graph_capturing_sheet(simple_rules, tmp_sheet, add_drop_down_list=True, auto_identifier_type="uuid") | ||
resulting_sheet = ExcelImporter(tmp_sheet).to_tables() | ||
assert resulting_sheet.keys() == graph_capturing_sheet.keys() | ||
for sheet_name in resulting_sheet.keys(): | ||
assert list(resulting_sheet[sheet_name].columns) == list(graph_capturing_sheet[sheet_name].columns) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.