aboutsummaryrefslogtreecommitdiffstats
path: root/app/test/event_based_scan/test_network_add.py
blob: 943dcf4c5c80fa71e2d7a9a065f7cb57872f9a8f (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
###############################################################################
# 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_add import EventNetworkAdd
from test.event_based_scan.test_data.event_payload_network_add \
    import EVENT_PAYLOAD_NETWORK_ADD, NETWORK_DOCUMENT
from test.event_based_scan.test_event import TestEvent


class TestNetworkAdd(TestEvent):

    def test_handle_network_add(self):
        self.values = EVENT_PAYLOAD_NETWORK_ADD

        self.inv.get_by_id.return_value = None

        # add network document
        res = EventNetworkAdd().handle(self.env, self.values)

        self.assertTrue(res.result)
        self.inv.set.assert_called_with(NETWORK_DOCUMENT)