Completed
Push — master ( 8bd3ea...0334cb )
by Tomaz
03:06
created

ScheduleWhoIsOnCallTestCase.test_run_api_success()   A

Complexity

Conditions 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
dl 0
loc 10
rs 9.4285
1
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
2
# contributor license agreements.  See the NOTICE file distributed with
3
# this work for additional information regarding copyright ownership.
4
# The ASF licenses this file to You under the Apache License, Version 2.0
5
# (the "License"); you may not use this file except in compliance with
6
# the License.  You may obtain a copy of the License at
7
#
8
#     http://www.apache.org/licenses/LICENSE-2.0
9
#
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
15
from opsgenie_base_test_case import OpsGenieBaseActionTestCase
16
17
from get_schedule_who_is_on_call import ScheduleWhoIsOnCallAction
18
19
20
class ScheduleWhoIsOnCallTestCase(OpsGenieBaseActionTestCase):
21
    __test__ = True
22
    action_cls = ScheduleWhoIsOnCallAction
23
24
    def test_run_api_invalid_ley(self):
25
        action, adapter = self._get_action_status_code(
26
            "GET",
27
            "mock://api.opsgenie.com/v1/json/schedule/whoIsOnCall",
28
            status_code=400)
29
        self.assertRaises(ValueError,
30
                          action.run)
31
32
    def test_run_api_404(self):
33
        action, adapter = self._get_action_status_code(
34
            "GET",
35
            "mock://api.opsgenie.com/v1/json/schedule/whoIsOnCall",
36
            status_code=404)
37
        self.assertRaises(ValueError,
38
                          action.run)
39
40
    def test_run_invalid_json(self):
41
        action, adapter = self._get_action_invalid_json(
42
            "GET",
43
            "mock://api.opsgenie.com/v1/json/schedule/whoIsOnCall")
44
45
        self.assertRaises(ValueError,
46
                          action.run)
47
48
    def test_run_api_success(self):
49
        expected = self.load_json("schedule_whoIsOnCall.json")
50
51
        action, adapter = self._get_mocked_action()
52
        adapter.register_uri('GET',
53
                             "mock://api.opsgenie.com/v1/json/schedule/whoIsOnCall",
54
                             text=self.get_fixture_content("schedule_whoIsOnCall.json"))
55
56
        result = action.run()
57
        self.assertEqual(result, expected)
58