Skip to content

Commit

Permalink
migrate custom function tests from xlwings repo
Browse files Browse the repository at this point in the history
  • Loading branch information
fzumstein committed Oct 29, 2024
1 parent afd07d5 commit 8f7f4d4
Show file tree
Hide file tree
Showing 4 changed files with 956 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Settings(BaseSettings):
enable_excel_online: bool = True
enable_htmx: bool = True
enable_socketio: bool = True
enable_tests: bool = False
environment: Literal["dev", "qa", "uat", "staging", "prod"] = "prod"
functions_namespace: str = "XLWINGS"
hostname: Optional[str] = None
Expand Down
10 changes: 9 additions & 1 deletion app/custom_functions/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"""

import asyncio
import sys
from pathlib import Path
from typing import Annotated

import numpy as np
Expand All @@ -12,7 +14,7 @@
from xlwings.ext.sql import _sql
from xlwings.server import arg, func, ret

from .. import custom_scripts, utils
from .. import custom_scripts, settings, utils
from ..models import CurrentUser


Expand Down Expand Up @@ -159,3 +161,9 @@ async def hello_with_script(name):
"""This function triggers a custom script, requires XLWINGS_ENABLE_SOCKETIO=true"""
await utils.trigger_script(custom_scripts.hello_world, exclude="MySheet")
return f"Hello {name}!"


# Unit tests
if settings.enable_tests:
sys.path.append(str(Path(__file__).parent.parent.resolve()))
from tests.e2e_custom_functions import *
Loading

0 comments on commit 8f7f4d4

Please sign in to comment.