-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathtest_db.py
43 lines (34 loc) · 1.03 KB
/
test_db.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
"""
Tests for the db module.
"""
import unittest
from unittest import mock
from cloudevents.http import CloudEvent
from firebase_functions import core, db_fn
class TestDb(unittest.TestCase):
"""
Tests for the db module.
"""
def test_calls_init_function(self):
hello = None
@core.init
def init():
nonlocal hello
hello = "world"
func = mock.Mock(__name__="example_func")
decorated_func = db_fn.on_value_created(reference="path")(func)
event = CloudEvent(attributes={
"specversion": "1.0",
"id": "id",
"source": "source",
"subject": "subject",
"type": "type",
"time": "2024-04-10T12:00:00.000Z",
"instance": "instance",
"ref": "ref",
"firebasedatabasehost": "firebasedatabasehost",
"location": "location",
},
data={"delta": "delta"})
decorated_func(event)
self.assertEqual(hello, "world")