specmatic 2.0.0__py3-none-any.whl → 2.0.1__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.
Potentially problematic release.
This version of specmatic might be problematic. Click here for more details.
- specmatic/core/decorators.py +4 -4
- specmatic/core/specmatic.jar +0 -0
- specmatic/core/specmatic.py +5 -5
- specmatic/core/specmatic_base.py +5 -13
- specmatic/core/specmatic_stub.py +2 -3
- specmatic/core/specmatic_test.py +2 -3
- specmatic/version.py +2 -2
- {specmatic-2.0.0.dist-info → specmatic-2.0.1.dist-info}/METADATA +6 -6
- {specmatic-2.0.0.dist-info → specmatic-2.0.1.dist-info}/RECORD +11 -11
- {specmatic-2.0.0.dist-info → specmatic-2.0.1.dist-info}/WHEEL +1 -1
- {specmatic-2.0.0.dist-info → specmatic-2.0.1.dist-info}/top_level.txt +0 -0
specmatic/core/decorators.py
CHANGED
|
@@ -12,10 +12,10 @@ from specmatic.utils import get_junit_report_file_path
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def specmatic_stub(host: str = '127.0.0.1', port: int = 0, project_root: str = '', expectations=None,
|
|
15
|
-
|
|
15
|
+
specmatic_config_file_path: str = ''):
|
|
16
16
|
def decorator(cls):
|
|
17
17
|
try:
|
|
18
|
-
cls.stub = SpecmaticStub(host, port, project_root,
|
|
18
|
+
cls.stub = SpecmaticStub(host, port, project_root, specmatic_config_file_path)
|
|
19
19
|
cls.stub.set_expectations(expectations)
|
|
20
20
|
except Exception as e:
|
|
21
21
|
if hasattr(cls, 'stub'):
|
|
@@ -31,7 +31,7 @@ def specmatic_stub(host: str = '127.0.0.1', port: int = 0, project_root: str = '
|
|
|
31
31
|
|
|
32
32
|
def specmatic_contract_test(host: str = '127.0.0,1', port: int = 0,
|
|
33
33
|
project_root: str = '',
|
|
34
|
-
|
|
34
|
+
specmatic_config_file_path: str = '', args=None, appRouteAdapter: AppRouteAdapter=None,):
|
|
35
35
|
def decorator(cls):
|
|
36
36
|
try:
|
|
37
37
|
test_host = host
|
|
@@ -47,7 +47,7 @@ def specmatic_contract_test(host: str = '127.0.0,1', port: int = 0,
|
|
|
47
47
|
cls.coverage_server.start()
|
|
48
48
|
endpoints_api = cls.coverage_server.endpoints_api
|
|
49
49
|
|
|
50
|
-
SpecmaticTest(test_host, test_port, project_root,
|
|
50
|
+
SpecmaticTest(test_host, test_port, project_root, specmatic_config_file_path, args,
|
|
51
51
|
endpoints_api).run()
|
|
52
52
|
|
|
53
53
|
if issubclass(cls, unittest.TestCase):
|
specmatic/core/specmatic.jar
CHANGED
|
Binary file
|
specmatic/core/specmatic.py
CHANGED
|
@@ -37,7 +37,7 @@ class Specmatic:
|
|
|
37
37
|
self.test_args = None
|
|
38
38
|
|
|
39
39
|
self.project_root = ''
|
|
40
|
-
self.
|
|
40
|
+
self.specmatic_config_file_path = ''
|
|
41
41
|
|
|
42
42
|
self.run_stub = False
|
|
43
43
|
self.run_app = False
|
|
@@ -50,8 +50,8 @@ class Specmatic:
|
|
|
50
50
|
self.project_root = project_root
|
|
51
51
|
return self
|
|
52
52
|
|
|
53
|
-
def
|
|
54
|
-
self.
|
|
53
|
+
def with_specmatic_config_file_path(self, specmatic_config_file_path):
|
|
54
|
+
self.specmatic_config_file_path = specmatic_config_file_path
|
|
55
55
|
return self
|
|
56
56
|
|
|
57
57
|
def with_stub(self, stub_host: str = '127.0.0.1', stub_port: int = 0, expectations=None, args=None):
|
|
@@ -138,7 +138,7 @@ class Specmatic:
|
|
|
138
138
|
|
|
139
139
|
def __start_stub(self):
|
|
140
140
|
if self.run_stub:
|
|
141
|
-
self.stub = SpecmaticStub(self.stub_host, self.stub_port, self.project_root, self.
|
|
141
|
+
self.stub = SpecmaticStub(self.stub_host, self.stub_port, self.project_root, self.specmatic_config_file_path,
|
|
142
142
|
self.stub_args)
|
|
143
143
|
self.stub.set_expectations(self.expectations)
|
|
144
144
|
if self.app_server is not None:
|
|
@@ -157,7 +157,7 @@ class Specmatic:
|
|
|
157
157
|
self.endpoints_api = self.coverage_server.endpoints_api
|
|
158
158
|
|
|
159
159
|
SpecmaticTest(self.test_host, self.test_port, self.project_root,
|
|
160
|
-
self.
|
|
160
|
+
self.specmatic_config_file_path, self.test_args, self.endpoints_api).run()
|
|
161
161
|
|
|
162
162
|
if issubclass(self.test_class, unittest.TestCase):
|
|
163
163
|
print("Injecting unittest methods")
|
specmatic/core/specmatic_base.py
CHANGED
|
@@ -3,22 +3,15 @@ import os
|
|
|
3
3
|
|
|
4
4
|
class SpecmaticBase:
|
|
5
5
|
def __init__(self, host: str = '127.0.0.1', port: int = 0, project_root: str = '',
|
|
6
|
-
|
|
7
|
-
self.specmatic_json_file_path = None
|
|
6
|
+
specmatic_config_file_path: str = '', args=None, endpoints_api=""):
|
|
8
7
|
self.contract_file_paths = None
|
|
9
|
-
self.project_root = None
|
|
10
8
|
self.project_root = project_root
|
|
11
9
|
self.host = host
|
|
12
10
|
self.port = port
|
|
13
|
-
self.
|
|
11
|
+
self.specmatic_config_file_path = specmatic_config_file_path
|
|
14
12
|
self.args = [] if args is None else args
|
|
15
13
|
self.endpoints_api = endpoints_api
|
|
16
14
|
|
|
17
|
-
def validate_mandatory_fields(self):
|
|
18
|
-
if self.project_root == '' and self.specmatic_json_file_path == '':
|
|
19
|
-
raise Exception(
|
|
20
|
-
'Please specify either of the following parameters: project_root, specmatic_json_file_path')
|
|
21
|
-
|
|
22
15
|
def create_command_array(self, mode: str, junit_dir_path=""):
|
|
23
16
|
jar_path = os.path.dirname(os.path.realpath(__file__)) + "/specmatic.jar"
|
|
24
17
|
cmd = ["java"]
|
|
@@ -31,10 +24,9 @@ class SpecmaticBase:
|
|
|
31
24
|
cmd.append(jar_path)
|
|
32
25
|
cmd.append(mode)
|
|
33
26
|
|
|
34
|
-
if self.
|
|
35
|
-
cmd.append("--config=" + self.
|
|
36
|
-
|
|
37
|
-
cmd.append("--config=" + self.project_root + "/specmatic.json")
|
|
27
|
+
if self.specmatic_config_file_path != '':
|
|
28
|
+
cmd.append("--config=" + self.specmatic_config_file_path)
|
|
29
|
+
|
|
38
30
|
cmd += ['--host=' + self.host]
|
|
39
31
|
if self.port != 0:
|
|
40
32
|
cmd += ["--port=" + str(self.port)]
|
specmatic/core/specmatic_stub.py
CHANGED
|
@@ -13,8 +13,8 @@ from specmatic.core.specmatic_base import SpecmaticBase
|
|
|
13
13
|
class SpecmaticStub(SpecmaticBase):
|
|
14
14
|
|
|
15
15
|
def __init__(self, host: str = '127.0.0.1', port: int = 0, project_root: str = '',
|
|
16
|
-
|
|
17
|
-
super().__init__(host, port, project_root,
|
|
16
|
+
specmatic_config_file_path: str = '', args=None):
|
|
17
|
+
super().__init__(host, port, project_root, specmatic_config_file_path, args)
|
|
18
18
|
self.__stub_started_event = None
|
|
19
19
|
self.__process = None
|
|
20
20
|
self.__stub_running_success_message = 'Stub server is running on '
|
|
@@ -115,5 +115,4 @@ class SpecmaticStub(SpecmaticBase):
|
|
|
115
115
|
self.__stub_started_event.set()
|
|
116
116
|
|
|
117
117
|
def __create_stub_process_command(self):
|
|
118
|
-
self.validate_mandatory_fields()
|
|
119
118
|
return self.create_command_array('stub')
|
specmatic/core/specmatic_test.py
CHANGED
|
@@ -8,8 +8,8 @@ from specmatic.utils import get_junit_report_dir_path
|
|
|
8
8
|
|
|
9
9
|
class SpecmaticTest(SpecmaticBase):
|
|
10
10
|
def __init__(self, host: str = "127.0.0.1", port: int = 5000, project_root: str = '',
|
|
11
|
-
|
|
12
|
-
super().__init__(host, port, project_root,
|
|
11
|
+
specmatic_config_file_path: str = '', args=None, endpoints_api: str = ''):
|
|
12
|
+
super().__init__(host, port, project_root, specmatic_config_file_path, args, endpoints_api)
|
|
13
13
|
|
|
14
14
|
def run(self):
|
|
15
15
|
self._delete_existing_report_if_exists()
|
|
@@ -21,7 +21,6 @@ class SpecmaticTest(SpecmaticBase):
|
|
|
21
21
|
shutil.rmtree(junit_report_dir_path)
|
|
22
22
|
|
|
23
23
|
def _execute_tests(self):
|
|
24
|
-
self.validate_mandatory_fields()
|
|
25
24
|
cmd = self.create_command_array('test', get_junit_report_dir_path())
|
|
26
25
|
print("command array:")
|
|
27
26
|
print(cmd)
|
specmatic/version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
__version__ = '2.0.
|
|
2
|
-
__specmatic_version__ = '2.0.
|
|
1
|
+
__version__ = '2.0.1'
|
|
2
|
+
__specmatic_version__ = '2.0.1'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: specmatic
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.1
|
|
4
4
|
Summary: A Python module for using the Specmatic Library.
|
|
5
5
|
Home-page: https://github.com/znsio/specmatic-python-extensions
|
|
6
6
|
Author: Specmatic Builders
|
|
@@ -15,7 +15,7 @@ Requires-Dist: flask >=2.2.5
|
|
|
15
15
|
Requires-Dist: sanic >=22.12.0
|
|
16
16
|
|
|
17
17
|
# Specmatic Python
|
|
18
|
-
This is a Python library to run [Specmatic](https://specmatic.
|
|
18
|
+
This is a Python library to run [Specmatic](https://specmatic.io).
|
|
19
19
|
Specmatic is a contract driven development tool that allows us to turn OpenAPI contracts into executable specifications.
|
|
20
20
|
<br/>Click below to learn more about Specmatic and Contract Driven Development<br/><br/>
|
|
21
21
|
[](https://www.youtube.com/watch?v=3HPgpvd8MGg "Specmatic - Contract Driven Development")
|
|
@@ -27,8 +27,8 @@ Specmatic is a contract driven development tool that allows us to turn OpenAPI c
|
|
|
27
27
|
|
|
28
28
|
#### Running Contract Tests
|
|
29
29
|
A contract test validates an open api specification against a running api service.
|
|
30
|
-
The open api specification can be present either locally or in a [Central Contract Repository](https://specmatic.
|
|
31
|
-
[Click here](https://specmatic.
|
|
30
|
+
The open api specification can be present either locally or in a [Central Contract Repository](https://specmatic.io/documentation/central_contract_repository.html)
|
|
31
|
+
[Click here](https://specmatic.io/documentation/contract_tests.html) to learn more about contract tests.
|
|
32
32
|
|
|
33
33
|
#### How to use
|
|
34
34
|
- Create a file called test_contract.py in your test folder.
|
|
@@ -82,12 +82,12 @@ pytest.main()
|
|
|
82
82
|
- In this, we are passing:
|
|
83
83
|
- an instance of your wsgi app like flask
|
|
84
84
|
- app_host and app_port. If they are not specified, the app will be started on a random available port on 127.0.0.1.
|
|
85
|
-
- You would need a [specmatic
|
|
85
|
+
- You would need a [specmatic config](https://specmatic.in/documentation/specmatic_json.html) file to be present in the root directory of your project.
|
|
86
86
|
- an empty test class.
|
|
87
87
|
- stub_host, stub_port, optional list of json files to set expectations on the stub.
|
|
88
88
|
The stub_host, stub_port will be used to run the specmatic stub server.
|
|
89
89
|
If they are not supplied, the stub will be started on a random available port on 127.0.0.1.
|
|
90
|
-
[Click here](https://specmatic.
|
|
90
|
+
[Click here](https://specmatic.io/documentation/service_virtualization_tutorial.html) to learn more about stubbing/service virtualization.
|
|
91
91
|
- You can run this test from either your IDE or command line by pointing pytest to your test folder:
|
|
92
92
|
``````pytest test -v -s``````
|
|
93
93
|
- NOTE: Please ensure that you set the '-v' and '-s' flags while running pytest as otherwise pytest may swallow up the console output.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
specmatic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
specmatic/build_utils.py,sha256=vIOoNyEUYofdMo3-U5bB9obL0lvjw4dEEGbZJNIzsL0,564
|
|
3
3
|
specmatic/utils.py,sha256=6JDPqpO51ykl0MWCOa32jkUOXZ-0RZ6N5Ng9_7r7XaU,519
|
|
4
|
-
specmatic/version.py,sha256=
|
|
4
|
+
specmatic/version.py,sha256=5zPBddgsXvNYwbw2EDk6j8Ri8GUU1ItR9hm9J2g9yxM,54
|
|
5
5
|
specmatic/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
specmatic/core/decorators.py,sha256=
|
|
7
|
-
specmatic/core/specmatic.jar,sha256=
|
|
8
|
-
specmatic/core/specmatic.py,sha256=
|
|
9
|
-
specmatic/core/specmatic_base.py,sha256=
|
|
10
|
-
specmatic/core/specmatic_stub.py,sha256=
|
|
11
|
-
specmatic/core/specmatic_test.py,sha256=
|
|
6
|
+
specmatic/core/decorators.py,sha256=jGi_m2tGGn8HZOyiMvAB3GvOWW_AkuWZvfqztMVy2pc,3972
|
|
7
|
+
specmatic/core/specmatic.jar,sha256=degbZkmI76zE1-ym8yZGqfj7Pvaax_WSh3X7yquXejE,66181781
|
|
8
|
+
specmatic/core/specmatic.py,sha256=vi7-LM5XTKipWwemh5cnbIoAZDbg9fpFEISDs6YM_f4,7918
|
|
9
|
+
specmatic/core/specmatic_base.py,sha256=IN9LY45EB5ApRtpF-LEkLmmy20gAXXAMwYhJQrS8TT0,1334
|
|
10
|
+
specmatic/core/specmatic_stub.py,sha256=pDjUZXjOc2RvBDd_92QalH7zjVzoWuhAzMGqLnV3V0c,4526
|
|
11
|
+
specmatic/core/specmatic_test.py,sha256=cXU5882L5wPUiscWwm1HDR_knBJjOCNssODcUrKBHdI,1048
|
|
12
12
|
specmatic/coverage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
specmatic/coverage/app_route_adapter.py,sha256=hFJ54R7CZFK9jFI6VbxHtKJKJgLX4PUX47TMdWjjhSA,1538
|
|
14
14
|
specmatic/coverage/coverage_route.py,sha256=WaqjG2Oh2PUfP72HoRnPkb5jG4BUmZK7Acla7gt_5Ko,284
|
|
@@ -29,7 +29,7 @@ specmatic/servers/app_server.py,sha256=kOZviJA7-F4kmMTLGiBln2oO5uYX28wKJM2xQJTOV
|
|
|
29
29
|
specmatic/servers/asgi_app_server.py,sha256=yn3tpWoF-nP8labOJdn49UB85vKiqIELVXk-gAugcUc,2924
|
|
30
30
|
specmatic/servers/wsgi_app_server.py,sha256=3aU-o6Hh8FrnZlbjCLLpGY92HvJoU_rcqsZIb9TKVr8,1342
|
|
31
31
|
specmatic/servers/wsgi_server_thread.py,sha256=XUEYW7-FP1a-5EkQVGc3FI_jkDQBocArxHLiCn3JJvc,691
|
|
32
|
-
specmatic-2.0.
|
|
33
|
-
specmatic-2.0.
|
|
34
|
-
specmatic-2.0.
|
|
35
|
-
specmatic-2.0.
|
|
32
|
+
specmatic-2.0.1.dist-info/METADATA,sha256=2BYoNFbvHQGrkXY44qKtVWoEXQ5_t68m3ANwNhvEQRo,10356
|
|
33
|
+
specmatic-2.0.1.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
|
|
34
|
+
specmatic-2.0.1.dist-info/top_level.txt,sha256=E7kQ78YacKBoKKeKWR_N83exlG8r5J0wlzlGqFmvIfo,10
|
|
35
|
+
specmatic-2.0.1.dist-info/RECORD,,
|
|
File without changes
|