Skip to content

Commit 4cc7c69

Browse files
committed
fix more tests
1 parent 7fcd1b6 commit 4cc7c69

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

tests/unit/plugins/module_utils/test_mariadb_replication.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def test_uses_replica_terminology(f_output, c_output, c_ret_type):
4141
@pytest.mark.parametrize(
4242
'user,password,expected_query',
4343
[
44-
(None, None, "START GROUP_REPLICATION"),
44+
(None, None, "START GROUP_REPLICATION "),
4545
("repl_user", None, "START GROUP_REPLICATION USER='repl_user'"),
46-
(None, "repl_pass", "START GROUP_REPLICATION"),
47-
("repl_user", "repl_pass", "START GROUP_REPLICATION USER='repl_user' PASSWORD='repl_pass'"),
46+
(None, "repl_pass", "START GROUP_REPLICATION PASSWORD='repl_pass'"),
47+
("repl_user", "repl_pass", "START GROUP_REPLICATION USER='repl_user', PASSWORD='repl_pass'"),
4848
]
4949
)
5050
def test_start_group_replication(user, password, expected_query):
@@ -66,7 +66,6 @@ def test_start_group_replication(user, password, expected_query):
6666

6767
assert result is True
6868
assert cursor.executed_queries[0] == expected_query
69-
assert cursor.executed_queries[1] == "SHOW STATUS LIKE 'group_replication_status';"
7069

7170

7271
def test_stop_group_replication():
@@ -82,7 +81,6 @@ def test_stop_group_replication():
8281

8382
assert result is True
8483
assert cursor.executed_queries[0] == "STOP GROUP_REPLICATION"
85-
assert cursor.executed_queries[1] == "SHOW STATUS LIKE 'group_replication_status';"
8684

8785

8886
def test_start_group_replication_fail():

tests/unit/plugins/module_utils/test_mysql_replication.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ def test_uses_replica_terminology(f_output, c_output, c_ret_type):
4545
@pytest.mark.parametrize(
4646
'user,password,expected_query',
4747
[
48-
(None, None, "START GROUP_REPLICATION"),
48+
(None, None, "START GROUP_REPLICATION "),
4949
("repl_user", None, "START GROUP_REPLICATION USER='repl_user'"),
50-
(None, "repl_pass", "START GROUP_REPLICATION"),
51-
("repl_user", "repl_pass", "START GROUP_REPLICATION USER='repl_user' PASSWORD='repl_pass'"),
50+
(None, "repl_pass", "START GROUP_REPLICATION PASSWORD='repl_pass'"),
51+
("repl_user", "repl_pass", "START GROUP_REPLICATION USER='repl_user', PASSWORD='repl_pass'"),
5252
]
5353
)
5454
def test_start_group_replication(user, password, expected_query):
@@ -62,15 +62,14 @@ def test_start_group_replication(user, password, expected_query):
6262

6363
chm = []
6464
if user:
65-
chm.append(" USER='%s'" % user)
65+
chm.append("USER='%s'" % user)
6666
if password:
67-
chm.append(" PASSWORD='%s'" % password)
67+
chm.append("PASSWORD='%s'" % password)
6868

6969
result = startgroupreplication(module, cursor, chm, False)
7070

7171
assert result is True
7272
assert cursor.executed_queries[0] == expected_query
73-
assert cursor.executed_queries[1] == "SHOW STATUS LIKE 'group_replication_status';"
7473

7574

7675
def test_stop_group_replication():
@@ -86,22 +85,17 @@ def test_stop_group_replication():
8685

8786
assert result is True
8887
assert cursor.executed_queries[0] == "STOP GROUP_REPLICATION"
89-
assert cursor.executed_queries[1] == "SHOW STATUS LIKE 'group_replication_status';"
9088

9189

9290
def test_start_group_replication_fail():
9391
"""Test startgroupreplication function with failure."""
9492
from ansible_collections.community.mysql.plugins.modules.mysql_replication import startgroupreplication
95-
import pymysql
9693

9794
cursor = MockCursor(status="ERROR")
9895
module = type('obj', (object,), {
9996
'fail_json': lambda msg: None,
10097
})
10198

102-
# Mock the Warning exception
103-
pymysql.Warning = Exception
104-
10599
result = startgroupreplication(module, cursor, [], True)
106100

107101
assert result is False
@@ -110,16 +104,12 @@ def test_start_group_replication_fail():
110104
def test_stop_group_replication_fail():
111105
"""Test stopgroupreplication function with failure."""
112106
from ansible_collections.community.mysql.plugins.modules.mysql_replication import stopgroupreplication
113-
import pymysql
114107

115108
cursor = MockCursor(status="ERROR")
116109
module = type('obj', (object,), {
117110
'fail_json': lambda msg: None,
118111
})
119112

120-
# Mock the Warning exception
121-
pymysql.Warning = Exception
122-
123113
result = stopgroupreplication(module, cursor, True)
124114

125115
assert result is False

0 commit comments

Comments
 (0)