22
33import os
44import sys
5- from pathlib import Path
65from unittest import mock
76
8- import pytest
9-
107
118def test_extensions_ref_default ():
129 """PUBLIC_SKILLS_BRANCH should default to 'main' when EXTENSIONS_REF is not set."""
1310 # Clear EXTENSIONS_REF if set
1411 with mock .patch .dict (os .environ , {}, clear = False ):
1512 if "EXTENSIONS_REF" in os .environ :
1613 del os .environ ["EXTENSIONS_REF" ]
17-
14+
1815 # Force reload of the module to pick up environment variable
1916 if "openhands.sdk.context.skills.skill" in sys .modules :
2017 del sys .modules ["openhands.sdk.context.skills.skill" ]
21-
18+
2219 from openhands .sdk .context .skills .skill import PUBLIC_SKILLS_BRANCH
23-
24- assert PUBLIC_SKILLS_BRANCH == "main" , \
20+
21+ assert PUBLIC_SKILLS_BRANCH == "main" , (
2522 f"Expected 'main' but got '{ PUBLIC_SKILLS_BRANCH } '"
23+ )
2624
2725
2826def test_extensions_ref_custom_branch ():
@@ -32,11 +30,12 @@ def test_extensions_ref_custom_branch():
3230 # Force reload of the module to pick up environment variable
3331 if "openhands.sdk.context.skills.skill" in sys .modules :
3432 del sys .modules ["openhands.sdk.context.skills.skill" ]
35-
33+
3634 from openhands .sdk .context .skills .skill import PUBLIC_SKILLS_BRANCH
37-
38- assert PUBLIC_SKILLS_BRANCH == "feature-branch" , \
35+
36+ assert PUBLIC_SKILLS_BRANCH == "feature-branch" , (
3937 f"Expected 'feature-branch' but got '{ PUBLIC_SKILLS_BRANCH } '"
38+ )
4039
4140
4241def test_extensions_ref_with_load_public_skills ():
@@ -45,19 +44,23 @@ def test_extensions_ref_with_load_public_skills():
4544 # Force reload of the module
4645 if "openhands.sdk.context.skills.skill" in sys .modules :
4746 del sys .modules ["openhands.sdk.context.skills.skill" ]
48-
47+
4948 from openhands .sdk .context .skills .skill import (
5049 PUBLIC_SKILLS_BRANCH ,
5150 load_public_skills ,
5251 )
53-
52+
5453 # Verify the constant is set correctly
5554 assert PUBLIC_SKILLS_BRANCH == "test-branch"
56-
55+
5756 # Mock the actual git operations to avoid needing a real clone
58- with mock .patch ("openhands.sdk.context.skills.utils.update_skills_repository" ) as mock_update :
59- mock_update .return_value = None # Simulate failed clone (expected behavior for test)
60-
57+ with mock .patch (
58+ "openhands.sdk.context.skills.utils.update_skills_repository"
59+ ) as mock_update :
60+ mock_update .return_value = (
61+ None # Simulate failed clone (expected behavior for test)
62+ )
63+
6164 # This should use test-branch internally
6265 # We expect it to fail/return empty since we're mocking the repo update
6366 try :
@@ -75,9 +78,11 @@ def test_extensions_ref_empty_string():
7578 # Force reload of the module
7679 if "openhands.sdk.context.skills.skill" in sys .modules :
7780 del sys .modules ["openhands.sdk.context.skills.skill" ]
78-
81+
7982 from openhands .sdk .context .skills .skill import PUBLIC_SKILLS_BRANCH
80-
83+
8184 # Empty string should fall back to 'main' via os.environ.get default
82- assert PUBLIC_SKILLS_BRANCH == "" , \
83- "Empty EXTENSIONS_REF should result in empty string (os.environ.get behavior)"
85+ assert PUBLIC_SKILLS_BRANCH == "" , (
86+ "Empty EXTENSIONS_REF should result in empty string "
87+ "(os.environ.get behavior)"
88+ )
0 commit comments