Skip to content

Commit 315d545

Browse files
author
patrick
committed
add more tests
1 parent e3db67c commit 315d545

File tree

9 files changed

+22
-18
lines changed

9 files changed

+22
-18
lines changed

src/qpystructs/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""".editorignore"""
22
__VERSION__ = "0.0.1"
33

4-
from .dicttools import *
5-
from .models import *
6-
from .operations import *
7-
from .dotty import *
4+
from qpystructs.dicttools import *
5+
from qpystructs.models import *
6+
from qpystructs.operations import *
7+
from qpystructs.dotty import *

tests/__init__.py

Whitespace-only changes.

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import os
2+
import sys
3+
print(sys.path)

tests/helper/__init__.py

Whitespace-only changes.
File renamed without changes.

tests/model_for_test.py renamed to tests/helper/demo_models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
from typing import Any, Annotated
44

5-
from qpystructs.models import GenericDataModel
65
from pydantic import BaseModel, Field,ConfigDict
76

7+
from qpystructs import GenericDataModel
8+
89

910
#
1011
# {

tests/test_dicttools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from data_constants import more_dict
1+
from tests.helper.data_constants import more_dict
22
from qpystructs import dicttools
33

44

tests/test_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from model_for_test import DemoModel, DemoModelAlias, DemoUnit, UnitInfo, UnitInfoRawModel
2-
from qpystructs import models, operations
1+
from tests.helper.demo_models import *
2+
from qpystructs import operations
33
from qpystructs.operations import DataFormatType
44
import qpystructs as sr
55

tests/test_operations.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import qpystructs
2-
from data_constants import more_dict, more_json_dict
1+
from tests.helper.data_constants import *
2+
from qpystructs import get_value, set_value, differ, load_from_file
33

44

55
def test_get_value_by_expression():
6-
result = qpystructs.get_value(more_dict, "characters.Lonestar")
6+
result = get_value(more_dict, "characters.Lonestar")
77
assert result == {
88
"id": 55923,
99
"role": "renegade",
@@ -12,27 +12,27 @@ def test_get_value_by_expression():
1212

1313

1414
def test_set_value_by_express():
15-
new_dict = qpystructs.set_value(more_dict, "characters.Lonestar", {})
16-
result = qpystructs.get_value(new_dict, "characters.Lonestar")
15+
new_dict = set_value(more_dict, "characters.Lonestar", {})
16+
result = get_value(new_dict, "characters.Lonestar")
1717
assert result == {}
1818

1919

2020
def test_set_value_by_express_json():
21-
result = qpystructs.set_value(more_json_dict, "characters.Lonestar", {})
22-
result = qpystructs.get_value(result, "characters.Lonestar")
21+
result = set_value(more_json_dict, "characters.Lonestar", {})
22+
result = get_value(result, "characters.Lonestar")
2323
assert result == {}
2424

2525

2626
def test_differ():
27-
result = qpystructs.differ(more_dict, more_json_dict)
27+
result = differ(more_dict, more_json_dict)
2828
print(result)
2929
assert len(result) > 1
3030

3131

3232
def test_query_expression():
3333
query = "locations[?state == 'WA'].name | sort(@) | {WashingtonCities: join(', ', @)}"
34-
result = qpystructs.load_from_file("./structured-data/query-data.json")
35-
query_result = qpystructs.get_value(result, query)
34+
result = load_from_file("./structured-data/query-data.json")
35+
query_result = get_value(result, query)
3636
assert query_result == {
3737
"WashingtonCities": "Bellevue, Olympia, Seattle"
3838
}

0 commit comments

Comments
 (0)