Completed
Push — master ( 185d69...37094f )
by
unknown
18s
created

GMPCreateTargetCommandTestCase.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
22
23
24
class GMPCreateTargetCommandTestCase(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...
best-practice introduced by
Too many public methods (27/20)
Loading history...
25
26
    TARGET_NAME = 'Unittest Target'
27
    TARGET_HOST = '127.0.0.1'
28
    COMMENT = 'This is a comment'
29
    UUID = '00000000-0000-0000-0000-000000000000'
30
    PORT = '1234'
31
    ALIVE_TEST = 'ICMP Ping'
32
    PORT_RANGE = 'T:10-20,U:10-30'
33
34
    def setUp(self):
35
        self.gmp = GmpCommandFactory()
36
37
    def tearDown(self):
38
        pass
39
40
    def test_valid_name_make_unique_true_correct_cmd(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_valid_name_make_unique_true_correct_cmd 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...
41
        cmd = self.gmp.create_target_command(self.TARGET_NAME,
42
                                             True,
43
                                             {'hosts': self.TARGET_HOST})
44
45
        self.assertEqual('<create_target><name>' + self.TARGET_NAME +
46
                         '<make_unique>1</make_unique></name>'
47
                         '<hosts>' + self.TARGET_HOST + '</hosts>'
48
                         '</create_target>', cmd)
49
50
    def test_valid_name_make_unique_false_correct_cmd(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_valid_name_make_unique_false_correct_cmd 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...
51
        cmd = self.gmp.create_target_command(self.TARGET_NAME,
52
                                             False,
53
                                             {'hosts': self.TARGET_HOST})
54
55
        self.assertEqual('<create_target><name>' + self.TARGET_NAME +
56
                         '<make_unique>0</make_unique></name>'
57
                         '<hosts>' + self.TARGET_HOST + '</hosts>'
58
                         '</create_target>', cmd)
59
60
    def test_empty_name_value_error(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...
61
        with self.assertRaises(ValueError) as context:
62
            self.gmp.create_target_command(
63
                "", True, {'hosts': self.TARGET_HOST})
64
65
        self.assertEqual('create_target requires a name element',
66
                         str(context.exception))
67
68
    def test_asset_hosts_correct_cmd(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...
69
        cmd = self.gmp.create_target_command(
70
            self.TARGET_NAME, True,
71
            {'asset_hosts': {'filter': self.TARGET_HOST}})
72
73
        self.assertEqual('<create_target><name>' + self.TARGET_NAME +
74
                         '<make_unique>1</make_unique></name>'
75
                         '<asset_hosts filter="' + self.TARGET_HOST + '"/>'
76
                         '</create_target>',
77
                         cmd)
78
79
    def test_no_host_no_asset_hosts_value_error(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_no_host_no_asset_hosts_value_error 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...
80
        with self.assertRaises(ValueError) as context:
81
            self.gmp.create_target_command(self.TARGET_NAME, True, {})
82
83
        self.assertEqual('create_target requires either a hosts or '
84
                         'an asset_hosts element',
85
                         str(context.exception))
86
87
    def test_comment_correct_cmd(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...
88
        cmd = self.gmp.create_target_command(
89
            self.TARGET_NAME,
90
            True,
91
            {
92
                'hosts': self.TARGET_HOST,
93
                'comment': self.COMMENT
94
            })
95
96
        self.assertEqual('<create_target><name>' + self.TARGET_NAME +
97
                         '<make_unique>1</make_unique></name>'
98
                         '<hosts>' + self.TARGET_HOST + '</hosts>'
99
                         '<comment>' + self.COMMENT + '</comment>'
100
                         '</create_target>',
101
                         cmd)
102
103
    def test_copy_correct_cmd(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...
104
        cmd = self.gmp.create_target_command(
105
            self.TARGET_NAME,
106
            True,
107
            {
108
                'hosts': self.TARGET_HOST,
109
                'copy': self.UUID
110
            })
111
112
        self.assertEqual('<create_target><name>' + self.TARGET_NAME +
113
                         '<make_unique>1</make_unique></name>'
114
                         '<hosts>' + self.TARGET_HOST + '</hosts>'
115
                         '<copy>' + self.UUID + '</copy>'
116
                         '</create_target>',
117
                         cmd)
118
119
    def test_exclude_hosts_correct_cmd(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...
120
        cmd = self.gmp.create_target_command(
121
            self.TARGET_NAME,
122
            True,
123
            {
124
                'hosts': self.TARGET_HOST,
125
                'exclude_hosts': self.TARGET_HOST
126
            })
127
128
        self.assertEqual(
129
            '<create_target><name>' + self.TARGET_NAME +
130
            '<make_unique>1</make_unique></name>'
131
            '<hosts>' + self.TARGET_HOST + '</hosts>'
132
            '<exclude_hosts>' + self.TARGET_HOST + '</exclude_hosts>'
133
            '</create_target>',
134
            cmd)
135
136
    def test_ssh_credential_correct_cmd(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...
137
        cmd = self.gmp.create_target_command(
138
            self.TARGET_NAME,
139
            True,
140
            {
141
                'hosts': self.TARGET_HOST,
142
                'ssh_credential':
143
                    {
144
                        'id': self.UUID
145
                    }
146
            })
147
148
        self.assertEqual(
149
            '<create_target><name>' + self.TARGET_NAME +
150
            '<make_unique>1</make_unique></name>'
151
            '<hosts>' + self.TARGET_HOST + '</hosts>'
152
            '<ssh_credential id="' + self.UUID + '"></ssh_credential>'
153
            '</create_target>',
154
            cmd)
155
156
    def test_ssh_credential_with_port_correct_cmd(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_ssh_credential_with_port_correct_cmd 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...
157
        cmd = self.gmp.create_target_command(
158
            self.TARGET_NAME,
159
            True,
160
            {
161
                'hosts': self.TARGET_HOST,
162
                'ssh_credential':
163
                    {
164
                        'id': self.UUID,
165
                        'port': self.PORT
166
                    }
167
            })
168
169
        self.assertEqual(
170
            '<create_target><name>' + self.TARGET_NAME +
171
            '<make_unique>1</make_unique></name>'
172
            '<hosts>' + self.TARGET_HOST + '</hosts>'
173
            '<ssh_credential id="' + self.UUID + '">'
174
            '<port>' + self.PORT + '</port></ssh_credential>'
175
            '</create_target>',
176
            cmd)
177
178
    def test_ssh_credential_no_id_value_error(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_ssh_credential_no_id_value_error 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...
179
        with self.assertRaises(ValueError) as context:
180
            self.gmp.create_target_command(
181
                self.TARGET_NAME,
182
                True,
183
                {
184
                    'hosts': self.TARGET_HOST,
185
                    'ssh_credential': {}
186
                })
187
188
        self.assertEqual('ssh_credential requires an id attribute',
189
                         str(context.exception))
190
191
    def test_smb_credential_correct_cmd(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...
192
        cmd = self.gmp.create_target_command(
193
            self.TARGET_NAME,
194
            True,
195
            {
196
                'hosts': self.TARGET_HOST,
197
                'smb_credential':
198
                    {
199
                        'id': self.UUID
200
                    }
201
            })
202
203
        self.assertEqual('<create_target><name>' + self.TARGET_NAME +
204
                         '<make_unique>1</make_unique></name>'
205
                         '<hosts>' + self.TARGET_HOST + '</hosts>'
206
                         '<smb_credential id="' + self.UUID + '"/>'
207
                         '</create_target>',
208
                         cmd)
209
210
    def test_smb_credential_no_id_value_error(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_smb_credential_no_id_value_error 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...
211
        with self.assertRaises(ValueError) as context:
212
            self.gmp.create_target_command(
213
                self.TARGET_NAME,
214
                True,
215
                {
216
                    'hosts': self.TARGET_HOST,
217
                    'smb_credential': {}
218
                })
219
220
        self.assertEqual('smb_credential requires an id attribute',
221
                         str(context.exception))
222
223
    def test_esxi_credential_correct_cmd(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_esxi_credential_correct_cmd 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...
224
        cmd = self.gmp.create_target_command(
225
            self.TARGET_NAME,
226
            True,
227
            {
228
                'hosts': self.TARGET_HOST,
229
                'esxi_credential':
230
                    {
231
                        'id': self.UUID
232
                    }
233
            })
234
235
        self.assertEqual(
236
            '<create_target><name>' + self.TARGET_NAME +
237
            '<make_unique>1</make_unique></name>'
238
            '<hosts>' + self.TARGET_HOST + '</hosts>'
239
            '<esxi_credential id="' + self.UUID + '"/>'
240
            '</create_target>',
241
            cmd)
242
243
    def test_esxi_credential_no_id_value_error(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_esxi_credential_no_id_value_error 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...
244
        with self.assertRaises(ValueError) as context:
245
            self.gmp.create_target_command(
246
                self.TARGET_NAME,
247
                True,
248
                {
249
                    'hosts': self.TARGET_HOST,
250
                    'esxi_credential': {}
251
                })
252
253
        self.assertEqual('esxi_credential requires an id attribute',
254
                         str(context.exception))
255
256
    def test_snmp_credential_correct_cmd(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_snmp_credential_correct_cmd 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...
257
        cmd = self.gmp.create_target_command(
258
            self.TARGET_NAME,
259
            True,
260
            {
261
                'hosts': self.TARGET_HOST,
262
                'snmp_credential':
263
                    {
264
                        'id': self.UUID
265
                    }
266
            })
267
268
        self.assertEqual('<create_target><name>' + self.TARGET_NAME +
269
                         '<make_unique>1</make_unique></name>'
270
                         '<hosts>' + self.TARGET_HOST + '</hosts>'
271
                         '<snmp_credential id="' + self.UUID + '"/>'
272
                         '</create_target>',
273
                         cmd)
274
275
    def test_snmp_credential_no_id_value_error(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_snmp_credential_no_id_value_error 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...
276
        with self.assertRaises(ValueError) as context:
277
            self.gmp.create_target_command(
278
                self.TARGET_NAME,
279
                True,
280
                {
281
                    'hosts': self.TARGET_HOST,
282
                    'snmp_credential': {}
283
                })
284
285
        self.assertEqual('snmp_credential requires an id attribute',
286
                         str(context.exception))
287
288
    def test_alive_tests_correct_cmd(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...
289
        cmd = self.gmp.create_target_command(
290
            self.TARGET_NAME,
291
            True,
292
            {
293
                'hosts': self.TARGET_HOST,
294
                'alive_tests': self.ALIVE_TEST
295
            })
296
297
        self.assertEqual('<create_target><name>' + self.TARGET_NAME +
298
                         '<make_unique>1</make_unique></name>'
299
                         '<hosts>' + self.TARGET_HOST + '</hosts>'
300
                         '<alive_tests>' + self.ALIVE_TEST + '</alive_tests>'
301
                         '</create_target>',
302
                         cmd)
303
304
    def test_reverse_lookup_only_true_correct_cmd(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_reverse_lookup_only_true_correct_cmd 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...
305
        cmd = self.gmp.create_target_command(
306
            self.TARGET_NAME,
307
            True,
308
            {
309
                'hosts': self.TARGET_HOST,
310
                'reverse_lookup_only': True
311
            })
312
313
        self.assertEqual(
314
            '<create_target><name>' + self.TARGET_NAME +
315
            '<make_unique>1</make_unique></name>'
316
            '<hosts>' + self.TARGET_HOST + '</hosts>'
317
            '<reverse_lookup_only>1</reverse_lookup_only>'
318
            '</create_target>',
319
            cmd)
320
321
    def test_reverse_lookup_only_false_correct_cmd(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_reverse_lookup_only_false_correct_cmd 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...
322
        cmd = self.gmp.create_target_command(
323
            self.TARGET_NAME,
324
            True,
325
            {
326
                'hosts': self.TARGET_HOST,
327
                'reverse_lookup_only': False
328
            })
329
330
        self.assertEqual(
331
            '<create_target><name>' + self.TARGET_NAME +
332
            '<make_unique>1</make_unique></name>'
333
            '<hosts>' + self.TARGET_HOST + '</hosts>'
334
            '<reverse_lookup_only>0</reverse_lookup_only>'
335
            '</create_target>',
336
            cmd)
337
338
    def test_reverse_lookup_unify_true_correct_cmd(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_reverse_lookup_unify_true_correct_cmd 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...
339
        cmd = self.gmp.create_target_command(
340
            self.TARGET_NAME,
341
            True,
342
            {
343
                'hosts': self.TARGET_HOST,
344
                'reverse_lookup_unify': True
345
            })
346
347
        self.assertEqual('<create_target><name>' + self.TARGET_NAME +
348
                         '<make_unique>1</make_unique></name>'
349
                         '<hosts>' + self.TARGET_HOST + '</hosts>'
350
                         '<reverse_lookup_unify>1</reverse_lookup_unify>'
351
                         '</create_target>',
352
                         cmd)
353
354
    def test_reverse_lookup_unify_false_correct_cmd(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_reverse_lookup_unify_false_correct_cmd 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...
355
        cmd = self.gmp.create_target_command(
356
            self.TARGET_NAME,
357
            True,
358
            {
359
                'hosts': self.TARGET_HOST,
360
                'reverse_lookup_unify': False
361
            })
362
363
        self.assertEqual('<create_target><name>' + self.TARGET_NAME +
364
                         '<make_unique>1</make_unique></name>'
365
                         '<hosts>' + self.TARGET_HOST + '</hosts>'
366
                         '<reverse_lookup_unify>0</reverse_lookup_unify>'
367
                         '</create_target>',
368
                         cmd)
369
370
    def test_port_range_correct_cmd(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...
371
        cmd = self.gmp.create_target_command(
372
            self.TARGET_NAME,
373
            True,
374
            {
375
                'hosts': self.TARGET_HOST,
376
                'port_range': self.PORT_RANGE
377
            })
378
379
        self.assertEqual(
380
            '<create_target><name>' + self.TARGET_NAME +
381
            '<make_unique>1</make_unique></name>'
382
            '<hosts>' + self.TARGET_HOST + '</hosts>'
383
            '<port_range>' + self.PORT_RANGE + '</port_range>'
384
            '</create_target>',
385
            cmd)
386
387
    def test_port_list_correct_cmd(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...
388
        cmd = self.gmp.create_target_command(
389
            self.TARGET_NAME,
390
            True,
391
            {
392
                'hosts': self.TARGET_HOST,
393
                'port_list':
394
                    {
395
                        'id': self.UUID
396
                    }
397
            })
398
399
        self.assertEqual('<create_target><name>' + self.TARGET_NAME +
400
                         '<make_unique>1</make_unique></name>'
401
                         '<hosts>' + self.TARGET_HOST + '</hosts>'
402
                         '<port_list id="' + self.UUID + '"/>'
403
                         '</create_target>',
404
                         cmd)
405
406
    def test_port_list_no_id_value_error(self):
0 ignored issues
show
Coding Style Naming introduced by
The name test_port_list_no_id_value_error 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...
407
        with self.assertRaises(ValueError) as context:
408
            self.gmp.create_target_command(
409
                self.TARGET_NAME,
410
                True,
411
                {
412
                    'hosts': self.TARGET_HOST,
413
                    'port_list': {}
414
                })
415
416
        self.assertEqual('port_list requires an id attribute',
417
                         str(context.exception))
418
419
420
if __name__ == '__main__':
421
    unittest.main()
422