-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A bit of cleanup now that we've moved to the PBR system as well
- Loading branch information
Showing
7 changed files
with
107 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
CHANGES | ||
======= | ||
|
||
* Ignore Pipfile.lock | ||
* Fairly extensive refactoring | ||
|
||
v2.0.0 | ||
------ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ hbreader = "*" | |
|
||
[dev-packages] | ||
yadict-compare = "*" | ||
requests = "*" | ||
pyjsg = "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
from jsonasobj.jsonobj import JsonObj, as_dict, as_list, as_json, as_json_obj, get, items, loads, load, setdefault | ||
from jsonasobj.extendednamespace import ExtendedNamespace | ||
|
||
__license__ = 'CC0 1.0 Universal (CC0 1.0) Public Domain Dedication' | ||
__version__ = '1.4.0' | ||
|
||
__all__ = ['JsonObj', 'extendednamespace', 'as_dict', 'as_list', 'as_json', 'as_json_obj', 'get', 'items', | ||
__all__ = ['JsonObj', 'ExtendedNamespace', 'as_dict', 'as_list', 'as_json', 'as_json_obj', 'get', 'items', | ||
'load', 'loads', 'setdefault'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import unittest | ||
|
||
from pyjsg.jsglib import JSGObjectMap, JSGString, JSGPattern, ArrayFactory, JSGContext, Integer | ||
from pyjsg.validate_json import JSGPython | ||
|
||
from json import loads as jsonloads | ||
from jsonasobj import as_json | ||
|
||
# Taken from | ||
class HEX(JSGString): | ||
pattern = JSGPattern(r'[0-9]|[A-F]|[a-f]') | ||
|
||
|
||
_CONTEXT = JSGContext() | ||
|
||
|
||
class BuiltinSyntaxTestCase(unittest.TestCase): | ||
""" This tests a somewhat mysterious issue focused around the as_json function """ | ||
# From: https://github.com/hsolbrig/pyjsg/blob/master/tests/test_issues/test_builtins_issue.py | ||
def test_1(self): | ||
x = JSGPython('''doc { | ||
v1: @string, | ||
v2: @number, | ||
v3: @int, | ||
v4: @bool, | ||
v5: @null, | ||
v6: @array, | ||
v7: @object | ||
} | ||
obj {a: . , }''') | ||
|
||
rslt = x.conforms(''' | ||
{ "v1": "This is text!", | ||
"v2": -117.432e+2, | ||
"v3": -100173, | ||
"v4": false, | ||
"v5": null, | ||
"v6": [12, "text", null], | ||
"v7": {"q": "life", "a": 42} | ||
}''') | ||
self.assertTrue(rslt.success) | ||
|
||
def test_basic_map(self): | ||
""" Test sometimes failing pyjsg use case for jsonasobj """ | ||
# From: https://github.com/hsolbrig/pyjsg/blob/master/tests/test_jsglib/test_objectmap.py#L15 | ||
class IntObjectMap(JSGObjectMap): | ||
_name_filter = HEX | ||
_value_type = ArrayFactory('', _CONTEXT, Integer, 0, None) | ||
|
||
def __init__(self, | ||
**_kwargs): | ||
super().__init__(_CONTEXT, **_kwargs) | ||
|
||
x = IntObjectMap() | ||
x.E = [1,2,3] | ||
self.assertTrue(x._is_valid()) | ||
self.assertEqual(as_json(x), as_json(jsonloads('{"E":[1,2,3]}'))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import unittest | ||
from copy import deepcopy | ||
from dataclasses import dataclass | ||
|
||
from jsonasobj import JsonObj | ||
|
||
|
||
class YAMLRoot(JsonObj): | ||
pass | ||
|
||
|
||
@dataclass | ||
class Test(YAMLRoot): | ||
v: int | ||
|
||
|
||
class MissingConstructorTestCase(unittest.TestCase): | ||
def test_missing_constructor(self): | ||
""" Test for reasonable behavior when the constructor wasn't invoked """ | ||
z = Test(1) | ||
deepcopy(z) # Invokes test for local __deepcopy__ in z | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters