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

GetAccountInfoTestCase.test_run_api_404()   A

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 8
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_account_info import GetAccountInfoAction
18
19
20
class GetAccountInfoTestCase(OpsGenieBaseActionTestCase):
21
    __test__ = True
22
    action_cls = GetAccountInfoAction
23
24
    def test_run_api_404(self):
25
        action, adapter = self._get_action_status_code(
26
            'GET',
27
            "mock://api.opsgenie.com/v1/json/account/info",
28
            status_code=404)
29
30
        self.assertRaises(ValueError,
31
                          action.run)
32
33
    def test_run_invalid_json(self):
34
        action, adapter = self._get_action_invalid_json(
35
            'GET',
36
            "mock://api.opsgenie.com/v1/json/account/info")
37
        self.assertRaises(ValueError,
38
                          action.run)
39
40
    def test_run_api_success(self):
41
        expected = {u'name': u'opsgenie',
42
                    u'plan': {u'isYearly': True, u'maxUserCount': 1500, u'name': u'Enterprise'},
43
                    u'userCount': 1450}
44
45
        action, adapter = self._get_mocked_action()
46
        adapter.register_uri('GET',
47
                             "mock://api.opsgenie.com/v1/json/account/info",
48
                             text=self.get_fixture_content("get_account_info.json"))
49
50
        result = action.run()
51
        self.assertEqual(result, expected)
52