-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_input_store.py
36 lines (31 loc) · 994 Bytes
/
test_input_store.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
28
29
30
31
32
33
34
35
36
import pytest
import json
import os
from struct_module.input_store import InputStore
@pytest.fixture
def input_store(tmp_path):
input_file = tmp_path / "input.json"
return InputStore(input_file)
def test_load(input_store):
data = {"key": "value"}
with open(input_store.input_file, 'w') as f:
json.dump(data, f)
input_store.load()
assert input_store.get_data() == data
def test_get_value(input_store):
data = {"key": "value"}
with open(input_store.input_file, 'w') as f:
json.dump(data, f)
input_store.load()
assert input_store.get_value("key") == "value"
def test_set_value(input_store):
input_store.load()
input_store.set_value("key", "value")
assert input_store.get_value("key") == "value"
def test_save(input_store):
input_store.load()
input_store.set_value("key", "value")
input_store.save()
with open(input_store.input_file, 'r') as f:
data = json.load(f)
assert data == {"key": "value"}