Passed
Pull Request — master (#638)
by
unknown
13:58
created

tests.integration.test_minimum_tls_version_invalid   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 82.35 %

Importance

Changes 0
Metric Value
wmc 5
eloc 23
dl 28
loc 34
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A TestMinimumTLSVersionInvalid._get_config_file_name() 18 18 2
A TestMinimumTLSVersionInvalid._get_log_contents() 3 3 2
A TestMinimumTLSVersionInvalid.test_minimum_tls_version_invalid() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

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 TestMinimumTLSVersionInvalid(integ_test_base.IntegTestBase):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
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 = TLSv-1.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_invalid(self):
31
        log_contents = self._get_log_contents()
32
        self.assertIn("Unrecognized value for TABPY_MINIMUM_TLS_VERSION", log_contents)
33
        self.assertIn("Setting minimum TLS version to TLSv1_2", log_contents)
34