Skip to content

Commit 1e173c1

Browse files
authored
Use proper mock assertion (#444)
* Use proper mock assertion See python/cpython#100690 for details. * Fix uri parsing mock and assertion
1 parent 42f81a7 commit 1e173c1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎redun/tests/test_uri_parsing.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ def test_uri_from_secret(client_mock) -> None:
9090
port = "5555"
9191
dbname = "mydb"
9292

93-
client_mock.return_value.get_secret_value.return_value = {
93+
# client_mock is the mock for get_aws_client function
94+
# We need to mock what it returns (the actual AWS client)
95+
aws_client_mock = client_mock.return_value
96+
aws_client_mock.get_secret_value.return_value = {
9497
"SecretString": json.dumps(
9598
{
9699
"engine": engine,
@@ -104,5 +107,5 @@ def test_uri_from_secret(client_mock) -> None:
104107
}
105108

106109
db_uri = RDB._get_uri_from_secret("mysecret")
107-
assert client_mock.get_secret_value.called_with("mysecret")
110+
aws_client_mock.get_secret_value.assert_called_with(SecretId="mysecret")
108111
assert db_uri == f"postgresql://{username}:{password}@{host}:{port}/{dbname}"

0 commit comments

Comments
 (0)