Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Ensure function name is saved to JSON
  • Loading branch information
StephenNneji committed Feb 12, 2026
commit 002cd0ad2b7f6cfdd9cb2774f835a88abc1df256
6 changes: 5 additions & 1 deletion ratapi/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,12 +956,16 @@ def make_data_dict(item):
elif field == "custom_files":

def make_custom_file_dict(item):
return {
file_dict = {
"name": item.name,
"filename": item.filename,
"language": item.language,
"path": try_relative_to(item.path, filepath.parent),
}
if item.name != item.function_name:
file_dict["function_name"] = item.function_name

return file_dict

json_dict["custom_files"] = [make_custom_file_dict(file) for file in attr]

Expand Down
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8537,3 +8537,11 @@ def absorption():
"""The project from the absorption example."""
project, _ = ratapi.examples.absorption()
return project


@pytest.fixture
def absorption_different_function():
"""The project from the absorption example with a function name different from filename."""
project, _ = ratapi.examples.absorption()
project.custom_files[0].function_name = "test_func"
return project
1 change: 1 addition & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,7 @@ def test_wrap_extend(test_project, class_list: str, model_type: str, field: str,
"domains_custom_layers",
"domains_custom_xy",
"absorption",
"absorption_different_function",
],
)
def test_save_load(project, request):
Expand Down
Loading