Try to unit test but give up for now
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
9256beabdb
commit
a0374d8209
1
library/__init__.py
Normal file
1
library/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
VERSION = "0.0.1"
|
@ -1,11 +1,43 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
import traceback
|
||||||
|
from subprocess import check_output
|
||||||
|
|
||||||
|
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||||
|
|
||||||
DOCUMENTATION = """
|
DOCUMENTATION = """
|
||||||
---
|
---
|
||||||
module: gandi_dns
|
module: gandi_dns
|
||||||
short_description: Manage Gandi DNS entries
|
short_description: Manage Gandi DNS entries.
|
||||||
|
requirements:
|
||||||
|
- python >= 3.8
|
||||||
|
- gandi.cli >= 1.5
|
||||||
|
author:
|
||||||
|
- Luke Murphy (@decentral1se)
|
||||||
|
options:
|
||||||
|
apirest_key:
|
||||||
|
description:
|
||||||
|
- The Gandi REST API key. It may also be specified by the
|
||||||
|
C(API_REST_KEY) environment variable. See the
|
||||||
|
U(https://github.com/Gandi/gandi.cli/blob/master/gandicli.man.rst#environment)
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
domain:
|
||||||
|
description: The domain name you're working with.
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
ipv4:
|
||||||
|
description: The IP v4 address that the domain refers to.
|
||||||
|
type: str
|
||||||
|
required: true
|
||||||
|
state:
|
||||||
|
description:
|
||||||
|
- The desired instance state.
|
||||||
|
type: str
|
||||||
|
choices:
|
||||||
|
- present
|
||||||
|
- absent
|
||||||
|
required: true
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
@ -14,12 +46,41 @@ EXAMPLES = """
|
|||||||
apirest_key: "{{ apirest_key }}"
|
apirest_key: "{{ apirest_key }}"
|
||||||
domain: foobar.autonomic.zone
|
domain: foobar.autonomic.zone
|
||||||
ipv4: 192.168.1.2
|
ipv4: 192.168.1.2
|
||||||
|
state: present
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
RETURN = """
|
||||||
|
TODO
|
||||||
|
"""
|
||||||
|
|
||||||
|
GANDI_CLI_IMP_ERR = None
|
||||||
|
try:
|
||||||
|
from gandi import cli # noqa
|
||||||
|
|
||||||
|
HAS_GANDI_DEPENDENCY = True
|
||||||
|
except ImportError:
|
||||||
|
GANDI_IMP_ERR = traceback.format_exc()
|
||||||
|
HAS_GANDI_DEPENDENCY = False
|
||||||
|
|
||||||
|
|
||||||
|
def retrieve_domain(domain):
|
||||||
|
"""Retrieve information about an existing domain."""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
"""Module entrypoint."""
|
||||||
module = AnsibleModule(argument_spec={})
|
module = AnsibleModule(argument_spec={})
|
||||||
module.exit_json(changed=False, meta={"TO": "DO"})
|
|
||||||
|
if not HAS_GANDI_DEPENDENCY:
|
||||||
|
msg = missing_required_lib('gandi.cli')
|
||||||
|
module.fail_json(msg=msg, exception=GANDI_IMP_ERR)
|
||||||
|
|
||||||
|
if module.params['state'] == 'present':
|
||||||
|
domain = retrieve_domain(module.params['domain'])
|
||||||
|
|
||||||
|
if module.params['state'] == 'absent':
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -11,6 +11,12 @@ skip = .venv, .tox
|
|||||||
include_trailing_comma = True
|
include_trailing_comma = True
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
name = autonomic.gandi
|
name = library
|
||||||
author = decentral1se
|
author = decentral1se
|
||||||
version = 0.0.1
|
version = 0.0.1
|
||||||
|
|
||||||
|
[options]
|
||||||
|
packages = find:
|
||||||
|
install_requires =
|
||||||
|
ansible >= 2.9.6, <= 2.10
|
||||||
|
gandi.cli >= 1.5, <= 2.0
|
||||||
|
9
test/conftest.py
Normal file
9
test/conftest.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
from ansible.module_utils import basic
|
||||||
|
from ansible.module_utils._text import to_bytes
|
||||||
|
|
||||||
|
|
||||||
|
def set_module_args(args):
|
||||||
|
args = json.dumps({'ANSIBLE_MODULE_ARGS': args})
|
||||||
|
basic._ANSIBLE_ARGS = to_bytes(args)
|
@ -1,2 +1,9 @@
|
|||||||
def test_gandi_dns():
|
import pytest
|
||||||
assert 666 == 666
|
|
||||||
|
gandi_cli = pytest.importorskip('gandi.cli')
|
||||||
|
|
||||||
|
|
||||||
|
def test_TODO():
|
||||||
|
# TODO(decentral1se): discover how to unit test the module so far it is a
|
||||||
|
# bit of a weird python packaging circus and there are lots of errors...
|
||||||
|
assert 1 == 1
|
||||||
|
Loading…
Reference in New Issue
Block a user