|
1
|
|
|
# Copyright (C) 2014-2018 Greenbone Networks GmbH |
|
2
|
|
|
# |
|
3
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later |
|
4
|
|
|
# |
|
5
|
|
|
# This program is free software; you can redistribute it and/or |
|
6
|
|
|
# modify it under the terms of the GNU General Public License |
|
7
|
|
|
# as published by the Free Software Foundation; either version 2 |
|
8
|
|
|
# of the License, or (at your option) any later version. |
|
9
|
|
|
# |
|
10
|
|
|
# This program is distributed in the hope that it will be useful, |
|
11
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13
|
|
|
# GNU General Public License for more details. |
|
14
|
|
|
# |
|
15
|
|
|
# You should have received a copy of the GNU General Public License |
|
16
|
|
|
# along with this program; if not, write to the Free Software |
|
17
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18
|
|
|
|
|
19
|
|
|
""" Test module for OSPDError class |
|
20
|
|
|
""" |
|
21
|
|
|
|
|
22
|
|
|
import unittest |
|
23
|
|
|
|
|
24
|
|
|
from ospd.ospd import OSPDError |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
class OSPDErrorTestCase(unittest.TestCase): |
|
28
|
|
|
def test_default_params(self): |
|
29
|
|
|
e = OSPDError('message') |
|
30
|
|
|
self.assertEqual('message', e.message) |
|
31
|
|
|
self.assertEqual(400, e.status) |
|
32
|
|
|
self.assertEqual('osp', e.command) |
|
33
|
|
|
|
|
34
|
|
|
def test_constructor(self): |
|
35
|
|
|
e = OSPDError('message', 'command', '304') |
|
36
|
|
|
self.assertEqual('message', e.message) |
|
37
|
|
|
self.assertEqual('command', e.command) |
|
38
|
|
|
self.assertEqual('304', e.status) |
|
39
|
|
|
|
|
40
|
|
|
def test_as_xml(self): |
|
41
|
|
|
e = OSPDError('message') |
|
42
|
|
|
self.assertEqual( |
|
43
|
|
|
b'<osp_response status="400" status_text="message" />', e.as_xml() |
|
44
|
|
|
) |
|
45
|
|
|
|