Skip to content

Commit 83b4c0f

Browse files
committed
Adding FlatStore spec.
1 parent f963014 commit 83b4c0f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tests/unit/lib/__init__.py

Whitespace-only changes.

tests/unit/lib/flat_store_spec.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from describe import expect
2+
from intercom.lib.flat_store import FlatStore
3+
4+
5+
class DescribeIntercomFlatStore:
6+
7+
def it_raises_if_you_try_to_set_or_merge_in_nested_hash_structures(self):
8+
data = FlatStore()
9+
with expect.raise_error(ValueError):
10+
data["thing"] = [1]
11+
with expect.raise_error(ValueError):
12+
data["thing"] = {1: 2}
13+
with expect.raise_error(ValueError):
14+
FlatStore(**{"1": {2: 3}})
15+
16+
def it_raises_if_you_try_to_use_a_non_string_key(self):
17+
data = FlatStore()
18+
with expect.raise_error(ValueError):
19+
data[1] = "something"
20+
21+
def it_sets_and_merges_valid_entries(self):
22+
data = FlatStore()
23+
data["a"] = 1
24+
data["b"] = 2
25+
expect(data["a"]) == 1
26+
expect(data["b"]) == 2
27+
data = FlatStore(a=1, b=2)
28+
expect(data["a"]) == 1
29+
expect(data["b"]) == 2

0 commit comments

Comments
 (0)