| Conditions | 1 |
| Total Lines | 60 |
| Code Lines | 51 |
| Lines | 60 |
| Ratio | 100 % |
| 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 -*- |
||
| 97 | View Code Duplication | def test_get_single_vt_severity_cvssv3(self): |
|
|
|
|||
| 98 | w = DummyDaemon() |
||
| 99 | w.nvti.get_nvt_metadata.return_value = { |
||
| 100 | 'category': '3', |
||
| 101 | 'creation_date': '1237458156', |
||
| 102 | 'cvss_base_vector': 'AV:N/AC:L/Au:N/C:N/I:N/A:N', |
||
| 103 | 'severity_vector': 'CVSS:3.0/AV:L/AC:H/PR:H/UI:R/S:U/C:N/I:L/A:L', |
||
| 104 | 'severity_date': '1237458156', |
||
| 105 | 'severity_origin': 'Greenbone', |
||
| 106 | 'excluded_keys': 'Settings/disable_cgi_scanning', |
||
| 107 | 'family': 'Product detection', |
||
| 108 | 'filename': 'mantis_detect.nasl', |
||
| 109 | 'last_modification': ('1533906565'), |
||
| 110 | 'name': 'Mantis Detection', |
||
| 111 | 'qod_type': 'remote_banner', |
||
| 112 | 'required_ports': 'Services/www, 80', |
||
| 113 | 'solution': 'some solution', |
||
| 114 | 'solution_type': 'WillNotFix', |
||
| 115 | 'solution_method': 'DebianAPTUpgrade', |
||
| 116 | 'impact': 'some impact', |
||
| 117 | 'insight': 'some insight', |
||
| 118 | 'summary': ('some summary'), |
||
| 119 | 'affected': 'some affection', |
||
| 120 | 'timeout': '0', |
||
| 121 | 'vt_params': { |
||
| 122 | '1': { |
||
| 123 | 'id': '1', |
||
| 124 | 'default': '', |
||
| 125 | 'description': 'Description', |
||
| 126 | 'name': 'Data length :', |
||
| 127 | 'type': 'entry', |
||
| 128 | }, |
||
| 129 | '2': { |
||
| 130 | 'id': '2', |
||
| 131 | 'default': 'no', |
||
| 132 | 'description': 'Description', |
||
| 133 | 'name': 'Do not randomize the order in which ports are scanned', # pylint: disable=line-too-long |
||
| 134 | 'type': 'checkbox', |
||
| 135 | }, |
||
| 136 | }, |
||
| 137 | 'refs': { |
||
| 138 | 'bid': [''], |
||
| 139 | 'cve': [''], |
||
| 140 | 'xref': ['URL:http://www.mantisbt.org/'], |
||
| 141 | }, |
||
| 142 | } |
||
| 143 | |||
| 144 | vthelper = VtHelper(w.nvti) |
||
| 145 | |||
| 146 | res = vthelper.get_single_vt("1.3.6.1.4.1.25623.1.0.100061") |
||
| 147 | assert_called_once(w.nvti.get_nvt_metadata) |
||
| 148 | |||
| 149 | severities = res.get('severities') |
||
| 150 | self.assertEqual( |
||
| 151 | "CVSS:3.0/AV:L/AC:H/PR:H/UI:R/S:U/C:N/I:L/A:L", |
||
| 152 | severities.get('severity_base_vector'), |
||
| 153 | ) |
||
| 154 | self.assertEqual("cvss_base_v3", severities.get('severity_type')) |
||
| 155 | self.assertEqual("Greenbone", severities.get('severity_origin')) |
||
| 156 | self.assertEqual("1237458156", severities.get('severity_date')) |
||
| 157 | |||
| 215 |