-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
django_createcachetable: new module (#8412)
* django_createcachetabe: new module * add --noinput arg to testcase * add module to BOTMETA * rename module class name * fix examples documentation * remove unused config * adjust version_added
- Loading branch information
Showing
6 changed files
with
141 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2024, Alexei Znamensky <russoz@gmail.com> | ||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
from __future__ import absolute_import, division, print_function | ||
__metaclass__ = type | ||
|
||
DOCUMENTATION = """ | ||
module: django_createcachetable | ||
author: | ||
- Alexei Znamensky (@russoz) | ||
short_description: Wrapper for C(django-admin createcachetable) | ||
version_added: 9.1.0 | ||
description: | ||
- This module is a wrapper for the execution of C(django-admin createcachetable). | ||
extends_documentation_fragment: | ||
- community.general.attributes | ||
- community.general.django | ||
- community.general.django.database | ||
attributes: | ||
check_mode: | ||
support: full | ||
diff_mode: | ||
support: none | ||
""" | ||
|
||
EXAMPLES = """ | ||
- name: Create cache table in the default database | ||
community.general.django_createcachetable: | ||
settings: myproject.settings | ||
- name: Create cache table in the other database | ||
community.general.django_createcachetable: | ||
database: myotherdb | ||
settings: fancysite.settings | ||
pythonpath: /home/joedoe/project/fancysite | ||
venv: /home/joedoe/project/fancysite/venv | ||
""" | ||
|
||
RETURN = """ | ||
run_info: | ||
description: Command-line execution information. | ||
type: dict | ||
returned: success and O(verbosity) >= 3 | ||
""" | ||
|
||
from ansible_collections.community.general.plugins.module_utils.django import DjangoModuleHelper | ||
|
||
|
||
class DjangoCreateCacheTable(DjangoModuleHelper): | ||
module = dict( | ||
supports_check_mode=True, | ||
) | ||
django_admin_cmd = "createcachetable" | ||
django_admin_arg_order = "noinput database dry_run" | ||
_django_args = ["noinput", "database", "dry_run"] | ||
_check_mode_arg = "dry_run" | ||
|
||
|
||
def main(): | ||
DjangoCreateCacheTable.execute() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
13 changes: 13 additions & 0 deletions
13
tests/unit/plugins/modules/test_django_createcachetable.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright (c) Alexei Znamensky (russoz@gmail.com) | ||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
from __future__ import (absolute_import, division, print_function) | ||
__metaclass__ = type | ||
|
||
|
||
from ansible_collections.community.general.plugins.modules import django_createcachetable | ||
from .helper import Helper | ||
|
||
|
||
Helper.from_module(django_createcachetable, __name__) |
15 changes: 15 additions & 0 deletions
15
tests/unit/plugins/modules/test_django_createcachetable.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) Alexei Znamensky (russoz@gmail.com) | ||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
--- | ||
- id: command_success | ||
input: | ||
settings: whatever.settings | ||
run_command_calls: | ||
- command: [/testbin/python, -m, django, createcachetable, --no-color, --settings=whatever.settings, --noinput, --database=default] | ||
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true} | ||
rc: 0 | ||
out: "whatever\n" | ||
err: "" |