Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions awacs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def JSONrepr(self) -> dict:
self.validate()
return self.resource

def to_json(self, indent: int = 4, sort_keys: bool = True) -> str:
def to_json(self, indent: Optional[int] = 4, sort_keys: bool = True) -> str:
p = self.properties
return json.dumps(p, cls=awsencode, indent=indent, sort_keys=sort_keys)

Expand Down Expand Up @@ -149,7 +149,7 @@ def getdata(self, data: Union[AWSObject, T]) -> Union[str, None, T]:
else:
return data

def to_json(self, indent: int = 4, sort_keys: bool = True) -> str:
def to_json(self, indent: Optional[int] = 4, sort_keys: bool = True) -> str:
p = self
return json.dumps(p, cls=awsencode, indent=indent, sort_keys=sort_keys)

Expand Down
16 changes: 16 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ def test_invalid_property(self):
"'statement'",
)

def test_to_json(self):
p = PolicyDocument(Version="2012-10-17", Statement=[])

self.assertEqual(
p.to_json(),
'{\n "Statement": [],\n "Version": "2012-10-17"\n}',
)

def test_to_json_indent_non(self):
p = PolicyDocument(Version="2012-10-17", Statement=[])

self.assertEqual(
p.to_json(indent=None),
'{"Statement": [], "Version": "2012-10-17"}',
)


class TestAWSProperty(unittest.TestCase):
def test_prop_value_type_mismatch_expect_list(self):
Expand Down