community.mysql/tests/unit/plugins/modules/test_mysql_replication.py
Steve Teahan 06907715d7
mysql_user: fixed encrypted option for MySQL 8.0 and test coverage ()
* mysql_user: fixed encrypted option for MySQL 8.0 and test coverage

The purpose of this change was originally to expand test coverage to
unblock , but an issue was detected with the encrypted parameter on
MySQL 8.0 in the process of writing the tests. Additionally,
user_password_update_test.yml had been disabled at some point, so I
opted to replace it with two new files that will focus on the password
and plugin auth paths.

* Updated tests to cover a couple of missing branches

* Skip tests that rely on sha256_password if pymysql < 0.9

* Cover the case where pymysql isn't installed for plugin tests

* Added better plugin auth checking to tests and other minor changes

* Fixed version detection to explicitly handle MariaDB

* Removed unneeded import from previous change

* Remove whitespace that was introduced by change that was removed

* Added unit tests for missing coverage
2021-01-14 08:27:05 +03:00

32 lines
1.1 KiB
Python

# -*- 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.modules.mysql_replication import uses_replica_terminology
from ..utils import dummy_cursor_class
@pytest.mark.parametrize(
'f_output,c_output,c_ret_type',
[
(False, '5.5.1-mysql', 'list'),
(False, '5.7.0-mysql', 'dict'),
(False, '8.0.0-mysql', 'list'),
(False, '8.0.11-mysql', 'dict'),
(False, '8.0.21-mysql', 'list'),
(False, '10.5.0-mariadb', 'dict'),
(True, '8.0.22-mysql', 'list'),
(True, '8.1.2-mysql', 'dict'),
(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):
cursor = dummy_cursor_class(c_output, c_ret_type)
assert uses_replica_terminology(cursor) == f_output