Total Complexity | 5 |
Total Lines | 33 |
Duplicated Lines | 81.82 % |
Changes | 0 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | from . import integ_test_base |
||
2 | import os |
||
3 | import requests |
||
4 | |||
5 | |||
6 | View Code Duplication | class TestMinimumTLSVersionValid(integ_test_base.IntegTestBase): |
|
|
|||
7 | def _get_log_contents(self): |
||
8 | with open(self.log_file_path, 'r') as f: |
||
9 | return f.read() |
||
10 | |||
11 | def _get_config_file_name(self) -> str: |
||
12 | config_file = open(os.path.join(self.tmp_dir, "test.conf"), "w+") |
||
13 | config_file.write( |
||
14 | "[TabPy]\n" |
||
15 | "TABPY_PORT = 9005\n" |
||
16 | "TABPY_TRANSFER_PROTOCOL = https\n" |
||
17 | "TABPY_CERTIFICATE_FILE = ./tests/integration/resources/2019_04_24_to_3018_08_25.crt\n" |
||
18 | "TABPY_KEY_FILE = ./tests/integration/resources/2019_04_24_to_3018_08_25.key\n" |
||
19 | "TABPY_MINIMUM_TLS_VERSION = TLSv1_3" |
||
20 | ) |
||
21 | pwd_file = self._get_pwd_file() |
||
22 | if pwd_file is not None: |
||
23 | pwd_file = os.path.abspath(pwd_file) |
||
24 | config_file.write(f"TABPY_PWD_FILE = {pwd_file}\n") |
||
25 | |||
26 | config_file.close() |
||
27 | self.delete_config_file = True |
||
28 | return config_file.name |
||
29 | |||
30 | def test_minimum_tls_version_valid(self): |
||
31 | log_contents = self._get_log_contents() |
||
32 | self.assertIn("Setting minimum TLS version to TLSv1_3", log_contents) |
||
33 |