Completed
Push — master ( 31f8dc...fc9f1c )
by
unknown
16s queued 12s
created

GMPCreateReportCommandTestCase.tearDown()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
# Copyright (C) 2018 Greenbone Networks GmbH
3
#
4
# SPDX-License-Identifier: GPL-3.0-or-later
5
#
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19
import unittest
20
21
from gmp.xml import _GmpCommandFactory as GmpCommandFactory
22
23
24
class GMPCreateReportCommandTestCase(unittest.TestCase):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
25
26
    TASK_ID = '00000000-0000-0000-0000-000000000001'
27
    TASK_NAME = 'unit test task'
28
    COMMENT = 'This is a comment'
29
    REPORT_XML_STRING = (
30
        '<report id="67a62fb7-b238-4f0e-bc48-59bde8939cdc">'
31
        '<results max="1" start="1">'
32
        '<result id="f180b40f-49dd-4856-81ed-8c1195afce80">'
33
        '<severity>0.0</severity>'
34
        '<nvt oid="1.3.6.1.4.1.25623.1.0.10330"/>'
35
        '<host>132.67.253.114</host>'
36
        '</result></results></report>'
37
    )
38
39
    def setUp(self):
40
        self.gmp = GmpCommandFactory()
41
42
    def tearDown(self):
43
        pass
44
45
    def test_create_report_cmd_task_id(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
46
        cmd = self.gmp.create_report_command(
47
            self.REPORT_XML_STRING,
48
            {
49
                'task_id': self.TASK_ID,
50
            })
51
52
        self.assertEqual(
53
            '<create_report>'
54
            '<task id="{0}"/>'
55
            '{1}'
56
            '</create_report>'.format(self.TASK_ID, self.REPORT_XML_STRING),
57
            cmd)
58
59
    def test_create_teport_cmd_task_name(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_create_teport_cmd_task_name does not conform to the method naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
60
        cmd = self.gmp.create_report_command(
61
            self.REPORT_XML_STRING,
62
            {
63
                'task_name': self.TASK_NAME,
64
                'comment': self.COMMENT,
65
            })
66
67
        self.assertEqual(
68
            '<create_report>'
69
            '<task>'
70
            '<name>{0}</name>'
71
            '<comment>{1}</comment>'
72
            '</task>'
73
            '{2}'
74
            '</create_report>'.format(self.TASK_NAME, self.COMMENT,
75
                                      self.REPORT_XML_STRING),
76
            cmd)
77
78
    def test_create_report_cmd_noreport(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
79
        args = {
80
            'task_name': self.TASK_NAME,
81
            'comment': self.COMMENT,
82
        }
83
84
        self.assertRaises(ValueError,
85
                          self.gmp.create_report_command,
86
                          None,
87
                          args)
88
89
    def test_create_report_cmd_notask(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
90
        args = {'comment': self.COMMENT}
91
        self.assertRaises(ValueError,
92
                          self.gmp.create_report_command,
93
                          self.REPORT_XML_STRING,
94
                          args)
95
96
97
if __name__ == '__main__':
98
    unittest.main()
99