-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_storer.py
48 lines (36 loc) · 1.12 KB
/
test_storer.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
37
38
39
40
41
42
43
44
45
46
47
48
import pytest
import os
import re
from project0 import storer, parser
@pytest.fixture
def sample_incidents():
return [
parser.Incident('2/24/2022 1:05',
'2022-00010284',
'1306 168TH AVE NE',
'911 Call Nature Unknown',
'OK0140200'),
parser.Incident('2/24/2022 8:20',
'2022-00003471',
'',
'',
'EMSSTAT')
]
@pytest.fixture(scope='module')
def db():
test_db_file = 'test_normanpd.db'
# Setup
db = storer.create_db(test_db_file)
yield db
# Teardown
if os.path.exists(test_db_file):
os.remove(test_db_file)
def test_create_db_should_return_connectable_db(db):
assert db.check_con()
def test_get_stats_should_return_formatted_natures_count_string(
db, sample_incidents):
inserted_count = db.add_incidents(sample_incidents)
assert inserted_count == len(sample_incidents)
got = db.get_stats()
want = '911 Call Nature Unknown|1'
assert re.search(want, got) is not None