MCPcopy Index your code
hub / github.com/saltstack/salt / test_query_error

Function test_query_error

tests/pytests/unit/modules/test_mysql.py:890–901  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

888
889@pytest.mark.skipif(not HAS_PYMYSQL, reason="Could not import pymysql")
890def test_query_error():
891 connect_mock = MagicMock()
892 with patch.object(mysql, "_connect", connect_mock):
893 with patch.dict(mysql.__salt__, {"config.option": MagicMock()}):
894 # Use the OperationalError from the salt mysql module because that
895 # exception can come from either MySQLdb or pymysql
896 side_effect = mysql.OperationalError(9999, "Something Went Wrong")
897 with patch.object(mysql, "_execute", MagicMock(side_effect=side_effect)):
898 mysql.query("testdb", "SELECT * FROM testdb")
899 assert "mysql.error" in mysql.__context__
900 expected = "MySQL Error 9999: Something Went Wrong"
901 assert mysql.__context__["mysql.error"] == expected
902
903
904def test_plugin_add():

Callers

nothing calls this directly

Calls 1

queryMethod · 0.80

Tested by

no test coverage detected