Skip to content

Commit cb45ec8

Browse files
committed
Save point #3
1 parent 3df80fa commit cb45ec8

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

plugins/cisco_umbrella_destinations/unit_test/test_dlCreate.py

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,32 @@
33

44
sys.path.append(os.path.abspath("../"))
55

6-
from unittest import TestCase
6+
from unittest import TestCase, mock
77
from icon_cisco_umbrella_destinations.connection.connection import Connection
8-
from icon_cisco_umbrella_destinations.actions.dlCreate import DlCreate
8+
from ..icon_cisco_umbrella_destinations.actions.dlCreate import DlCreate
9+
from icon_cisco_umbrella_destinations.actions.dlCreate.schema import Input
910
import json
1011
import logging
12+
from unit_test.mock import STUB_CONNECTION, mock_request_200, STUB_DESTINATION_LIST_ID
1113

1214

1315
class TestDlCreate(TestCase):
14-
def test_dlCreate(self):
15-
"""
16-
DO NOT USE PRODUCTION/SENSITIVE DATA FOR UNIT TESTS
17-
18-
TODO: Implement test cases here
19-
20-
For information on mocking and unit testing please go here:
21-
22-
https://docs.google.com/document/d/1PifePDG1-mBcmNYE8dULwGxJimiRBrax5BIDG_0TFQI/edit?usp=sharing
23-
"""
24-
25-
self.fail("Unimplemented Test Case")
16+
def setUp(self) -> None:
17+
self.connection = Connection()
18+
self.connection.logger = logging.getLogger("Connection logger")
19+
self.connection.connect(STUB_CONNECTION)
20+
21+
self.action = DlCreate()
22+
self.action.connection = self.connection
23+
self.action.logger = logging.getLogger("Action logger")
24+
25+
self.data = {
26+
"access": "allow",
27+
"isGlobal": True,
28+
"name": "NewName",
29+
}
30+
31+
@mock.patch("requests.request", side_effect=mock_request_200)
32+
def test_successful(self, mock_post):
33+
response = self.action.run()
34+
expected_response = []

plugins/cisco_umbrella_destinations/unit_test/test_dlDelete.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from unittest import TestCase, mock
77
from icon_cisco_umbrella_destinations.connection.connection import Connection
88
from icon_cisco_umbrella_destinations.actions.dlDelete import DlDelete
9+
from icon_cisco_umbrella_destinations.actions.dlDelete.schema import Input
910
import json
1011
import logging
1112
from unit_test.mock import STUB_CONNECTION, mock_request_200, STUB_DESTINATION_LIST_ID
@@ -23,7 +24,7 @@ def setUp(self) -> None:
2324

2425
@mock.patch("requests.request", side_effect=mock_request_200)
2526
def test_successful(self, mock_delete):
26-
response = self.action.run()
27-
expected_response = {"success": {"status": {"code": 200, "text": "OK"}, "data": []}}
27+
response = self.action.run({Input.DESTINATIONLISTID: STUB_DESTINATION_LIST_ID})
28+
expected_response = {"success": []}
2829

2930
self.assertEqual(response, expected_response)

0 commit comments

Comments
 (0)