summaryrefslogtreecommitdiffstats
path: root/ansible_collections/purestorage/fusion/tests/helpers.py
blob: 76d51b6f71e45fc4e501bf2ca89d43eb04598b22 (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
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-

# (c) 2023, Denys Denysyev (ddenysyev@purestorage.com)
# GNU General Public License v3.0+ (see COPYING.GPLv3 or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function

__metaclass__ = type

import fusion as purefusion

from http import HTTPStatus


class ApiExceptionsMockGenerator:
    @staticmethod
    def create_permission_denied():
        status = HTTPStatus.FORBIDDEN
        return purefusion.rest.ApiException(status=status, reason=status.phrase)

    @staticmethod
    def create_conflict():
        status = HTTPStatus.CONFLICT
        return purefusion.rest.ApiException(status=status, reason=status.phrase)

    @staticmethod
    def create_not_found():
        status = HTTPStatus.NOT_FOUND
        return purefusion.rest.ApiException(status=status, reason=status.phrase)


class OperationResultsDict(dict):
    """dot.notation access to dictionary attributes"""

    __getattr__ = dict.get
    __setattr__ = dict.__setitem__
    __delattr__ = dict.__delitem__