agentstr 0.1.13__tar.gz → 0.1.15__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. agentstr-0.1.15/MANIFEST.in +7 -0
  2. {agentstr-0.1.13/src/agentstr.egg-info → agentstr-0.1.15}/PKG-INFO +6 -8
  3. {agentstr-0.1.13 → agentstr-0.1.15}/README.md +0 -4
  4. {agentstr-0.1.13 → agentstr-0.1.15}/pyproject.toml +10 -6
  5. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr/buyer.py +2 -2
  6. {agentstr-0.1.13 → agentstr-0.1.15/src/agentstr.egg-info}/PKG-INFO +6 -8
  7. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr.egg-info/SOURCES.txt +1 -5
  8. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr.egg-info/requires.txt +4 -2
  9. agentstr-0.1.13/MANIFEST.in +0 -3
  10. agentstr-0.1.13/tests/test_buyer.py +0 -110
  11. agentstr-0.1.13/tests/test_merchant.py +0 -154
  12. agentstr-0.1.13/tests/test_nostr_integration.py +0 -98
  13. agentstr-0.1.13/tests/test_nostr_mocked.py +0 -107
  14. {agentstr-0.1.13 → agentstr-0.1.15}/LICENSE +0 -0
  15. {agentstr-0.1.13 → agentstr-0.1.15}/setup.cfg +0 -0
  16. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr/__init__.py +0 -0
  17. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr/buyer.pyi +0 -0
  18. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr/merchant.py +0 -0
  19. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr/merchant.pyi +0 -0
  20. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr/models.py +0 -0
  21. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr/models.pyi +0 -0
  22. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr/nostr.py +0 -0
  23. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr/nostr.pyi +0 -0
  24. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr/py.typed +0 -0
  25. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr.egg-info/dependency_links.txt +0 -0
  26. {agentstr-0.1.13 → agentstr-0.1.15}/src/agentstr.egg-info/top_level.txt +0 -0
@@ -0,0 +1,7 @@
1
+ include LICENSE README.md
2
+ global-exclude __pycache__
3
+ global-exclude *.py[cod]
4
+
5
+ # Explicitly exclude tests/ from source distribution (sdist)
6
+ global-exclude tests/*
7
+ global-exclude tests/**/*
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: agentstr
3
- Version: 0.1.13
3
+ Version: 0.1.15
4
4
  Summary: Tools for a Nostr agentic ecosystem
5
5
  Author-email: Synvya <synvya@synvya.com>
6
6
  License: MIT
@@ -8,7 +8,7 @@ Project-URL: Homepage, https://www.synvya.com
8
8
  Project-URL: Repository, https://github.com/synvya/agentstr
9
9
  Project-URL: Documentation, https://github.com/synvya/agentstr#readme
10
10
  Project-URL: BugTracker, https://github.com/synvya/agentstr/issues
11
- Requires-Python: <3.13,>=3.9
11
+ Requires-Python: <3.13,>=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: agno>=1.1.1
@@ -24,8 +24,10 @@ Requires-Dist: mypy>=1.0; extra == "dev"
24
24
  Requires-Dist: pylint>=3.0; extra == "dev"
25
25
  Provides-Extra: examples
26
26
  Requires-Dist: python-dotenv>=1.0; extra == "examples"
27
- Requires-Dist: cassandra-driver>=3.29.2; extra == "examples"
28
- Requires-Dist: cassio>=0.1.10; extra == "examples"
27
+ Requires-Dist: psycopg[binary]>=3.2.5; extra == "examples"
28
+ Requires-Dist: sqlalchemy>=2.0.0; extra == "examples"
29
+ Requires-Dist: nest-asyncio>=1.6.0; extra == "examples"
30
+ Requires-Dist: pgvector>=0.3.6; extra == "examples"
29
31
  Requires-Dist: fastapi>=0.110.0; extra == "examples"
30
32
  Requires-Dist: uvicorn>=0.30.0; extra == "examples"
31
33
 
