Skip to content

Commit 2afc2cc

Browse files
devin-ai-integration[bot]rlauer@blues.com
andcommitted
feat: add verify and delete parameters to note.template
Co-Authored-By: rlauer@blues.com <rlauer@blues.com>
1 parent f3f203b commit 2afc2cc

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

notecard/note.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def update(card, file=None, note_id=None, body=None, payload=None):
172172

173173
@validate_card_object
174174
def template(card, file=None, body=None, length=None, port=None,
175-
format=None, compact=None):
175+
format=None, compact=None, verify=None, delete=None):
176176
"""Create a template for new Notes in a Notefile.
177177
178178
Args:
@@ -189,6 +189,9 @@ def template(card, file=None, body=None, length=None, port=None,
189189
additional metadata to save on storage and bandwidth.
190190
compact (bool): Legacy parameter. If True, equivalent to setting
191191
format="compact". Retained for backward compatibility.
192+
verify (bool): When True, verifies the template against existing
193+
notes in the Notefile.
194+
delete (bool): When True, deletes the template from the Notefile.
192195
193196
Returns:
194197
dict: The result of the Notecard request. Returns error object if
@@ -210,6 +213,10 @@ def template(card, file=None, body=None, length=None, port=None,
210213
body[key] = int(value)
211214
req["body"] = body
212215

216+
if verify is not None:
217+
if not isinstance(verify, bool):
218+
return {"err": "verify parameter must be a boolean"}
219+
213220
if length is not None:
214221
if not isinstance(length, int) or length < 0:
215222
return {"err": "Length must be a non-negative integer"}
@@ -235,4 +242,9 @@ def template(card, file=None, body=None, length=None, port=None,
235242
f"Only {allowed_metadata} are allowed.")
236243
}
237244

245+
if verify is not None:
246+
req["verify"] = verify
247+
if delete is not None:
248+
req["delete"] = delete
249+
238250
return card.Transaction(req)

test/fluent_api/test_note_template.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,25 @@ def test_template_compact_with_invalid_metadata(mock_card):
112112
assert not mock_card.Transaction.called
113113

114114

115+
def test_template_verify_parameter(mock_card):
116+
note.template(mock_card, verify=True)
117+
assert mock_card.Transaction.called
118+
assert mock_card.Transaction.call_args[0][0]["verify"] is True
119+
120+
121+
def test_template_verify_invalid_type(mock_card):
122+
result = note.template(mock_card, verify="yes")
123+
assert "err" in result
124+
assert "verify parameter must be a boolean" in result["err"]
125+
assert not mock_card.Transaction.called
126+
127+
128+
def test_template_delete_parameter(mock_card):
129+
note.template(mock_card, delete=True)
130+
assert mock_card.Transaction.called
131+
assert mock_card.Transaction.call_args[0][0]["delete"] is True
132+
133+
115134
def test_template_full_configuration(mock_card):
116135
body = {
117136
"temperature": 21.5,
@@ -126,7 +145,9 @@ def test_template_full_configuration(mock_card):
126145
body=body,
127146
length=32,
128147
port=1,
129-
format="compact"
148+
format="compact",
149+
verify=True,
150+
delete=False
130151
)
131152
assert mock_card.Transaction.called
132153
req = mock_card.Transaction.call_args[0][0]
@@ -135,3 +156,5 @@ def test_template_full_configuration(mock_card):
135156
assert req["length"] == 32
136157
assert req["port"] == 1
137158
assert req["format"] == "compact"
159+
assert req["verify"] is True
160+
assert req["delete"] is False

0 commit comments

Comments
 (0)