-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
27 lines (21 loc) · 842 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from unittest import TestCase
import json
from prune import prune
class SimpleCases(TestCase):
def test_simple_tree_with_single_key(self):
tree = { "a": 1 }
prune(tree, ["a"])
self.assertEquals(json.dumps(tree), "{}")
def test_simple_tree_with_two_keys(self):
tree = { "a": 1, "b": 2 }
prune(tree, ["a"])
self.assertEquals(json.dumps(tree), '{"b": 2}')
class AdvancedCases(TestCase):
def test_simple_tree_with_nested_key(self):
tree = { "a": 1, "b": { "c": "d" } }
prune(tree, ["b.c"])
self.assertEquals(json.dumps(tree), '{"a": 1, "b": {}}')
def test_simple_tree_with_single_key(self):
tree = { "a": 1, "b": { "c": "d", "e": "f" } }
prune(tree, ["b.c"])
self.assertEquals(json.dumps(tree), '{"a": 1, "b": {"e": "f"}}')