diff options
author | 2017-07-27 15:04:07 +0000 | |
---|---|---|
committer | 2017-07-27 15:04:07 +0000 | |
commit | 162c03ef301396072c1934e7e7e0c40a841b4fe2 (patch) | |
tree | 7a2a2781949252436450ff5832962785061a774a /app/test/event_based_scan/test_interface_delete.py | |
parent | b88c78e3cf2bef22aa2f1c4d0bf305e303bc15f0 (diff) | |
parent | 7e83d0876ddb84a45e130eeba28bc40ef53c074b (diff) |
Merge "Calipso initial release for OPNFV"
Diffstat (limited to 'app/test/event_based_scan/test_interface_delete.py')
-rw-r--r-- | app/test/event_based_scan/test_interface_delete.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/test/event_based_scan/test_interface_delete.py b/app/test/event_based_scan/test_interface_delete.py new file mode 100644 index 0000000..b156758 --- /dev/null +++ b/app/test/event_based_scan/test_interface_delete.py @@ -0,0 +1,44 @@ +############################################################################### +# 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_interface_delete import EventInterfaceDelete +from discover.fetchers.api.api_access import ApiAccess +from test.event_based_scan.test_data.event_payload_interface_delete import EVENT_PAYLOAD_INTERFACE_DELETE, NETWORK_DOC, \ + EVENT_PAYLOAD_REGION, PORT_DOC, ROUTER_DOCUMENT, HOST, VNIC_DOCS +from test.event_based_scan.test_event import TestEvent +from utils.util import encode_router_id + + +class TestInterfaceDelete(TestEvent): + def test_handle_interface_delete(self): + self.values = EVENT_PAYLOAD_INTERFACE_DELETE + self.payload = self.values['payload'] + self.interface = self.payload['router_interface'] + + self.port_id = self.interface['port_id'] + self.host_id = self.values["publisher_id"].replace("network.", "", 1) + self.router_id = encode_router_id(self.host_id, self.interface['id']) + + # set document for instance deleting. + self.set_item(NETWORK_DOC) + self.set_item(PORT_DOC) + self.set_item(ROUTER_DOCUMENT) + self.set_item(HOST) + self.set_item(VNIC_DOCS[0]) + ApiAccess.regions = EVENT_PAYLOAD_REGION + + # delete interface + EventInterfaceDelete().handle(self.env, self.values) + + # assert data + router_doc = self.inv.get_by_id(self.env, ROUTER_DOCUMENT['id']) + self.assertNotIn(NETWORK_DOC['id'], router_doc['network']) + + self.assert_empty_by_id(PORT_DOC['id']) + self.assert_empty_by_id(VNIC_DOCS[0]['id']) |