Skip to content

Commit 2750a53

Browse files
committed
fix: error-related-to-package-tests
1 parent a48ef1d commit 2750a53

6 files changed

Lines changed: 23 additions & 18 deletions

File tree

.github/workflows/tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
- name: Install the project
2121
run: uv sync --locked --all-extras --dev
2222

23-
- name: Run tests
23+
- name: Install in development mode
24+
run: uv pip install -e .
2425

26+
- name: Run tests
2527
run: uv run pytest tests

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ server:
44
test:
55
uv run pytest tests/
66

7-
.PHONY: server test
7+
upload:
8+
uv run twine upload dist/*
9+
10+
.PHONY: server test upload
811

912

1013

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ classifiers = [
2121
]
2222

2323
[project.scripts]
24-
code2postman-mcp = "src.code2postman_mcp.server:main"
24+
code2postman-mcp = "code2postman_mcp.server:main"
2525

2626
[tool.setuptools]
2727
package-dir = {"" = "src"}

tests/unit/postman_generator_mcp/tools/test_handle_files.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import re
55
from unittest.mock import patch, mock_open, MagicMock
66

7-
from src.code2postman_mcp.consts.excluded_files import Language
8-
from src.code2postman_mcp.tools.handle_files import get_tree_directory_from_path, read_file
7+
from code2postman_mcp.consts.excluded_files import Language
8+
from code2postman_mcp.tools.handle_files import get_tree_directory_from_path, read_file
99

1010

1111
class TestGetTreeDirectoryFromPath:
@@ -36,7 +36,7 @@ def mock_directory_structure(self):
3636
}
3737

3838
@pytest.mark.asyncio
39-
@patch("src.code2postman_mcp.tools.handle_files.Language")
39+
@patch("code2postman_mcp.tools.handle_files.Language")
4040
async def test_get_tree_directory_invalid_language(self, mock_language):
4141
"""Test if the function raises ValueError for invalid language"""
4242
# Set up the mock to correctly handle the comparison and enum value listing
@@ -55,7 +55,7 @@ async def test_get_tree_directory_invalid_language(self, mock_language):
5555

5656
@pytest.mark.asyncio
5757
@patch("os.walk")
58-
@patch("src.code2postman_mcp.utils.files.count_lines")
58+
@patch("code2postman_mcp.utils.files.count_lines")
5959
@patch("os.path.basename", return_value="root")
6060
async def test_get_tree_directory_python(self, mock_basename, mock_count_lines, mock_walk, mock_directory_structure):
6161
"""Test tree directory generation for Python language"""
@@ -89,7 +89,7 @@ async def test_get_tree_directory_python(self, mock_basename, mock_count_lines,
8989

9090
@pytest.mark.asyncio
9191
@patch("os.walk")
92-
@patch("src.code2postman_mcp.utils.files.count_lines")
92+
@patch("code2postman_mcp.utils.files.count_lines")
9393
@patch("os.path.relpath")
9494
@patch("os.path.basename")
9595
async def test_get_tree_directory_with_different_languages(self, mock_basename, mock_relpath,

tests/unit/postman_generator_mcp/tools/test_handle_postman.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from unittest.mock import patch, mock_open, MagicMock
55
import tempfile
66

7-
from src.code2postman_mcp.tools.handle_postman import (
7+
from code2postman_mcp.tools.handle_postman import (
88
validate_string,
99
validate_dict,
1010
create_postman_collection,
@@ -99,7 +99,7 @@ class TestAddPostmanCollectionItem:
9999
@patch("builtins.open", new_callable=mock_open)
100100
@patch("json.load")
101101
@patch("json.dump")
102-
@patch("src.code2postman_mcp.utils.files.is_a_valid_item", return_value=True)
102+
@patch("code2postman_mcp.utils.files.is_a_valid_item", return_value=True)
103103
async def test_add_item_success(self, mock_valid_item, mock_json_dump, mock_json_load, mock_file):
104104
"""Test adding an item to a collection successfully"""
105105
file_path = "test_collection.json"
@@ -131,7 +131,7 @@ async def test_add_item_success(self, mock_valid_item, mock_json_dump, mock_json
131131
@patch("builtins.open", new_callable=mock_open)
132132
@patch("json.load")
133133
@patch("json.dump")
134-
@patch("src.code2postman_mcp.utils.files.is_a_valid_item", return_value=True)
134+
@patch("code2postman_mcp.utils.files.is_a_valid_item", return_value=True)
135135
async def test_add_item_no_items_array(self, mock_valid_item, mock_json_dump, mock_json_load, mock_file):
136136
"""Test adding an item to a collection with no items array"""
137137
file_path = "test_collection.json"
@@ -157,7 +157,7 @@ async def test_add_item_no_items_array(self, mock_valid_item, mock_json_dump, mo
157157
@pytest.mark.asyncio
158158
@patch("builtins.open", new_callable=mock_open)
159159
@patch("json.load")
160-
@patch("src.code2postman_mcp.utils.files.is_a_valid_item", return_value=False)
160+
@patch("code2postman_mcp.utils.files.is_a_valid_item", return_value=False)
161161
async def test_add_invalid_item(self, mock_valid_item, mock_json_load, mock_file):
162162
"""Test adding an invalid item to a collection"""
163163
file_path = "test_collection.json"
@@ -549,7 +549,7 @@ async def test_update_variable_not_found(self, mock_json_dump, mock_json_load, m
549549

550550
class TestAddPostmanCollectionFolder:
551551
@pytest.mark.asyncio
552-
@patch("src.code2postman_mcp.tools.handle_postman.add_postman_collection_item")
552+
@patch("code2postman_mcp.tools.handle_postman.add_postman_collection_item")
553553
async def test_add_folder_success(self, mock_add_item):
554554
"""Test adding a folder to a collection successfully"""
555555
file_path = "test_collection.json"
@@ -569,7 +569,7 @@ async def test_add_folder_success(self, mock_add_item):
569569
assert args[1]["item"] == items
570570

571571
@pytest.mark.asyncio
572-
@patch("src.code2postman_mcp.tools.handle_postman.add_postman_collection_item")
572+
@patch("code2postman_mcp.tools.handle_postman.add_postman_collection_item")
573573
async def test_add_folder_no_items(self, mock_add_item):
574574
"""Test adding a folder without items to a collection"""
575575
file_path = "test_collection.json"
@@ -593,7 +593,7 @@ class TestAddItemToFolder:
593593
@patch("builtins.open", new_callable=mock_open)
594594
@patch("json.load")
595595
@patch("json.dump")
596-
@patch("src.code2postman_mcp.utils.files.is_a_valid_item", return_value=True)
596+
@patch("code2postman_mcp.utils.files.is_a_valid_item", return_value=True)
597597
async def test_add_item_to_folder_success(self, mock_valid_item, mock_json_dump, mock_json_load, mock_file):
598598
"""Test adding an item to a folder successfully"""
599599
file_path = "test_collection.json"
@@ -628,7 +628,7 @@ async def test_add_item_to_folder_success(self, mock_valid_item, mock_json_dump,
628628
@pytest.mark.asyncio
629629
@patch("builtins.open", new_callable=mock_open)
630630
@patch("json.load")
631-
@patch("src.code2postman_mcp.utils.files.is_a_valid_item", return_value=False)
631+
@patch("code2postman_mcp.utils.files.is_a_valid_item", return_value=False)
632632
async def test_add_invalid_item_to_folder(self, mock_valid_item, mock_json_load, mock_file):
633633
"""Test adding an invalid item to a folder"""
634634
file_path = "test_collection.json"
@@ -651,7 +651,7 @@ async def test_add_invalid_item_to_folder(self, mock_valid_item, mock_json_load,
651651
@pytest.mark.asyncio
652652
@patch("builtins.open", new_callable=mock_open)
653653
@patch("json.load")
654-
@patch("src.code2postman_mcp.utils.files.is_a_valid_item", return_value=True)
654+
@patch("code2postman_mcp.utils.files.is_a_valid_item", return_value=True)
655655
async def test_add_item_to_nonexistent_folder(self, mock_valid_item, mock_json_load, mock_file):
656656
"""Test adding an item to a non-existent folder"""
657657
file_path = "test_collection.json"

tests/unit/postman_generator_mcp/utils/test_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33
from unittest.mock import patch, mock_open, MagicMock
44

5-
from src.code2postman_mcp.utils.files import count_lines
5+
from code2postman_mcp.utils.files import count_lines
66

77

88
class TestCountLines:

0 commit comments

Comments
 (0)