Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/list supported processes duplication #90

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/pg_to_evalscript/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import pkg_resources

implicitly_supported_processes = ["load_collection", "save_result"]

def list_supported_processes():
process_definitions_directory = "javascript_processes"
implicitly_supported_processes = ["load_collection", "save_result", "reduce_dimension", "apply"]
process_definition_files = pkg_resources.resource_listdir("pg_to_evalscript", f"{process_definitions_directory}")
supported_processes_with_files = [
process_definition_file.replace(".js", "") for process_definition_file in process_definition_files
]
return [*implicitly_supported_processes, *supported_processes_with_files]
unique_supported_processes = list(set([*implicitly_supported_processes, *supported_processes_with_files]))
return unique_supported_processes
10 changes: 4 additions & 6 deletions tests/integration_tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
from pg_to_evalscript import convert_from_process_graph, list_supported_processes
from pg_to_evalscript.utils import implicitly_supported_processes

from tests.utils import (
get_process_graph_json,
Expand Down Expand Up @@ -260,13 +261,10 @@ def test_process_graphs_with_scenes(pg_name, example_input, scenes, expected_out


def test_list_supported_processes():
known_supported_processes = [
"load_collection",
"save_result",
"reduce_dimension",
"apply",
known_supported_processes = list(set([
*implicitly_supported_processes,
*get_defined_processes_from_files(),
]
]))
supported_processes = list_supported_processes()
assert len(known_supported_processes) == len(supported_processes)
assert set(known_supported_processes) == set(supported_processes)
Expand Down