genlayer-test 0.7.0__py3-none-any.whl → 0.9.0__py3-none-any.whl

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 (58) hide show
  1. {genlayer_test-0.7.0.dist-info → genlayer_test-0.9.0.dist-info}/METADATA +245 -4
  2. genlayer_test-0.9.0.dist-info/RECORD +38 -0
  3. {genlayer_test-0.7.0.dist-info → genlayer_test-0.9.0.dist-info}/top_level.txt +0 -1
  4. gltest/__init__.py +3 -0
  5. gltest/types.py +12 -1
  6. gltest/validators/__init__.py +3 -0
  7. gltest/validators/validator_factory.py +136 -0
  8. gltest_cli/config/constants.py +7 -0
  9. gltest_cli/config/plugin.py +22 -4
  10. gltest_cli/config/types.py +81 -46
  11. gltest_cli/config/user.py +95 -7
  12. genlayer_test-0.7.0.dist-info/RECORD +0 -79
  13. tests/__init__.py +0 -0
  14. tests/conftest.py +0 -1
  15. tests/examples/contracts/football_prediction_market.py +0 -100
  16. tests/examples/contracts/intelligent_oracle.py +0 -370
  17. tests/examples/contracts/intelligent_oracle_factory.py +0 -49
  18. tests/examples/contracts/invalid_deploy.py +0 -10
  19. tests/examples/contracts/llm_erc20.py +0 -70
  20. tests/examples/contracts/log_indexer.py +0 -69
  21. tests/examples/contracts/multi_file_contract/__init__.py +0 -24
  22. tests/examples/contracts/multi_file_contract/other.py +0 -14
  23. tests/examples/contracts/multi_read_erc20.py +0 -29
  24. tests/examples/contracts/multi_tenant_storage.py +0 -51
  25. tests/examples/contracts/read_erc20.py +0 -19
  26. tests/examples/contracts/simple_time_contract.py +0 -85
  27. tests/examples/contracts/storage.py +0 -23
  28. tests/examples/contracts/user_storage.py +0 -25
  29. tests/examples/contracts/wizard_of_coin.py +0 -57
  30. tests/examples/tests/test_football_prediction_market.py +0 -38
  31. tests/examples/tests/test_intelligent_oracle_factory.py +0 -162
  32. tests/examples/tests/test_invalid_deploy.py +0 -24
  33. tests/examples/tests/test_llm_erc20.py +0 -60
  34. tests/examples/tests/test_llm_erc20_analyze.py +0 -54
  35. tests/examples/tests/test_log_indexer.py +0 -76
  36. tests/examples/tests/test_multi_file_contract.py +0 -15
  37. tests/examples/tests/test_multi_read_erc20.py +0 -103
  38. tests/examples/tests/test_multi_tenant_storage.py +0 -76
  39. tests/examples/tests/test_read_erc20.py +0 -38
  40. tests/examples/tests/test_simple_time_contract.py +0 -90
  41. tests/examples/tests/test_storage.py +0 -26
  42. tests/examples/tests/test_user_storage.py +0 -87
  43. tests/examples/tests/test_wizard_of_coin.py +0 -27
  44. tests/gltest/__init__.py +0 -0
  45. tests/gltest/artifact/__init__.py +0 -0
  46. tests/gltest/artifact/contracts/duplicate_ic_contract_1.py +0 -22
  47. tests/gltest/artifact/contracts/duplicate_ic_contract_2.py +0 -22
  48. tests/gltest/artifact/contracts/not_ic_contract.py +0 -22
  49. tests/gltest/artifact/test_contract_definition.py +0 -55
  50. tests/gltest/assertions/test_assertions.py +0 -344
  51. tests/gltest_cli/__init__.py +0 -0
  52. tests/gltest_cli/config/test_config_integration.py +0 -432
  53. tests/gltest_cli/config/test_general_config.py +0 -406
  54. tests/gltest_cli/config/test_plugin.py +0 -290
  55. tests/gltest_cli/config/test_user.py +0 -411
  56. {genlayer_test-0.7.0.dist-info → genlayer_test-0.9.0.dist-info}/WHEEL +0 -0
  57. {genlayer_test-0.7.0.dist-info → genlayer_test-0.9.0.dist-info}/entry_points.txt +0 -0
  58. {genlayer_test-0.7.0.dist-info → genlayer_test-0.9.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,406 +0,0 @@
1
- import pytest
2
- from pathlib import Path
3
- from gltest_cli.config.types import (
4
- GeneralConfig,
5
- UserConfig,
6
- PluginConfig,
7
- PathConfig,
8
- NetworkConfigData,
9
- )
10
- from gltest_cli.config.constants import DEFAULT_ARTIFACTS_DIR, DEFAULT_CONTRACTS_DIR
11
-
12
-
13
- def test_general_config_artifacts_methods():
14
- """Test GeneralConfig artifacts directory methods."""
15
- user_config = UserConfig(
16
- networks={"localnet": NetworkConfigData()},
17
- paths=PathConfig(contracts=Path("contracts"), artifacts=Path("user_artifacts")),
18
- )
19
-
20
- plugin_config = PluginConfig()
21
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
22
-
23
- # Test get_artifacts_dir returns user config value when plugin config is not set
24
- assert general_config.get_artifacts_dir() == Path("user_artifacts")
25
-
26
- # Test set_artifacts_dir updates plugin config
27
- general_config.set_artifacts_dir(Path("plugin_artifacts"))
28
- assert general_config.get_artifacts_dir() == Path("plugin_artifacts")
29
-
30
- # Plugin config should take precedence
31
- assert general_config.plugin_config.artifacts_dir == Path("plugin_artifacts")
32
-
33
-
34
- def test_general_config_artifacts_default():
35
- """Test GeneralConfig artifacts directory with default values."""
36
- user_config = UserConfig(
37
- networks={"localnet": NetworkConfigData()},
38
- paths=PathConfig(artifacts=DEFAULT_ARTIFACTS_DIR),
39
- )
40
-
41
- plugin_config = PluginConfig()
42
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
43
-
44
- # Should return default artifacts directory
45
- assert general_config.get_artifacts_dir() == DEFAULT_ARTIFACTS_DIR
46
-
47
-
48
- def test_general_config_artifacts_plugin_precedence():
49
- """Test that plugin config takes precedence over user config for artifacts."""
50
- user_config = UserConfig(
51
- networks={"localnet": NetworkConfigData()},
52
- paths=PathConfig(artifacts=Path("user_artifacts")),
53
- )
54
-
55
- plugin_config = PluginConfig(artifacts_dir=Path("plugin_artifacts"))
56
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
57
-
58
- # Plugin config should take precedence
59
- assert general_config.get_artifacts_dir() == Path("plugin_artifacts")
60
-
61
-
62
- def test_general_config_artifacts_none_values():
63
- """Test GeneralConfig behavior when artifacts paths are None."""
64
- user_config = UserConfig(
65
- networks={"localnet": NetworkConfigData()}, paths=PathConfig(artifacts=None)
66
- )
67
-
68
- plugin_config = PluginConfig(artifacts_dir=None)
69
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
70
-
71
- # Should return None when both are None
72
- assert general_config.get_artifacts_dir() is None
73
-
74
-
75
- def test_general_config_both_contracts_and_artifacts():
76
- """Test that both contracts and artifacts directories work together."""
77
- user_config = UserConfig(
78
- networks={"localnet": NetworkConfigData()},
79
- paths=PathConfig(
80
- contracts=Path("src/contracts"), artifacts=Path("build/artifacts")
81
- ),
82
- )
83
-
84
- plugin_config = PluginConfig(
85
- contracts_dir=Path("custom/contracts"), artifacts_dir=Path("custom/artifacts")
86
- )
87
-
88
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
89
-
90
- # Both should return plugin values (precedence)
91
- assert general_config.get_contracts_dir() == Path("custom/contracts")
92
- assert general_config.get_artifacts_dir() == Path("custom/artifacts")
93
-
94
-
95
- def test_general_config_mixed_precedence():
96
- """Test mixed precedence where only one path is overridden in plugin."""
97
- user_config = UserConfig(
98
- networks={"localnet": NetworkConfigData()},
99
- paths=PathConfig(
100
- contracts=Path("user/contracts"), artifacts=Path("user/artifacts")
101
- ),
102
- )
103
-
104
- # Only override artifacts in plugin config
105
- plugin_config = PluginConfig(artifacts_dir=Path("plugin/artifacts"))
106
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
107
-
108
- # Contracts should come from user config, artifacts from plugin config
109
- assert general_config.get_contracts_dir() == Path("user/contracts")
110
- assert general_config.get_artifacts_dir() == Path("plugin/artifacts")
111
-
112
-
113
- def test_path_config_validation():
114
- """Test PathConfig validation for artifacts."""
115
- # Valid path configurations
116
- valid_config = PathConfig(contracts=Path("contracts"), artifacts=Path("artifacts"))
117
- assert valid_config.contracts == Path("contracts")
118
- assert valid_config.artifacts == Path("artifacts")
119
-
120
- # Test with string paths
121
- string_config = PathConfig(contracts="contracts", artifacts="artifacts")
122
- # PathConfig should handle string conversion in __post_init__
123
- assert string_config.contracts == "contracts"
124
- assert string_config.artifacts == "artifacts"
125
-
126
-
127
- def test_path_config_invalid_types():
128
- """Test PathConfig validation with invalid types."""
129
- # Test invalid artifacts type
130
- with pytest.raises(ValueError, match="artifacts must be a string or Path"):
131
- PathConfig(artifacts=123)
132
-
133
- # Test invalid contracts type (existing validation)
134
- with pytest.raises(ValueError, match="contracts must be a string or Path"):
135
- PathConfig(contracts=123)
136
-
137
-
138
- def test_general_config_contracts_default():
139
- """Test GeneralConfig contracts directory with default values."""
140
- user_config = UserConfig(
141
- networks={"localnet": NetworkConfigData()},
142
- paths=PathConfig(contracts=DEFAULT_CONTRACTS_DIR),
143
- )
144
-
145
- plugin_config = PluginConfig()
146
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
147
-
148
- # Should return default contracts directory
149
- assert general_config.get_contracts_dir() == DEFAULT_CONTRACTS_DIR
150
-
151
-
152
- def test_general_config_leader_only_default():
153
- """Test GeneralConfig leader_only with default values."""
154
- user_config = UserConfig(
155
- networks={"localnet": NetworkConfigData()},
156
- )
157
-
158
- plugin_config = PluginConfig()
159
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
160
-
161
- # Should return False by default
162
- assert general_config.get_leader_only() is False
163
-
164
-
165
- def test_general_config_leader_only_network_config():
166
- """Test GeneralConfig leader_only from network configuration."""
167
- user_config = UserConfig(
168
- networks={"localnet": NetworkConfigData(leader_only=True)},
169
- default_network="localnet",
170
- )
171
-
172
- plugin_config = PluginConfig()
173
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
174
-
175
- # Should return True from network config
176
- assert general_config.get_leader_only() is True
177
-
178
-
179
- def test_general_config_leader_only_plugin_precedence():
180
- """Test that plugin config takes precedence over network config for leader_only."""
181
- user_config = UserConfig(
182
- networks={"localnet": NetworkConfigData(leader_only=False)},
183
- default_network="localnet",
184
- )
185
-
186
- plugin_config = PluginConfig(leader_only=True)
187
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
188
-
189
- # Plugin config should take precedence
190
- assert general_config.get_leader_only() is True
191
-
192
-
193
- def test_general_config_leader_only_multiple_networks():
194
- """Test leader_only with multiple networks."""
195
- user_config = UserConfig(
196
- networks={
197
- "localnet": NetworkConfigData(leader_only=False),
198
- "testnet": NetworkConfigData(leader_only=True),
199
- },
200
- default_network="testnet",
201
- )
202
-
203
- plugin_config = PluginConfig()
204
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
205
-
206
- # Should use the default network's leader_only value
207
- assert general_config.get_leader_only() is True
208
-
209
- # Change network via plugin config
210
- plugin_config.network_name = "localnet"
211
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
212
- assert general_config.get_leader_only() is False
213
-
214
-
215
- def test_general_config_leader_only_network_not_found():
216
- """Test leader_only when selected network is not found."""
217
- user_config = UserConfig(
218
- networks={"localnet": NetworkConfigData(leader_only=True)},
219
- default_network="localnet",
220
- )
221
-
222
- plugin_config = PluginConfig(network_name="nonexistent")
223
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
224
-
225
- # Should return False when network is not found
226
- assert general_config.get_leader_only() is False
227
-
228
-
229
- def test_check_local_rpc_with_localhost():
230
- """Test check_local_rpc with localhost URL."""
231
- user_config = UserConfig(
232
- networks={"localnet": NetworkConfigData(url="http://localhost:8545")},
233
- default_network="localnet",
234
- )
235
-
236
- plugin_config = PluginConfig()
237
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
238
-
239
- assert general_config.check_local_rpc() is True
240
-
241
-
242
- def test_check_local_rpc_with_127_0_0_1():
243
- """Test check_local_rpc with 127.0.0.1 URL."""
244
- user_config = UserConfig(
245
- networks={"localnet": NetworkConfigData(url="http://127.0.0.1:8545")},
246
- default_network="localnet",
247
- )
248
-
249
- plugin_config = PluginConfig()
250
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
251
-
252
- assert general_config.check_local_rpc() is True
253
-
254
-
255
- def test_check_local_rpc_with_external_url():
256
- """Test check_local_rpc with external URL."""
257
- user_config = UserConfig(
258
- networks={"testnet": NetworkConfigData(url="https://api.genlayer.com:8545")},
259
- default_network="testnet",
260
- )
261
-
262
- plugin_config = PluginConfig()
263
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
264
-
265
- assert general_config.check_local_rpc() is False
266
-
267
-
268
- def test_check_local_rpc_with_plugin_override():
269
- """Test check_local_rpc with plugin config RPC URL override."""
270
- user_config = UserConfig(
271
- networks={"localnet": NetworkConfigData(url="https://external.com")},
272
- default_network="localnet",
273
- )
274
-
275
- plugin_config = PluginConfig(rpc_url="http://localhost:9000")
276
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
277
-
278
- # Plugin config should take precedence
279
- assert general_config.check_local_rpc() is True
280
-
281
-
282
- def test_check_studio_based_rpc_with_localhost():
283
- """Test check_studio_based_rpc with localhost URL."""
284
- user_config = UserConfig(
285
- networks={"localnet": NetworkConfigData(url="http://localhost:8545")},
286
- default_network="localnet",
287
- )
288
-
289
- plugin_config = PluginConfig()
290
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
291
-
292
- assert general_config.check_studio_based_rpc() is True
293
-
294
-
295
- def test_check_studio_based_rpc_with_127_0_0_1():
296
- """Test check_studio_based_rpc with 127.0.0.1 URL."""
297
- user_config = UserConfig(
298
- networks={"localnet": NetworkConfigData(url="http://127.0.0.1:8545")},
299
- default_network="localnet",
300
- )
301
-
302
- plugin_config = PluginConfig()
303
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
304
-
305
- assert general_config.check_studio_based_rpc() is True
306
-
307
-
308
- def test_check_studio_based_rpc_with_genlayer_subdomain():
309
- """Test check_studio_based_rpc with .genlayer.com subdomains."""
310
- test_cases = [
311
- "https://api.genlayer.com:8545",
312
- "https://test.genlayer.com",
313
- "http://staging.api.genlayer.com:9000",
314
- "https://dev.test.genlayer.com",
315
- ]
316
-
317
- for url in test_cases:
318
- user_config = UserConfig(
319
- networks={"testnet": NetworkConfigData(url=url)},
320
- default_network="testnet",
321
- )
322
-
323
- plugin_config = PluginConfig()
324
- general_config = GeneralConfig(
325
- user_config=user_config, plugin_config=plugin_config
326
- )
327
-
328
- assert general_config.check_studio_based_rpc() is True, f"Failed for URL: {url}"
329
-
330
-
331
- def test_check_studio_based_rpc_with_genlayerlabs_subdomain():
332
- """Test check_studio_based_rpc with .genlayerlabs.com subdomains."""
333
- test_cases = [
334
- "https://api.genlayerlabs.com:8545",
335
- "https://test.genlayerlabs.com",
336
- "http://staging.api.genlayerlabs.com:9000",
337
- "https://dev.test.genlayerlabs.com",
338
- ]
339
-
340
- for url in test_cases:
341
- user_config = UserConfig(
342
- networks={"testnet": NetworkConfigData(url=url)},
343
- default_network="testnet",
344
- )
345
-
346
- plugin_config = PluginConfig()
347
- general_config = GeneralConfig(
348
- user_config=user_config, plugin_config=plugin_config
349
- )
350
-
351
- assert general_config.check_studio_based_rpc() is True, f"Failed for URL: {url}"
352
-
353
-
354
- def test_check_studio_based_rpc_with_non_genlayer_domain():
355
- """Test check_studio_based_rpc with non-GenLayer domains."""
356
- test_cases = [
357
- "https://api.example.com:8545",
358
- "https://test.otherdomain.com",
359
- "http://staging.api.random.org:9000",
360
- "https://genlayer.example.com", # Not a subdomain of .genlayer.com
361
- "https://genlayerlabs.example.com", # Not a subdomain of .genlayerlabs.com
362
- ]
363
-
364
- for url in test_cases:
365
- user_config = UserConfig(
366
- networks={"testnet": NetworkConfigData(url=url)},
367
- default_network="testnet",
368
- )
369
-
370
- plugin_config = PluginConfig()
371
- general_config = GeneralConfig(
372
- user_config=user_config, plugin_config=plugin_config
373
- )
374
-
375
- assert (
376
- general_config.check_studio_based_rpc() is False
377
- ), f"Failed for URL: {url}"
378
-
379
-
380
- def test_check_studio_based_rpc_with_plugin_override():
381
- """Test check_studio_based_rpc with plugin config RPC URL override."""
382
- # User config has external URL, but plugin overrides with GenLayer domain
383
- user_config = UserConfig(
384
- networks={"localnet": NetworkConfigData(url="https://external.com")},
385
- default_network="localnet",
386
- )
387
-
388
- plugin_config = PluginConfig(rpc_url="https://api.genlayer.com:9000")
389
- general_config = GeneralConfig(user_config=user_config, plugin_config=plugin_config)
390
-
391
- # Plugin config should take precedence
392
- assert general_config.check_studio_based_rpc() is True
393
-
394
- # Test opposite case: user has GenLayer domain, plugin overrides with external
395
- user_config2 = UserConfig(
396
- networks={"localnet": NetworkConfigData(url="https://api.genlayer.com")},
397
- default_network="localnet",
398
- )
399
-
400
- plugin_config2 = PluginConfig(rpc_url="https://external.com:9000")
401
- general_config2 = GeneralConfig(
402
- user_config=user_config2, plugin_config=plugin_config2
403
- )
404
-
405
- # Plugin config should take precedence
406
- assert general_config2.check_studio_based_rpc() is False
@@ -1,290 +0,0 @@
1
- def test_help_message(pytester):
2
- result = pytester.runpytest(
3
- "--help",
4
- )
5
- # fnmatch_lines does an assertion internally
6
- result.stdout.fnmatch_lines(
7
- [
8
- "gltest:",
9
- " --contracts-dir=CONTRACTS_DIR",
10
- " Path to directory containing contract files",
11
- " --artifacts-dir=ARTIFACTS_DIR",
12
- " Path to directory for storing contract artifacts",
13
- " --default-wait-interval=DEFAULT_WAIT_INTERVAL",
14
- " Default interval (ms) between transaction receipt checks",
15
- " --default-wait-retries=DEFAULT_WAIT_RETRIES",
16
- " Default number of retries for transaction receipt checks",
17
- " --rpc-url=RPC_URL RPC endpoint URL for the GenLayer network",
18
- " --network=NETWORK Target network (defaults to 'localnet' if no config",
19
- " file)",
20
- " --test-with-mocks Test with mocks",
21
- " --leader-only Run contracts in leader-only mode",
22
- ]
23
- )
24
-
25
-
26
- def test_default_wait_interval(pytester):
27
-
28
- pytester.makepyfile(
29
- """
30
- from gltest_cli.config.general import get_general_config
31
-
32
- def test_default_wait_interval():
33
- general_config = get_general_config()
34
- assert general_config.get_default_wait_interval() == 5000
35
- """
36
- )
37
-
38
- result = pytester.runpytest("--default-wait-interval=5000", "-v")
39
-
40
- result.stdout.fnmatch_lines(
41
- [
42
- "*::test_default_wait_interval PASSED*",
43
- ]
44
- )
45
- assert result.ret == 0
46
-
47
-
48
- def test_default_wait_retries(pytester):
49
- pytester.makepyfile(
50
- """
51
- from gltest_cli.config.general import get_general_config
52
-
53
- def test_default_wait_retries():
54
- general_config = get_general_config()
55
- assert general_config.get_default_wait_retries() == 4000
56
- """
57
- )
58
-
59
- result = pytester.runpytest("--default-wait-retries=4000", "-v")
60
-
61
- result.stdout.fnmatch_lines(
62
- [
63
- "*::test_default_wait_retries PASSED*",
64
- ]
65
- )
66
- assert result.ret == 0
67
-
68
-
69
- def test_rpc_url(pytester):
70
- pytester.makepyfile(
71
- """
72
- from gltest_cli.config.general import get_general_config
73
-
74
- def test_rpc_url():
75
- general_config = get_general_config()
76
- assert general_config.get_rpc_url() == 'http://custom-rpc-url:8545'
77
- """
78
- )
79
-
80
- result = pytester.runpytest("--rpc-url=http://custom-rpc-url:8545", "-v")
81
-
82
- result.stdout.fnmatch_lines(
83
- [
84
- "*::test_rpc_url PASSED*",
85
- ]
86
- )
87
- assert result.ret == 0
88
-
89
-
90
- def test_network_localnet(pytester):
91
- pytester.makepyfile(
92
- """
93
- from gltest_cli.config.general import get_general_config
94
-
95
- def test_network():
96
- general_config = get_general_config()
97
- assert general_config.get_network_name() == "localnet"
98
- """
99
- )
100
-
101
- result = pytester.runpytest("--network=localnet", "-v")
102
-
103
- result.stdout.fnmatch_lines(
104
- [
105
- "*::test_network PASSED*",
106
- ]
107
- )
108
- assert result.ret == 0
109
-
110
-
111
- def test_network_testnet(pytester):
112
- pytester.makepyfile(
113
- """
114
- from gltest_cli.config.general import get_general_config
115
-
116
- def test_network():
117
- general_config = get_general_config()
118
- assert general_config.get_network_name() == "testnet_asimov"
119
- """
120
- )
121
-
122
- result = pytester.runpytest(
123
- "--network=testnet_asimov", "--rpc-url=http://test.example.com:9151", "-v"
124
- )
125
-
126
- # The test should exit with an error code when testnet_asimov is used without accounts
127
- assert result.ret != 0
128
-
129
-
130
- def test_artifacts_dir(pytester):
131
- """Test that artifacts directory CLI parameter works correctly."""
132
- pytester.makepyfile(
133
- """
134
- from gltest_cli.config.general import get_general_config
135
- from pathlib import Path
136
-
137
- def test_artifacts_dir():
138
- general_config = get_general_config()
139
- assert general_config.get_artifacts_dir() == Path("custom/artifacts")
140
- """
141
- )
142
-
143
- result = pytester.runpytest("--artifacts-dir=custom/artifacts", "-v")
144
-
145
- result.stdout.fnmatch_lines(
146
- [
147
- "*::test_artifacts_dir PASSED*",
148
- ]
149
- )
150
- assert result.ret == 0
151
-
152
-
153
- def test_contracts_and_artifacts_dirs(pytester):
154
- """Test that both contracts and artifacts directories can be set via CLI."""
155
- pytester.makepyfile(
156
- """
157
- from gltest_cli.config.general import get_general_config
158
- from pathlib import Path
159
-
160
- def test_both_dirs():
161
- general_config = get_general_config()
162
- assert general_config.get_contracts_dir() == Path("src/contracts")
163
- assert general_config.get_artifacts_dir() == Path("build/artifacts")
164
- """
165
- )
166
-
167
- result = pytester.runpytest(
168
- "--contracts-dir=src/contracts", "--artifacts-dir=build/artifacts", "-v"
169
- )
170
-
171
- result.stdout.fnmatch_lines(
172
- [
173
- "*::test_both_dirs PASSED*",
174
- ]
175
- )
176
- assert result.ret == 0
177
-
178
-
179
- def test_test_with_mocks_true(pytester):
180
- pytester.makepyfile(
181
- """
182
- from gltest_cli.config.general import get_general_config
183
-
184
- def test_test_with_mocks():
185
- general_config = get_general_config()
186
- assert general_config.get_test_with_mocks() == True
187
- """
188
- )
189
-
190
- result = pytester.runpytest("--test-with-mocks", "-v")
191
-
192
- result.stdout.fnmatch_lines(
193
- [
194
- "*::test_test_with_mocks PASSED*",
195
- ]
196
- )
197
- assert result.ret == 0
198
-
199
-
200
- def test_test_with_mocks_false(pytester):
201
- pytester.makepyfile(
202
- """
203
- from gltest_cli.config.general import get_general_config
204
-
205
- def test_test_with_mocks():
206
- general_config = get_general_config()
207
- assert general_config.get_test_with_mocks() == False
208
- "*::test_test_with_mocks PASSED*",
209
-
210
- """
211
- )
212
-
213
- result = pytester.runpytest("-v")
214
-
215
- result.stdout.fnmatch_lines(
216
- [
217
- "*::test_test_with_mocks PASSED*",
218
- ]
219
- )
220
- assert result.ret == 0
221
-
222
-
223
- def test_artifacts_dir_default_fallback(pytester):
224
- """Test that artifacts directory falls back to config file default when CLI not provided."""
225
- pytester.makepyfile(
226
- """
227
- from gltest_cli.config.general import get_general_config
228
- from pathlib import Path
229
-
230
- def test_artifacts_default():
231
- general_config = get_general_config()
232
- # Should use the default from config
233
- artifacts_dir = general_config.get_artifacts_dir()
234
- assert isinstance(artifacts_dir, Path)
235
- # Default should be 'artifacts'
236
- assert str(artifacts_dir) == "artifacts"
237
-
238
- """
239
- )
240
-
241
- result = pytester.runpytest("-v")
242
-
243
- result.stdout.fnmatch_lines(
244
- [
245
- "*::test_artifacts_default PASSED*",
246
- ]
247
- )
248
- assert result.ret == 0
249
-
250
-
251
- def test_leader_only_true(pytester):
252
- pytester.makepyfile(
253
- """
254
- from gltest_cli.config.general import get_general_config
255
-
256
- def test_leader_only():
257
- general_config = get_general_config()
258
- assert general_config.get_leader_only() == True
259
- """
260
- )
261
-
262
- result = pytester.runpytest("--leader-only", "-v")
263
-
264
- result.stdout.fnmatch_lines(
265
- [
266
- "*::test_leader_only PASSED*",
267
- ]
268
- )
269
- assert result.ret == 0
270
-
271
-
272
- def test_leader_only_false(pytester):
273
- pytester.makepyfile(
274
- """
275
- from gltest_cli.config.general import get_general_config
276
-
277
- def test_leader_only():
278
- general_config = get_general_config()
279
- assert general_config.get_leader_only() == False
280
- """
281
- )
282
-
283
- result = pytester.runpytest("-v")
284
-
285
- result.stdout.fnmatch_lines(
286
- [
287
- "*::test_leader_only PASSED*",
288
- ]
289
- )
290
- assert result.ret == 0