Passed
Pull Request — master (#87)
by
unknown
03:06
created

tests.protocols.gmpv7.test_modify_port_list   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 38
dl 0
loc 85
rs 10
c 0
b 0
f 0
wmc 8

5 Methods

Rating   Name   Duplication   Size   Complexity  
A GmpModifyPortListTestCase.setUp() 0 3 1
A GmpModifyPortListTestCase.test_modify_port_list_with_name() 0 8 1
A GmpModifyPortListTestCase.test_modify_port_list() 0 7 1
A GmpModifyPortListTestCase.test_modify_port_list_missing_port_list_id() 0 14 4
A GmpModifyPortListTestCase.test_modify_port_list_with_comment() 0 8 1
1
# -*- coding: utf-8 -*-
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 gvm.errors import RequiredArgument
22
from gvm.protocols.gmpv7 import Gmp
23
24
from .. import MockConnection
25
26
27
class GmpModifyPortListTestCase(unittest.TestCase):
28
29
    def setUp(self):
30
        self.connection = MockConnection()
31
        self.gmp = Gmp(self.connection)
32
33
    def test_modify_port_list(self):
34
        self.gmp.modify_port_list(
35
            port_list_id='p1',
36
        )
37
38
        self.connection.send.has_been_called_with(
39
            '<modify_port_list port_list_id="p1"/>'
40
        )
41
42
    def test_modify_port_list_missing_port_list_id(self):
43
        with self.assertRaises(RequiredArgument):
44
            self.gmp.modify_port_list(
45
                port_list_id=None,
46
            )
47
48
        with self.assertRaises(RequiredArgument):
49
            self.gmp.modify_port_list(
50
                port_list_id='',
51
            )
52
53
        with self.assertRaises(RequiredArgument):
54
            self.gmp.modify_port_list(
55
                '',
56
            )
57
58
    def test_modify_port_list_with_comment(self):
59
        self.gmp.modify_port_list(
60
            port_list_id='p1',
61
            comment='foo',
62
        )
63
64
        self.connection.send.has_been_called_with(
65
            '<modify_port_list port_list_id="p1">'
66
            '<comment>foo</comment>'
67
            '</modify_port_list>'
68
        )
69
70
    def test_modify_port_list_with_name(self):
71
        self.gmp.modify_port_list(
72
            port_list_id='p1',
73
            name='foo',
74
        )
75
76
        self.connection.send.has_been_called_with(
77
            '<modify_port_list port_list_id="p1">'
78
            '<name>foo</name>'
79
            '</modify_port_list>'
80
        )
81
82
83
if __name__ == '__main__':
84
    unittest.main()
85