| Total Complexity | 5 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import integ_test_base |
||
| 2 | import requests |
||
| 3 | import subprocess |
||
| 4 | from pathlib import Path |
||
| 5 | |||
| 6 | |||
| 7 | class TestDeployAndEvaluateModelSSL(integ_test_base.IntegTestBase): |
||
| 8 | def _get_port(self): |
||
| 9 | return '9005' |
||
| 10 | |||
| 11 | def _get_transfer_protocol(self) -> str: |
||
| 12 | return 'https' |
||
| 13 | |||
| 14 | def _get_certificate_file_name(self) -> str: |
||
| 15 | return './tests/integration/resources/2019_04_24_to_3018_08_25.crt' |
||
| 16 | |||
| 17 | def _get_key_file_name(self) -> str: |
||
| 18 | return './tests/integration/resources/2019_04_24_to_3018_08_25.key' |
||
| 19 | |||
| 20 | def test_deploy_and_evaluate_model_ssl(self): |
||
| 21 | path = str(Path('models', 'setup.py')) |
||
| 22 | subprocess.call([self.py, path, self._get_config_file_name()]) |
||
| 23 | |||
| 24 | payload = ( |
||
| 25 | '''{ |
||
| 26 | "data": { "_arg1": ["happy", "sad", "neutral"] }, |
||
| 27 | "script": |
||
| 28 | "return tabpy.query('Sentiment%20Analysis',_arg1)['response']" |
||
| 29 | }''') |
||
| 30 | |||
| 31 | session = requests.Session() |
||
| 32 | # Do not verify servers' cert to be signed by trusted CA |
||
| 33 | session.verify = False |
||
| 34 | # Do not warn about insecure request |
||
| 35 | requests.packages.urllib3.disable_warnings() |
||
| 36 | response = session.post( |
||
| 37 | f'{self._get_transfer_protocol()}://' |
||
| 38 | f'localhost:{self._get_port()}/evaluate', |
||
| 39 | data=payload) |
||
| 40 | |||
| 41 | self.assertEqual(200, response.status_code) |
||
| 42 |