@@ -126,7 +128,3 @@ This project is licensed under the MIT License - see the [LICENSE](https://githu
126
128
  - [Rust-Nostr](https://rust-nostr.org) - For their Python Nostr SDK
127
129
  - [Nostr Protocol](https://github.com/nostr-protocol/nips) - For the protocol specification
128
130
 
129
- This software includes the following software licensed under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0):
130
- - [DataStax Python Driver for Apache Cassandra](https://github.com/datastax/python-driver)
131
- - [cassIO](https://github.com/CassioML/cassio). This library is not maintained anymore. We will need to replace it with a new library.
132
-
@@ -95,7 +95,3 @@ This project is licensed under the MIT License - see the [LICENSE](https://githu
95
95
  - [Rust-Nostr](https://rust-nostr.org) - For their Python Nostr SDK
96
96
  - [Nostr Protocol](https://github.com/nostr-protocol/nips) - For the protocol specification
97
97
 
98
- This software includes the following software licensed under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0):
99
- - [DataStax Python Driver for Apache Cassandra](https://github.com/datastax/python-driver)
100
- - [cassIO](https://github.com/CassioML/cassio). This library is not maintained anymore. We will need to replace it with a new library.
101
-
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "agentstr"
7
- version = "0.1.13"
7
+ version = "0.1.15"
8
8
  description = "Tools for a Nostr agentic ecosystem"
9
9
  readme = "README.md"
10
- requires-python = ">=3.9, <3.13"
10
+ requires-python = ">=3.10, <3.13"
11
11
  license = { text = "MIT" }
12
12
  authors = [
13
13
  {name = "Synvya", email = "synvya@synvya.com"}
@@ -30,8 +30,10 @@ dev = [
30
30
  ]
31
31
  examples = [
32
32
  "python-dotenv>=1.0",
33
- "cassandra-driver>=3.29.2",
34
- "cassio>=0.1.10",
33
+ "psycopg[binary]>=3.2.5",
34
+ "sqlalchemy>=2.0.0",
35
+ "nest-asyncio>=1.6.0",
36
+ "pgvector>=0.3.6",
35
37
  "fastapi>=0.110.0",
36
38
  "uvicorn>=0.30.0",
37
39
  ]
@@ -45,6 +47,8 @@ BugTracker = "https://github.com/synvya/agentstr/issues"
45
47
  [tool.setuptools]
46
48
  package-dir = {"" = "src"}
47
49
  packages = ["agentstr"]
50
+ exclude-package-data = {"*" = ["tests/*", "tests/**/*"]}
51
+
48
52
 
49
53
  [tool.black]
50
54
  line-length = 88
@@ -58,7 +62,7 @@ src_paths = ["src", "tests", "examples"]
58
62
  multi_line_output = 3
59
63
 
60
64
  [tool.mypy]
61
- python_version = "3.9"
65
+ python_version = "3.10"
62
66
  warn_return_any = true
63
67
  warn_unused_configs = true
64
68
  mypy_path = "src"
@@ -76,4 +80,4 @@ agentstr = ["py.typed"]
76
80
  asyncio_mode = "auto"
77
81
  markers = [
78
82
  "asyncio: mark test as async",
79
- ]
83
+ ]
@@ -298,8 +298,8 @@ class BuyerTools(Toolkit):
298
298
 
299
299
  def _store_response_in_knowledge_base(self, response: str) -> None:
300
300
  doc = Document(
301
- id=str(uuid4()),
301
+ # id=str(uuid4()),
302
302
  content=response,
303
303
  )
304
- # print(f"Document length: {len(doc.content.split())} words")
304
+ print(f"Document length: {len(doc.content.split())} words")
305
305
  self.knowledge_base.load_documents([doc]) # Store response in Cassandra
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: agentstr
3
- Version: 0.1.13
3
+ Version: 0.1.15
4
4
  Summary: Tools for a Nostr agentic ecosystem
5
5
  Author-email: Synvya <synvya@synvya.com>
6
6
  License: MIT
@@ -8,7 +8,7 @@ Project-URL: Homepage, https://www.synvya.com
8
8
  Project-URL: Repository, https://github.com/synvya/agentstr
9
9
  Project-URL: Documentation, https://github.com/synvya/agentstr#readme
10
10
  Project-URL: BugTracker, https://github.com/synvya/agentstr/issues
11
- Requires-Python: <3.13,>=3.9
11
+ Requires-Python: <3.13,>=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: agno>=1.1.1
@@ -24,8 +24,10 @@ Requires-Dist: mypy>=1.0; extra == "dev"
24
24
  Requires-Dist: pylint>=3.0; extra == "dev"
25
25
  Provides-Extra: examples
26
26
  Requires-Dist: python-dotenv>=1.0; extra == "examples"
27
- Requires-Dist: cassandra-driver>=3.29.2; extra == "examples"
28
- Requires-Dist: cassio>=0.1.10; extra == "examples"
27
+ Requires-Dist: psycopg[binary]>=3.2.5; extra == "examples"
28
+ Requires-Dist: sqlalchemy>=2.0.0; extra == "examples"
29
+ Requires-Dist: nest-asyncio>=1.6.0; extra == "examples"
30
+ Requires-Dist: pgvector>=0.3.6; extra == "examples"
29
31
  Requires-Dist: fastapi>=0.110.0; extra == "examples"
30
32
  Requires-Dist: uvicorn>=0.30.0; extra == "examples"
31
33
 
@@ -126,7 +128,3 @@ This project is licensed under the MIT License - see the [LICENSE](https://githu
126
128
  - [Rust-Nostr](https://rust-nostr.org) - For their Python Nostr SDK
127
129
  - [Nostr Protocol](https://github.com/nostr-protocol/nips) - For the protocol specification
128
130
 
129
- This software includes the following software licensed under the [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0):
130
- - [DataStax Python Driver for Apache Cassandra](https://github.com/datastax/python-driver)
131
- - [cassIO](https://github.com/CassioML/cassio). This library is not maintained anymore. We will need to replace it with a new library.
132
-
@@ -16,8 +16,4 @@ src/agentstr.egg-info/PKG-INFO
16
16
  src/agentstr.egg-info/SOURCES.txt
17
17
  src/agentstr.egg-info/dependency_links.txt
18
18
  src/agentstr.egg-info/requires.txt
19
- src/agentstr.egg-info/top_level.txt
20
- tests/test_buyer.py
21
- tests/test_merchant.py
22
- tests/test_nostr_integration.py
23
- tests/test_nostr_mocked.py
19
+ src/agentstr.egg-info/top_level.txt
@@ -13,7 +13,9 @@ pylint>=3.0
13
13
 
14
14
  [examples]
15
15
  python-dotenv>=1.0
16
- cassandra-driver>=3.29.2
17
- cassio>=0.1.10
16
+ psycopg[binary]>=3.2.5
17
+ sqlalchemy>=2.0.0
18
+ nest-asyncio>=1.6.0
19
+ pgvector>=0.3.6
18
20
  fastapi>=0.110.0
19
21
  uvicorn>=0.30.0
@@ -1,3 +0,0 @@
1
- include LICENSE README.md
2
- global-exclude __pycache__
3
- global-exclude *.py[cod]
@@ -1,110 +0,0 @@
1
- """
2
- This module contains tests for the BuyerTools class.
3
- """
4
-
5
- import json
6
- from typing import List
7
- from unittest.mock import patch
8
-
9
- from agentstr.buyer import BuyerTools
10
- from agentstr.models import AgentProfile, MerchantProduct, MerchantStall, NostrProfile
11
- from agentstr.nostr import Keys, PublicKey
12
-
13
-
14
- def test_buyer_profile_creation(
15
- buyer_profile: AgentProfile,
16
- buyer_profile_name: str,
17
- buyer_profile_about: str,
18
- buyer_profile_picture: str,
19
- ) -> None:
20
- """Test the creation of a buyer profile"""
21
- assert buyer_profile.get_name() == buyer_profile_name
22
- assert buyer_profile.get_about() == buyer_profile_about
23
- assert buyer_profile.get_picture() == buyer_profile_picture
24
-
25
-
26
- def test_find_sellers_by_location(
27
- buyer_tools: BuyerTools, merchant_location: str, merchant_profile_name: str
28
- ) -> None:
29
- """Test the finding of sellers by location"""
30
- with patch(
31
- "agentstr.buyer._map_location_to_geohash"
32
- ) as mock_map_location_to_geohash:
33
- mock_map_location_to_geohash.return_value = "000000000"
34
-
35
- result = buyer_tools.find_sellers_by_location(merchant_location)
36
- assert result is not None
37
- assert merchant_profile_name in result
38
-
39
-
40
- def test_find_seller_by_name(
41
- buyer_tools: BuyerTools,
42
- merchant_profile_name: str,
43
- ) -> None:
44
- """Test the finding of a seller by name"""
45
- result = buyer_tools.find_seller_by_name(merchant_profile_name)
46
- assert result is not None
47
- assert merchant_profile_name in result
48
-
49
-
50
- def test_find_seller_by_public_key(
51
- buyer_tools: BuyerTools,
52
- merchant_keys: Keys,
53
- seller_nostr_profile: NostrProfile,
54
- ) -> None:
55
- """Test the finding of a seller by public key"""
56
- with patch.object(
57
- buyer_tools, "find_seller_by_public_key"
58
- ) as mock_find_seller_by_public_key:
59
- mock_find_seller_by_public_key.return_value = seller_nostr_profile.to_json()
60
-
61
- result = buyer_tools.find_seller_by_public_key(
62
- merchant_keys.public_key().to_bech32()
63
- )
64
- assert result is not None
65
- assert merchant_keys.public_key().to_bech32() in result
66
-
67
-
68
- def test_get_seller_stalls(
69
- buyer_tools: BuyerTools,
70
- seller_nostr_profile: NostrProfile,
71
- merchant_stalls: List[MerchantStall],
72
- ) -> None:
73
- """Test the retrieval of a seller's stalls"""
74
- with patch.object(
75
- buyer_tools.get_nostr_client(), "retrieve_stalls_from_seller"
76
- ) as mock_get_seller_stalls:
77
- stall_data = [
78
- merchant_stall.to_stall_data() for merchant_stall in merchant_stalls
79
- ]
80
- mock_get_seller_stalls.return_value = stall_data
81
-
82
- result = buyer_tools.get_seller_stalls(seller_nostr_profile.get_public_key())
83
- assert result is not None
84
-
85
-
86
- def test_get_seller_products(
87
- buyer_tools: BuyerTools,
88
- seller_nostr_profile: NostrProfile,
89
- merchant_products: List[MerchantProduct],
90
- ) -> None:
91
- """Test the retrieval of a seller's products"""
92
- with patch.object(
93
- buyer_tools.get_nostr_client(),
94
- "retrieve_products_from_seller",
95
- return_value=merchant_products,
96
- ) as mock_get_seller_products:
97
- result = buyer_tools.get_seller_products(seller_nostr_profile.get_public_key())
98
- assert isinstance(result, str) # Ensure it's a JSON string
99
-
100
- # ✅ Verify that the mocked method was called
101
- mock_get_seller_products.assert_called_once_with(
102
- PublicKey.parse(seller_nostr_profile.get_public_key())
103
- )
104
-
105
- products = json.loads(result) # Convert JSON string back to a Python list
106
- products = json.loads(result) # Convert JSON string back to a Python list
107
- assert isinstance(products, list) # Ensure it's a list
108
- assert len(products) > 0 # Ensure the list is not empty
109
- assert isinstance(products[0], dict) # Ensure the first item is a dictionary
110
- assert "name" in products[0] # Ensure "name" key exists in the first product
@@ -1,154 +0,0 @@
1
- """
2
- This module contains tests for the MerchantTools class.
3
- """
4
-
5
- import itertools
6
- import json
7
- from typing import List
8
- from unittest.mock import patch
9
-
10
- from agentstr.merchant import MerchantTools
11
- from agentstr.models import MerchantProduct, MerchantStall
12
- from agentstr.nostr import EventId
13
-
14
-
15
- def test_merchant_initialization(
16
- relay: str,
17
- merchant_tools: MerchantTools,
18
- merchant_stalls: List[MerchantStall],
19
- merchant_products: List[MerchantProduct],
20
- ) -> None:
21
- """Test merchant initialization"""
22
- assert merchant_tools.get_profile() is not None
23
- assert merchant_tools.get_relay() == relay
24
-
25
- products = json.loads(merchant_tools.get_products())
26
- assert len(products) == len(merchant_products)
27
-
28
- stalls = json.loads(merchant_tools.get_stalls())
29
- assert len(stalls) == len(merchant_stalls)
30
- assert stalls[0]["name"] == merchant_stalls[0].name
31
-
32
-
33
- def test_publish_product_by_name(
34
- merchant_tools: MerchantTools,
35
- product_event_ids: List[EventId],
36
- merchant_products: List[MerchantProduct],
37
- ) -> None:
38
- """Test publishing a product by name"""
39
- with patch.object(
40
- merchant_tools.get_nostr_client(), "publish_product"
41
- ) as mock_publish:
42
- mock_publish.return_value = product_event_ids[0]
43
-
44
- result = json.loads(
45
- merchant_tools.publish_product_by_name(merchant_products[0].name)
46
- )
47
- assert result["status"] == "success"
48
- assert result["product_name"] == merchant_products[0].name
49
-
50
- result = json.loads(
51
- merchant_tools.publish_product_by_name(
52
- json.dumps({"name": merchant_products[0].name})
53
- )
54
- )
55
- assert result["status"] == "success"
56
- assert result["product_name"] == merchant_products[0].name
57
-
58
-
59
- def test_publish_stall_by_name(
60
- merchant_tools: MerchantTools,
61
- stall_event_ids: List[EventId],
62
- merchant_stalls: List[MerchantStall],
63
- ) -> None:
64
- """Test publishing a stall by name"""
65
- with patch.object(
66
- merchant_tools.get_nostr_client(), "publish_stall"
67
- ) as mock_publish:
68
- mock_publish.return_value = stall_event_ids[0]
69
-
70
- result = json.loads(
71
- merchant_tools.publish_stall_by_name(merchant_stalls[0].name)
72
- )
73
- assert result["status"] == "success"
74
- assert result["stall_name"] == merchant_stalls[0].name
75
-
76
-
77
- def test_publish_products_by_stall_name(
78
- merchant_tools: MerchantTools,
79
- product_event_ids: List[EventId],
80
- merchant_stalls: List[MerchantStall],
81
- ) -> None:
82
- """Test publishing all products in a stall"""
83
- with patch.object(
84
- merchant_tools.get_nostr_client(), "publish_product"
85
- ) as mock_publish:
86
- mock_publish.side_effect = itertools.cycle(product_event_ids)
87
-
88
- results = json.loads(
89
- merchant_tools.publish_products_by_stall_name(merchant_stalls[0].name)
90
- )
91
- assert len(results) == 2
92
- assert all(r["status"] == "success" for r in results)
93
-
94
-
95
- def test_publish_all_products(
96
- merchant_tools: MerchantTools, product_event_ids: List[EventId]
97
- ) -> None:
98
- """Test publishing all products"""
99
- with patch.object(
100
- merchant_tools.get_nostr_client(), "publish_product"
101
- ) as mock_publish:
102
- mock_publish.side_effect = itertools.cycle(product_event_ids)
103
-
104
- results = json.loads(merchant_tools.publish_all_products())
105
- assert len(results) == 3
106
-
107
-
108
- def test_publish_all_stalls(
109
- merchant_tools: MerchantTools, stall_event_ids: List[EventId]
110
- ) -> None:
111
- """Test publishing all stalls"""
112
- with patch.object(
113
- merchant_tools.get_nostr_client(), "publish_stall"
114
- ) as mock_publish:
115
- mock_publish.side_effect = itertools.cycle(stall_event_ids)
116
-
117
- results = json.loads(merchant_tools.publish_all_stalls())
118
- assert len(results) == 2
119
-
120
-
121
- def test_error_handling(merchant_tools: MerchantTools) -> None:
122
- """Test error handling in various scenarios"""
123
- result = json.loads(merchant_tools.publish_product_by_name("NonExistentProduct"))
124
- assert result["status"] == "error"
125
-
126
- results = json.loads(merchant_tools.publish_stall_by_name("NonExistentStall"))
127
- assert isinstance(results, list)
128
- assert results[0]["status"] == "error"
129
-
130
- results = json.loads(
131
- merchant_tools.publish_products_by_stall_name("NonExistentStall")
132
- )
133
- assert isinstance(results, list)
134
- assert results[0]["status"] == "error"
135
-
136
-
137
- def test_profile_operations(
138
- merchant_tools: MerchantTools,
139
- profile_event_id: EventId,
140
- merchant_profile_name: str,
141
- merchant_profile_about: str,
142
- ) -> None:
143
- """Test profile-related operations"""
144
- profile_data = json.loads(merchant_tools.get_profile())
145
- profile = json.loads(profile_data) # Parse the nested JSON string
146
- assert profile["name"] == merchant_profile_name
147
- assert profile["about"] == merchant_profile_about
148
-
149
- with patch.object(
150
- merchant_tools.get_nostr_client(), "publish_profile"
151
- ) as mock_publish:
152
- mock_publish.return_value = profile_event_id
153
- result = json.loads(merchant_tools.publish_profile())
154
- assert isinstance(result, dict)
@@ -1,98 +0,0 @@
1
- """
2
- This module contains tests for the NostrClient class using a real Nostr relay.
3
- """
4
-
5
- from typing import List
6
-
7
- import pytest
8
-
9
- from agentstr.models import MerchantProduct, MerchantStall
10
- from agentstr.nostr import EventId, Keys, NostrClient
11
-
12
-
13
- # used in test_nostr_integration.py
14
- @pytest.fixture(scope="session", name="nostr_client")
15
- def nostr_client_fixture(relay: str, merchant_keys: Keys) -> NostrClient:
16
- """Fixture providing a NostrClient instance"""
17
- nostr_client = NostrClient(relay, merchant_keys.secret_key().to_bech32())
18
- return nostr_client
19
-
20
-
21
- class TestNostrClient:
22
- """Test suite for NostrClient"""
23
-
24
- def test_publish_profile(
25
- self,
26
- nostr_client: NostrClient,
27
- merchant_profile_name: str,
28
- merchant_profile_about: str,
29
- merchant_profile_picture: str,
30
- ) -> None:
31
- """Test publishing a profile"""
32
- event_id = nostr_client.publish_profile(
33
- name=merchant_profile_name,
34
- about=merchant_profile_about,
35
- picture=merchant_profile_picture,
36
- )
37
- assert isinstance(event_id, EventId)
38
-
39
- def test_publish_stall(
40
- self, nostr_client: NostrClient, merchant_stalls: List[MerchantStall]
41
- ) -> None:
42
- """Test publishing a stall"""
43
- event_id = nostr_client.publish_stall(merchant_stalls[0])
44
- assert isinstance(event_id, EventId)
45
-
46
- def test_publish_product(
47
- self, nostr_client: NostrClient, merchant_products: List[MerchantProduct]
48
- ) -> None:
49
- """Test publishing a product"""
50
- event_id = nostr_client.publish_product(merchant_products[0])
51
- assert isinstance(event_id, EventId)
52
-
53
- # def test_delete_event(
54
- # self, nostr_client: NostrClient, test_merchant_stall: MerchantStall
55
- # ) -> None:
56
- # """Test deleting an event"""
57
- # # First publish something to delete
58
- # event_id = nostr_client.publish_stall(test_merchant_stall)
59
- # assert isinstance(event_id, EventId)
60
-
61
- # # Then delete it
62
- # delete_event_id = nostr_client.delete_event(event_id, reason="Test deletion")
63
- # assert isinstance(delete_event_id, EventId)
64
-
65
- def test_retrieve_products_from_seller(
66
- self, nostr_client: NostrClient, merchant_keys: Keys
67
- ) -> None:
68
- """Test retrieving products from a seller"""
69
- products = nostr_client.retrieve_products_from_seller(
70
- merchant_keys.public_key()
71
- )
72
- assert len(products) > 0
73
- for product in products:
74
- assert isinstance(product, MerchantProduct)
75
- # print(f"Product: {product.name}")
76
-
77
- def test_retrieve_sellers(self, nostr_client: NostrClient) -> None:
78
- """Test retrieving sellers"""
79
- try:
80
- sellers = nostr_client.retrieve_sellers()
81
- assert len(sellers) > 0
82
- except RuntimeError as e:
83
- # print(f"\nError retrieving sellers: {e}")
84
- raise e
85
-
86
- def test_retrieve_stalls_from_seller(
87
- self, nostr_client: NostrClient, merchant_keys: Keys
88
- ) -> None:
89
- """Test retrieving stalls from a seller"""
90
- stalls = nostr_client.retrieve_stalls_from_seller(merchant_keys.public_key())
91
- assert len(stalls) > 0
92
-
93
- def test_retrieve_profile(
94
- self, nostr_client: NostrClient, merchant_keys: Keys
95
- ) -> None:
96
- """Test async retrieve profile"""
97
- profile = nostr_client.retrieve_profile(merchant_keys.public_key())
98
- assert profile is not None
@@ -1,107 +0,0 @@
1
- """
2
- Module to perform mocked tests on the NostrClient class.
3
- Used for regular CI/CD testing without connecting to a real Nostr relay.
4
- """
5
-
6
- from typing import Generator, List
7
- from unittest.mock import patch
8
-
9
- import pytest
10
-
11
- from agentstr.models import AgentProfile, MerchantProduct, MerchantStall
12
- from agentstr.nostr import EventId, Keys, NostrClient
13
-
14
-
15
- # used in test_nostr_mocked.py
16
- @pytest.fixture(name="nostr_client")
17
- def mock_nostr_client( # type: ignore[no-untyped-def]
18
- profile_event_id: EventId,
19
- stall_event_ids: List[EventId],
20
- product_event_ids: List[EventId],
21
- merchant_products: List[MerchantProduct],
22
- merchant_stalls: List[MerchantStall],
23
- merchant_profile: AgentProfile,
24
- ) -> Generator[NostrClient, None, None]:
25
- """
26
- mock NostrClient instance
27
- """
28
- with patch("agentstr.nostr.NostrClient") as mock_client:
29
- instance = mock_client.return_value
30
- # mock_event_id = EventId(
31
- # public_key=Keys.generate().public_key(),
32
- # created_at=Timestamp.from_secs(1739580690),
33
- # kind=Kind(0),
34
- # tags=[],
35
- # content="mock_content",
36
- # )
37
- instance.publish_profile.return_value = profile_event_id
38
- instance.publish_stall.return_value = stall_event_ids[0]
39
- instance.publish_product.return_value = product_event_ids[0]
40
- instance.retrieve_products_from_seller.return_value = merchant_products
41
- instance.retrieve_sellers.return_value = [merchant_profile]
42
- instance.retrieve_stalls_from_seller.return_value = merchant_stalls
43
- instance.retrieve_profile.return_value = merchant_profile
44
- yield instance
45
-
46
-
47
- class TestNostrClientMocked:
48
- """Mocked test suite for NostrClient"""
49
-
50
- def test_publish_profile(
51
- self,
52
- nostr_client: NostrClient,
53
- merchant_profile_name: str,
54
- merchant_profile_about: str,
55
- merchant_profile_picture: str,
56
- ) -> None:
57
- """Test publishing a profile"""
58
- event_id = nostr_client.publish_profile(
59
- name=merchant_profile_name,
60
- about=merchant_profile_about,
61
- picture=merchant_profile_picture,
62
- )
63
- assert isinstance(event_id, EventId)
64
-
65
- def test_publish_stall(
66
- self, nostr_client: NostrClient, merchant_stalls: List[MerchantStall]
67
- ) -> None:
68
- """Test publishing a stall"""
69
- event_id = nostr_client.publish_stall(merchant_stalls[0])
70
- assert isinstance(event_id, EventId)
71
-
72
- def test_publish_product(
73
- self, nostr_client: NostrClient, merchant_products: List[MerchantProduct]
74
- ) -> None:
75
- """Test publishing a product"""
76
- event_id = nostr_client.publish_product(merchant_products[0])
77
- assert isinstance(event_id, EventId)
78
-
79
- def test_retrieve_products_from_seller(
80
- self, nostr_client: NostrClient, merchant_keys: Keys
81
- ) -> None:
82
- """Test retrieving products from a seller"""
83
- products = nostr_client.retrieve_products_from_seller(
84
- merchant_keys.public_key()
85
- )
86
- assert len(products) > 0
87
- for product in products:
88
- assert isinstance(product, MerchantProduct)
89
-
90
- def test_retrieve_sellers(self, nostr_client: NostrClient) -> None:
91
- """Test retrieving sellers"""
92
- sellers = nostr_client.retrieve_sellers()
93
- assert len(sellers) > 0
94
-
95
- def test_retrieve_stalls_from_seller(
96
- self, nostr_client: NostrClient, merchant_keys: Keys
97
- ) -> None:
98
- """Test retrieving stalls from a seller"""
99
- stalls = nostr_client.retrieve_stalls_from_seller(merchant_keys.public_key())
100
- assert len(stalls) > 0
101
-
102
- def test_retrieve_profile(
103
- self, nostr_client: NostrClient, merchant_keys: Keys
104
- ) -> None:
105
- """Test async retrieve profile"""
106
- profile = nostr_client.retrieve_profile(merchant_keys.public_key())
107
- assert profile is not None
File without changes
File without changes