Skip to content

Commit 2981b16

Browse files
committed
Add missing parameters arg to assertions keywords
1 parent 8902334 commit 2981b16

1 file changed

Lines changed: 29 additions & 11 deletions

File tree

src/DatabaseLibrary/assertion.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from typing import Optional
14+
from typing import List, Optional
1515

1616
from robot.api import logger
1717

@@ -22,7 +22,12 @@ class Assertion:
2222
"""
2323

2424
def check_if_exists_in_database(
25-
self, selectStatement: str, sansTran: bool = False, msg: Optional[str] = None, alias: Optional[str] = None
25+
self,
26+
selectStatement: str,
27+
sansTran: bool = False,
28+
msg: Optional[str] = None,
29+
alias: Optional[str] = None,
30+
parameters: Optional[List] = None,
2631
):
2732
"""
2833
Check if any row would be returned by given the input ``selectStatement``. If there are no results, then this will
@@ -43,13 +48,18 @@ def check_if_exists_in_database(
4348
| Check If Exists In Database | SELECT id FROM person WHERE first_name = 'John' | sansTran=True |
4449
"""
4550
logger.info(f"Executing : Check If Exists In Database | {selectStatement}")
46-
if not self.query(selectStatement, sansTran, alias=alias):
51+
if not self.query(selectStatement, sansTran, alias=alias, parameters=parameters):
4752
raise AssertionError(
4853
msg or f"Expected to have have at least one row, but got 0 rows from: '{selectStatement}'"
4954
)
5055

5156
def check_if_not_exists_in_database(
52-
self, selectStatement: str, sansTran: bool = False, msg: Optional[str] = None, alias: Optional[str] = None
57+
self,
58+
selectStatement: str,
59+
sansTran: bool = False,
60+
msg: Optional[str] = None,
61+
alias: Optional[str] = None,
62+
parameters: Optional[List] = None,
5363
):
5464
"""
5565
This is the negation of `check_if_exists_in_database`.
@@ -71,14 +81,19 @@ def check_if_not_exists_in_database(
7181
| Check If Not Exists In Database | SELECT id FROM person WHERE first_name = 'John' | sansTran=True |
7282
"""
7383
logger.info(f"Executing : Check If Not Exists In Database | {selectStatement}")
74-
query_results = self.query(selectStatement, sansTran, alias=alias)
84+
query_results = self.query(selectStatement, sansTran, alias=alias, parameters=parameters)
7585
if query_results:
7686
raise AssertionError(
7787
msg or f"Expected to have have no rows from '{selectStatement}', but got some rows: {query_results}"
7888
)
7989

8090
def row_count_is_0(
81-
self, selectStatement: str, sansTran: bool = False, msg: Optional[str] = None, alias: Optional[str] = None
91+
self,
92+
selectStatement: str,
93+
sansTran: bool = False,
94+
msg: Optional[str] = None,
95+
alias: Optional[str] = None,
96+
parameters: Optional[List] = None,
8297
):
8398
"""
8499
Check if any rows are returned from the submitted ``selectStatement``. If there are, then this will throw an
@@ -99,7 +114,7 @@ def row_count_is_0(
99114
| Row Count is 0 | SELECT id FROM person WHERE first_name = 'John' | sansTran=True |
100115
"""
101116
logger.info(f"Executing : Row Count Is 0 | {selectStatement}")
102-
num_rows = self.row_count(selectStatement, sansTran, alias=alias)
117+
num_rows = self.row_count(selectStatement, sansTran, alias=alias, parameters=parameters)
103118
if num_rows > 0:
104119
raise AssertionError(msg or f"Expected 0 rows, but {num_rows} were returned from: '{selectStatement}'")
105120

@@ -110,6 +125,7 @@ def row_count_is_equal_to_x(
110125
sansTran: bool = False,
111126
msg: Optional[str] = None,
112127
alias: Optional[str] = None,
128+
parameters: Optional[List] = None,
113129
):
114130
"""
115131
Check if the number of rows returned from ``selectStatement`` is equal to the value submitted. If not, then this
@@ -129,7 +145,7 @@ def row_count_is_equal_to_x(
129145
| Row Count Is Equal To X | SELECT id FROM person WHERE first_name = 'John' | 0 | sansTran=True |
130146
"""
131147
logger.info(f"Executing : Row Count Is Equal To X | {selectStatement} | {numRows}")
132-
num_rows = self.row_count(selectStatement, sansTran, alias=alias)
148+
num_rows = self.row_count(selectStatement, sansTran, alias=alias, parameters=parameters)
133149
if num_rows != int(numRows.encode("ascii")):
134150
raise AssertionError(
135151
msg or f"Expected {numRows} rows, but {num_rows} were returned from: '{selectStatement}'"
@@ -142,6 +158,7 @@ def row_count_is_greater_than_x(
142158
sansTran: bool = False,
143159
msg: Optional[str] = None,
144160
alias: Optional[str] = None,
161+
parameters: Optional[List] = None,
145162
):
146163
"""
147164
Check if the number of rows returned from ``selectStatement`` is greater than the value submitted. If not, then
@@ -161,7 +178,7 @@ def row_count_is_greater_than_x(
161178
| Row Count Is Greater Than X | SELECT id FROM person | 1 | sansTran=True |
162179
"""
163180
logger.info(f"Executing : Row Count Is Greater Than X | {selectStatement} | {numRows}")
164-
num_rows = self.row_count(selectStatement, sansTran, alias=alias)
181+
num_rows = self.row_count(selectStatement, sansTran, alias=alias, parameters=parameters)
165182
if num_rows <= int(numRows.encode("ascii")):
166183
raise AssertionError(
167184
msg or f"Expected more than {numRows} rows, but {num_rows} were returned from '{selectStatement}'"
@@ -174,6 +191,7 @@ def row_count_is_less_than_x(
174191
sansTran: bool = False,
175192
msg: Optional[str] = None,
176193
alias: Optional[str] = None,
194+
parameters: Optional[List] = None,
177195
):
178196
"""
179197
Check if the number of rows returned from ``selectStatement`` is less than the value submitted. If not, then this
@@ -194,7 +212,7 @@ def row_count_is_less_than_x(
194212
195213
"""
196214
logger.info(f"Executing : Row Count Is Less Than X | {selectStatement} | {numRows}")
197-
num_rows = self.row_count(selectStatement, sansTran, alias=alias)
215+
num_rows = self.row_count(selectStatement, sansTran, alias=alias, parameters=parameters)
198216
if num_rows >= int(numRows.encode("ascii")):
199217
raise AssertionError(
200218
msg or f"Expected less than {numRows} rows, but {num_rows} were returned from '{selectStatement}'"
@@ -204,7 +222,7 @@ def table_must_exist(
204222
self, tableName: str, sansTran: bool = False, msg: Optional[str] = None, alias: Optional[str] = None
205223
):
206224
"""
207-
Check if the table given exists in the database.
225+
Check if the given table exists in the database.
208226
209227
Set optional input ``sansTran`` to True to run command without an
210228
explicit transaction commit or rollback.

0 commit comments

Comments
 (0)