Debian Codegraph @

ansible_collections/community/general/tests/unit/plugins/modules/linode_conftest.py

raw
1 # Copyright (c) Ansible project
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4
5 from __future__ import annotations
6
7 import pytest
8
9
10 @pytest.fixture
11 def api_key(monkeypatch):
12 monkeypatch.setenv("LINODE_API_KEY", "foobar")
13
14
15 @pytest.fixture
16 def auth(monkeypatch):
17 def patched_test_echo(dummy):
18 return []
19
20 monkeypatch.setattr("linode.api.Api.test_echo", patched_test_echo)
21
22
23 @pytest.fixture
24 def access_token(monkeypatch):
25 monkeypatch.setenv("LINODE_ACCESS_TOKEN", "barfoo")
26
27
28 @pytest.fixture
29 def no_access_token_in_env(monkeypatch):
30 try:
31 monkeypatch.delenv("LINODE_ACCESS_TOKEN")
32 except KeyError:
33 pass
34
35
36 @pytest.fixture
37 def default_args():
38 return {"state": "present", "label": "foo"}
39
40
41 @pytest.fixture
42 def mock_linode():
43 class Linode:
44 def delete(self, *args, **kwargs):
45 pass
46
47 @property
48 def _raw_json(self):
49 return {
50 "alerts": {"cpu": 90, "io": 10000, "network_in": 10, "network_out": 10, "transfer_quota": 80},
51 "backups": {
52 "enabled": False,
53 "schedule": {
54 "day": None,
55 "window": None,
56 },
57 },
58 "created": "2018-09-26T08:12:33",
59 "group": "Foobar Group",
60 "hypervisor": "kvm",
61 "id": 10480444,
62 "image": "linode/centos7",
63 "ipv4": ["130.132.285.233"],
64 "ipv6": "2a82:7e00::h03c:46ff:fe04:5cd2/64",
65 "label": "lin-foo",
66 "region": "eu-west",
67 "specs": {"disk": 25600, "memory": 1024, "transfer": 1000, "vcpus": 1},
68 "status": "running",
69 "tags": [],
70 "type": "g6-nanode-1",
71 "updated": "2018-09-26T10:10:14",
72 "watchdog_enabled": True,
73 }
74
75 return Linode()