Skip to content

Commit 3a70f52

Browse files
authored
Merge pull request #33 from nevermined-io/feat/add-uuid-methods
feat: add uuid method
2 parents 45f0ea2 + 5be954d commit 3a70f52

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

payments_py/utils.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import uuid
2+
13
def snake_to_camel(name):
24
"""
35
Convert snake_case to camelCase.
@@ -7,4 +9,30 @@ def snake_to_camel(name):
79
810
"""
911
components = name.split('_')
10-
return components[0] + ''.join(x.title() for x in components[1:])
12+
return components[0] + ''.join(x.title() for x in components[1:])
13+
14+
def generate_step_id():
15+
"""
16+
Generate a random ID.
17+
18+
:return: str
19+
20+
"""
21+
return f"step-${str(uuid.uuid4())}"
22+
23+
def is_id_valid(id):
24+
"""
25+
Check if the ID is valid.
26+
27+
:param id: str
28+
:return: bool
29+
30+
"""
31+
if not id.startswith('step-'):
32+
return False
33+
else:
34+
try:
35+
uuid.UUID(id)
36+
return True
37+
except ValueError:
38+
return False

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "payments-py"
3-
version = "0.4.6"
3+
version = "0.4.7"
44
description = ""
55
authors = ["enrique <enrique@nevermined.io>"]
66
readme = "README.md"

tests/protocol_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ async def test_AIQueryApi_create_task_in_plan_purchased(ai_query_api_build_fixtu
164164
# @pytest.mark.asyncio(loop_scope="session")
165165
# async def test_AI_send_task(ai_query_api_build_fixture):
166166
# builder = ai_query_api_build_fixture
167-
# task = builder.ai_protocol.create_task('did:nv:a8983b06c0f25fb4064fc61d6527c84ca1813e552bfad5fa1c974caa3c5ccf49',
168-
# {'query': 'https://www.youtube.com/watch?v=-_4GZnGl55c&t=5s', 'name': 'Summarize video'})
167+
# task = builder.ai_protocol.create_task('did:nv:7d86045034ea8a14c133c487374a175c56a9c6144f6395581435bc7f1dc9e0cc',
168+
# {'query': 'https://www.youtube.com/watch?v=SB7eoaVw4Sk', 'name': 'Summarize video'})
169169
# print('Task created:', task.json())
170170

171171
# @pytest.mark.asyncio(loop_scope="session")

0 commit comments

Comments
 (0)