Skip to content

Commit 2fe840a

Browse files
committed
Merge commit '8c1df9ee00aa38d3b4097048b7a36b5643517ec5' into dev
* commit '8c1df9ee00aa38d3b4097048b7a36b5643517ec5': Update release badge and version file refactored bug test to regression test # Conflicts: # tests/unit/type_safe/type_safe_core/_regression/test_Type_Safe__regression.py
2 parents 6bea4f0 + 8c1df9e commit 2fe840a

File tree

5 files changed

+38
-40
lines changed

5 files changed

+38
-40
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OSBot-Utils
22

3-
![Current Release](https://img.shields.io/badge/release-v3.52.1-blue)
3+
![Current Release](https://img.shields.io/badge/release-v3.53.0-blue)
44
![Python](https://img.shields.io/badge/python-3.8+-green)
55
![Type-Safe](https://img.shields.io/badge/Type--Safe-✓-brightgreen)
66
![Caching](https://img.shields.io/badge/Caching-Built--In-orange)

osbot_utils/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v3.52.1
1+
v3.53.0

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "osbot_utils"
3-
version = "v3.52.1"
3+
version = "v3.53.0"
44
description = "OWASP Security Bot - Utils"
55
authors = ["Dinis Cruz <[email protected]>"]
66
license = "MIT"

tests/unit/type_safe/type_safe_core/_bugs/test_Type_Safe__bugs.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -100,39 +100,3 @@ class Extended_Config(Base_Config):
100100
Extended_Config() # BUG: should auto-assign Extended_Handler
101101

102102

103-
104-
def test__bug__set__json__serialisation_issue(self):
105-
import json
106-
from typing import Dict, Set
107-
from osbot_utils.testing.__ import __
108-
from osbot_utils.type_safe.primitives.domains.identifiers.Safe_Id import Safe_Id
109-
from osbot_utils.type_safe.primitives.domains.identifiers.Edge_Id import Edge_Id
110-
111-
class An_Class(Type_Safe):
112-
an_dict : Dict[Safe_Id , Set[Edge_Id ]]
113-
safe_id = Safe_Id('safe-id_jlqsh')
114-
edge_id = Edge_Id('6106b8e7')
115-
an_class = An_Class()
116-
an_class.an_dict[safe_id] = {edge_id}
117-
118-
#assert an_class.obj () == __(an_dict=__(safe_id_jlqsh={'6106b8e7'})) # BUG, this should be list, right? i.e. ['6106b8e7']
119-
#assert an_class.json() == {'an_dict': {'safe-id_jlqsh': {'6106b8e7'}}} # BUG, this should be list, right? i.e. ['6106b8e7']
120-
121-
assert an_class.obj () == __(an_dict=__(safe_id_jlqsh=['6106b8e7'])) # FIXED
122-
assert an_class.json() == {'an_dict': {'safe-id_jlqsh': ['6106b8e7']}} # FIXED
123-
124-
# error_message = "Object of type set is not JSON serializable"
125-
# with pytest.raises(TypeError, match=error_message): # BUG
126-
# json.dumps(an_class.json())
127-
assert json.dumps(an_class.json()) == '{"an_dict": {"safe-id_jlqsh": ["6106b8e7"]}}'
128-
129-
assert type(an_class.json().get('an_dict') ) is dict
130-
#assert type(an_class.json().get('an_dict').get('safe-id_jlqsh')) is set # BUG
131-
assert type(an_class.json().get('an_dict').get('safe-id_jlqsh')) is list # FIXED
132-
assert json.loads(json.dumps(an_class.json())) == an_class.json()
133-
error_message = "Type Set cannot be instantiated; use set() instead"
134-
# with pytest.raises(TypeError, match=re.escape(error_message)):
135-
# An_Class.from_json(an_class.json()) # BUG
136-
assert An_Class.from_json(an_class.json()).obj() == an_class.obj() # FIXED
137-
assert An_Class.from_json(an_class.json()).json() == an_class.json() # FIXED
138-

tests/unit/type_safe/type_safe_core/_regression/test_Type_Safe__regression.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import re
22
import sys
3+
import json
34
import pytest
45
from enum import Enum
56
from decimal import Decimal
67
from typing import Optional, Union, List, Dict, get_origin, Type, ForwardRef, Any, Set, Tuple
78
from unittest import TestCase
89
from unittest.mock import patch
10+
from osbot_utils.type_safe.primitives.domains.identifiers.Safe_Id import Safe_Id
11+
from osbot_utils.type_safe.primitives.domains.identifiers.Edge_Id import Edge_Id
912
from osbot_utils.type_safe.primitives.core.Safe_Float import Safe_Float
1013
from osbot_utils.type_safe.primitives.domains.identifiers.safe_str.Safe_Str__Id import Safe_Str__Id
1114
from osbot_utils.type_safe.primitives.domains.identifiers.Obj_Id import Obj_Id
@@ -2024,6 +2027,7 @@ class An_Class(Type_Safe):
20242027
assert With_Base ().json() == {'an_str': ''} # FIXED
20252028
assert With_Base ().obj () == __(an_str='') # FIXED
20262029

2030+
20272031
def test__regression__cls_kwargs_creates_ghost_objects_ignoring_provided_kwargs(self):
20282032
"""
20292033
BUG: __cls_kwargs__() creates default values for ALL annotated fields,
@@ -2247,4 +2251,34 @@ def test__regression__ghost_object_creation(self):
22472251

22482252
with Cache__Hash__Generator() as _:
22492253
#assert _.config is None # BUG
2250-
assert _.config is not None # FIXED
2254+
assert _.config is not None # FIXED
2255+
2256+
def test__regression__set__json__serialisation_issue(self):
2257+
2258+
class An_Class(Type_Safe):
2259+
an_dict : Dict[Safe_Id , Set[Edge_Id ]]
2260+
safe_id = Safe_Id('safe-id_jlqsh')
2261+
edge_id = Edge_Id('6106b8e7')
2262+
an_class = An_Class()
2263+
an_class.an_dict[safe_id] = {edge_id}
2264+
2265+
#assert an_class.obj () == __(an_dict=__(safe_id_jlqsh={'6106b8e7'})) # BUG, this should be list, right? i.e. ['6106b8e7']
2266+
#assert an_class.json() == {'an_dict': {'safe-id_jlqsh': {'6106b8e7'}}} # BUG, this should be list, right? i.e. ['6106b8e7']
2267+
2268+
assert an_class.obj () == __(an_dict=__(safe_id_jlqsh=['6106b8e7'])) # FIXED
2269+
assert an_class.json() == {'an_dict': {'safe-id_jlqsh': ['6106b8e7']}} # FIXED
2270+
2271+
# error_message = "Object of type set is not JSON serializable"
2272+
# with pytest.raises(TypeError, match=error_message): # BUG
2273+
# json.dumps(an_class.json())
2274+
assert json.dumps(an_class.json()) == '{"an_dict": {"safe-id_jlqsh": ["6106b8e7"]}}'
2275+
2276+
assert type(an_class.json().get('an_dict') ) is dict
2277+
#assert type(an_class.json().get('an_dict').get('safe-id_jlqsh')) is set # BUG
2278+
assert type(an_class.json().get('an_dict').get('safe-id_jlqsh')) is list # FIXED
2279+
assert json.loads(json.dumps(an_class.json())) == an_class.json()
2280+
error_message = "Type Set cannot be instantiated; use set() instead"
2281+
# with pytest.raises(TypeError, match=re.escape(error_message)):
2282+
# An_Class.from_json(an_class.json()) # BUG
2283+
assert An_Class.from_json(an_class.json()).obj() == an_class.obj() # FIXED
2284+
assert An_Class.from_json(an_class.json()).json() == an_class.json() # FIXED

0 commit comments

Comments
 (0)