| Conditions | 1 |
| Total Lines | 63 |
| Code Lines | 52 |
| Lines | 60 |
| Ratio | 95.24 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | # -*- coding: utf-8 -*- |
||
| 86 | View Code Duplication | def test_get_single_vt_severity_cvssv3(self): |
|
|
|
|||
| 87 | dummy = DummyDaemon() |
||
| 88 | dummy.nvti.get_nvt_metadata.return_value = { |
||
| 89 | 'category': '3', |
||
| 90 | 'creation_date': '1237458156', |
||
| 91 | 'cvss_base_vector': 'AV:N/AC:L/Au:N/C:N/I:N/A:N', |
||
| 92 | 'severity_vector': 'CVSS:3.0/AV:L/AC:H/PR:H/UI:R/S:U/C:N/I:L/A:L', |
||
| 93 | 'severity_date': '1237458156', |
||
| 94 | 'severity_origin': 'Greenbone', |
||
| 95 | 'excluded_keys': 'Settings/disable_cgi_scanning', |
||
| 96 | 'family': 'Product detection', |
||
| 97 | 'filename': 'mantis_detect.nasl', |
||
| 98 | 'last_modification': '1533906565', |
||
| 99 | 'name': 'Mantis Detection', |
||
| 100 | 'qod_type': 'remote_banner', |
||
| 101 | 'required_ports': 'Services/www, 80', |
||
| 102 | 'solution': 'some solution', |
||
| 103 | 'solution_type': 'WillNotFix', |
||
| 104 | 'solution_method': 'DebianAPTUpgrade', |
||
| 105 | 'impact': 'some impact', |
||
| 106 | 'insight': 'some insight', |
||
| 107 | 'summary': 'some summary', |
||
| 108 | 'affected': 'some affection', |
||
| 109 | 'timeout': '0', |
||
| 110 | 'vt_params': { |
||
| 111 | '1': { |
||
| 112 | 'id': '1', |
||
| 113 | 'default': '', |
||
| 114 | 'description': 'Description', |
||
| 115 | 'name': 'Data length :', |
||
| 116 | 'type': 'entry', |
||
| 117 | }, |
||
| 118 | '2': { |
||
| 119 | 'id': '2', |
||
| 120 | 'default': 'no', |
||
| 121 | 'description': 'Description', |
||
| 122 | 'name': ( # pylint: disable=line-too-long |
||
| 123 | 'Do not randomize the order in which ports are' |
||
| 124 | ' scanned' |
||
| 125 | ), |
||
| 126 | 'type': 'checkbox', |
||
| 127 | }, |
||
| 128 | }, |
||
| 129 | 'refs': { |
||
| 130 | 'bid': [''], |
||
| 131 | 'cve': [''], |
||
| 132 | 'xref': ['URL:http://www.mantisbt.org/'], |
||
| 133 | }, |
||
| 134 | } |
||
| 135 | |||
| 136 | vthelper = VtHelper(dummy.nvti) |
||
| 137 | |||
| 138 | res = vthelper.get_single_vt("1.3.6.1.4.1.25623.1.0.100061") |
||
| 139 | assert_called_once(dummy.nvti.get_nvt_metadata) |
||
| 140 | |||
| 141 | severities = res.get('severities') |
||
| 142 | self.assertEqual( |
||
| 143 | "CVSS:3.0/AV:L/AC:H/PR:H/UI:R/S:U/C:N/I:L/A:L", |
||
| 144 | severities.get('severity_base_vector'), |
||
| 145 | ) |
||
| 146 | self.assertEqual("cvss_base_v3", severities.get('severity_type')) |
||
| 147 | self.assertEqual("Greenbone", severities.get('severity_origin')) |
||
| 148 | self.assertEqual("1237458156", severities.get('severity_date')) |
||
| 149 | |||
| 236 |