mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-08 03:30:33 -07:00
Fix unit tests
This commit is contained in:
parent
546703f08b
commit
f4ca2f1497
5 changed files with 87 additions and 32 deletions
24
tests/unit/plugins/module_utils/test_mariadb_replication.py
Normal file
24
tests/unit/plugins/module_utils/test_mariadb_replication.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright: (c) 2020, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
|
||||||
|
|
||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from ansible_collections.community.mysql.plugins.module_utils.implementations.mariadb.replication import uses_replica_terminology
|
||||||
|
from ..utils import dummy_cursor_class
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'f_output,c_output,c_ret_type',
|
||||||
|
[
|
||||||
|
(False, '10.5.0-mariadb', 'dict'),
|
||||||
|
(True, '10.5.1-mariadb', 'dict'),
|
||||||
|
(True, '10.6.0-mariadb', 'dict'),
|
||||||
|
(True, '11.5.1-mariadb', 'dict'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
def test_uses_replica_terminology(f_output, c_output, c_ret_type):
|
||||||
|
cursor = dummy_cursor_class(c_output, c_ret_type)
|
||||||
|
assert uses_replica_terminology(cursor) == f_output
|
|
@ -0,0 +1,29 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from ansible_collections.community.mysql.plugins.module_utils.implementations.mariadb.user import (
|
||||||
|
supports_identified_by_password,
|
||||||
|
)
|
||||||
|
from ..utils import dummy_cursor_class
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'function_return,cursor_output,cursor_ret_type',
|
||||||
|
[
|
||||||
|
(True, '10.5.0-mariadb', 'dict'),
|
||||||
|
(True, '10.5.1-mariadb', 'dict'),
|
||||||
|
(True, '10.6.0-mariadb', 'dict'),
|
||||||
|
(True, '11.5.1-mariadb', 'dict'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
def test_supports_identified_by_password(function_return, cursor_output, cursor_ret_type):
|
||||||
|
"""
|
||||||
|
Tests whether 'CREATE USER %s@%s IDENTIFIED BY PASSWORD %s' is supported,
|
||||||
|
which is currently supported by everything besides MySQL >= 8.0.
|
||||||
|
"""
|
||||||
|
cursor = dummy_cursor_class(cursor_output, cursor_ret_type)
|
||||||
|
assert supports_identified_by_password(cursor) == function_return
|
|
@ -6,7 +6,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from ansible_collections.community.mysql.plugins.modules.mysql_replication import uses_replica_terminology
|
from ansible_collections.community.mysql.plugins.module_utils.implementations.mysql.replication import uses_replica_terminology
|
||||||
from ..utils import dummy_cursor_class
|
from ..utils import dummy_cursor_class
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,13 +18,9 @@ from ..utils import dummy_cursor_class
|
||||||
(False, '8.0.0-mysql', 'list'),
|
(False, '8.0.0-mysql', 'list'),
|
||||||
(False, '8.0.11-mysql', 'dict'),
|
(False, '8.0.11-mysql', 'dict'),
|
||||||
(False, '8.0.21-mysql', 'list'),
|
(False, '8.0.21-mysql', 'list'),
|
||||||
(False, '10.5.0-mariadb', 'dict'),
|
|
||||||
(True, '8.0.22-mysql', 'list'),
|
(True, '8.0.22-mysql', 'list'),
|
||||||
(True, '8.1.2-mysql', 'dict'),
|
(True, '8.1.2-mysql', 'dict'),
|
||||||
(True, '9.0.0-mysql', 'list'),
|
(True, '9.0.0-mysql', 'list'),
|
||||||
(True, '10.5.1-mariadb', 'dict'),
|
|
||||||
(True, '10.6.0-mariadb', 'dict'),
|
|
||||||
(True, '11.5.1-mariadb', 'dict'),
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_uses_replica_terminology(f_output, c_output, c_ret_type):
|
def test_uses_replica_terminology(f_output, c_output, c_ret_type):
|
|
@ -0,0 +1,33 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from ansible_collections.community.mysql.plugins.module_utils.implementations.mysql.user import (
|
||||||
|
supports_identified_by_password,
|
||||||
|
)
|
||||||
|
from ..utils import dummy_cursor_class
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'function_return,cursor_output,cursor_ret_type',
|
||||||
|
[
|
||||||
|
(True, '5.5.1-mysql', 'list'),
|
||||||
|
(True, '5.7.0-mysql', 'dict'),
|
||||||
|
(False, '8.0.22-mysql', 'list'),
|
||||||
|
(False, '8.1.2-mysql', 'dict'),
|
||||||
|
(False, '9.0.0-mysql', 'list'),
|
||||||
|
(False, '8.0.0-mysql', 'list'),
|
||||||
|
(False, '8.0.11-mysql', 'dict'),
|
||||||
|
(False, '8.0.21-mysql', 'list'),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
def test_supports_identified_by_password(function_return, cursor_output, cursor_ret_type):
|
||||||
|
"""
|
||||||
|
Tests whether 'CREATE USER %s@%s IDENTIFIED BY PASSWORD %s' is supported,
|
||||||
|
which is currently supported by everything besides MySQL >= 8.0.
|
||||||
|
"""
|
||||||
|
cursor = dummy_cursor_class(cursor_output, cursor_ret_type)
|
||||||
|
assert supports_identified_by_password(cursor) == function_return
|
|
@ -10,37 +10,10 @@ from ansible_collections.community.mysql.plugins.modules.mysql_user import (
|
||||||
has_grant_on_col,
|
has_grant_on_col,
|
||||||
normalize_col_grants,
|
normalize_col_grants,
|
||||||
sort_column_order,
|
sort_column_order,
|
||||||
supports_identified_by_password,
|
|
||||||
)
|
)
|
||||||
from ..utils import dummy_cursor_class
|
from ..utils import dummy_cursor_class
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
'function_return,cursor_output,cursor_ret_type',
|
|
||||||
[
|
|
||||||
(True, '5.5.1-mysql', 'list'),
|
|
||||||
(True, '5.7.0-mysql', 'dict'),
|
|
||||||
(True, '10.5.0-mariadb', 'dict'),
|
|
||||||
(True, '10.5.1-mariadb', 'dict'),
|
|
||||||
(True, '10.6.0-mariadb', 'dict'),
|
|
||||||
(True, '11.5.1-mariadb', 'dict'),
|
|
||||||
(False, '8.0.22-mysql', 'list'),
|
|
||||||
(False, '8.1.2-mysql', 'dict'),
|
|
||||||
(False, '9.0.0-mysql', 'list'),
|
|
||||||
(False, '8.0.0-mysql', 'list'),
|
|
||||||
(False, '8.0.11-mysql', 'dict'),
|
|
||||||
(False, '8.0.21-mysql', 'list'),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
def test_supports_identified_by_password(function_return, cursor_output, cursor_ret_type):
|
|
||||||
"""
|
|
||||||
Tests whether 'CREATE USER %s@%s IDENTIFIED BY PASSWORD %s' is supported,
|
|
||||||
which is currently supported by everything besides MySQL >= 8.0.
|
|
||||||
"""
|
|
||||||
cursor = dummy_cursor_class(cursor_output, cursor_ret_type)
|
|
||||||
assert supports_identified_by_password(cursor) == function_return
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'input_list,grant,output_tuple',
|
'input_list,grant,output_tuple',
|
||||||
[
|
[
|
||||||
|
|
Loading…
Add table
Reference in a new issue