Skip to content

Commit

Permalink
Fix attempt 2 for empty function namespace (#202)
Browse files Browse the repository at this point in the history
* 2nd attempt to fix empty function namespace

* added back test
  • Loading branch information
fzumstein authored Dec 8, 2024
1 parent 8be9715 commit c93f6b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/templates/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<Metadata>
<SourceLocation resid="Functions.Metadata.Url" />
</Metadata>
{% if settings.functions_namespace %}
{% if settings.functions_namespace or settings.environment != 'prod' %}
<Namespace resid="Functions.Namespace" />
{% endif %}
</ExtensionPoint>
Expand Down Expand Up @@ -127,8 +127,8 @@
<bt:Url id="Functions.Metadata.Url" DefaultValue="{{ base_url_with_app_path }}/xlwings/custom-functions-meta.json" />
</bt:Urls>
<bt:ShortStrings>
{% if settings.functions_namespace %}
<bt:String id="Functions.Namespace" DefaultValue="{{ settings.functions_namespace|upper }}{{ '_' if settings.functions_namespace and settings.environment != 'prod'}}{{ settings.environment | upper if settings.environment != 'prod'}}" />
{% if settings.functions_namespace or settings.environment != 'prod' %}
<bt:String id="Functions.Namespace" DefaultValue="{{ settings.functions_namespace|upper }}{{ '_' if settings.functions_namespace and settings.environment != 'prod'}}{{ settings.environment|upper if settings.environment != 'prod'}}" />
{% endif %}
<bt:String id="MyTab.TabLabel" DefaultValue="{{ settings.project_name }}{{ ' [' + settings.environment + ']' if settings.environment != 'prod'}}" />
<bt:String id="MyCommandsGroup.Label" DefaultValue="MyGroup" />
Expand All @@ -144,7 +144,7 @@
{% if "entraid" in settings.auth_providers %}
<WebApplicationInfo>
<Id>{{ settings.auth_entraid_client_id }}</Id>
<Resource>api://{{ base_url_with_app_path | replace("https://", "") }}/{{ settings.auth_entraid_client_id }}</Resource>
<Resource>api://{{ base_url_with_app_path|replace("https://", "") }}/{{ settings.auth_entraid_client_id }}</Resource>
<Scopes>
<Scope>openid</Scope>
<Scope>profile</Scope>
Expand Down
8 changes: 7 additions & 1 deletion tests/test_router_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@ def test_get_manifest_prod(mocker):
)


def test_empty_function_namespace(mocker):
def test_empty_function_namespace_prod(mocker):
mocker.patch.object(settings, "environment", "prod")
mocker.patch.object(settings, "functions_namespace", "")
response = client.get(f"{settings.app_path}/manifest")
assert "Functions.Namespace" not in response.text


def test_empty_function_namespace_nonprod(mocker):
mocker.patch.object(settings, "functions_namespace", "")
response = client.get(f"{settings.app_path}/manifest")
assert '<bt:String id="Functions.Namespace" DefaultValue="QA" />' in response.text


def test_entraid_auth_deactivated():
response = client.get(f"{settings.app_path}/manifest")
assert "<WebApplicationInfo>" not in response.text
Expand Down

0 comments on commit c93f6b3

Please sign in to comment.