blob: 90330c04de99a87aa6cdc39f24f5b895a9c4ef3d (
plain)
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
|
###############################################################################
# Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) #
# and others #
# #
# All rights reserved. This program and the accompanying materials #
# are made available under the terms of the Apache License, Version 2.0 #
# which accompanies this distribution, and is available at #
# http://www.apache.org/licenses/LICENSE-2.0 #
###############################################################################
from discover.events.event_network_update import EventNetworkUpdate
from test.event_based_scan.test_data.event_payload_network_update import \
EVENT_PAYLOAD_NETWORK_UPDATE, \
NETWORK_DOCUMENT, UPDATED_NETWORK_FIELDS
from test.event_based_scan.test_event import TestEvent
class TestNetworkUpdate(TestEvent):
def test_handle_network_update(self):
self.values = EVENT_PAYLOAD_NETWORK_UPDATE
self.payload = self.values['payload']
network = NETWORK_DOCUMENT
self.inv.get_by_id.return_value = network
res = EventNetworkUpdate().handle(self.env, self.values)
self.assertTrue(res.result)
self.assertTrue(self.inv.values_replace.called)
self.assertTrue(self.inv.set.called)
# check that all changed fields are updated
call_args, _ = self.inv.set.call_args
# Assert that all updated fields have been added to db
self.assertTrue(all(item in call_args[0].items()
for item in UPDATED_NETWORK_FIELDS.items()))
|