コード例 #1
0
 def test_read_trigger_timeout(self, _read_mock):
     # mocking the response into two parts, so we run into the timeout
     # check in the loop
     _read_mock.side_effect = [b"<foo>xyz<bar></bar>", b"</foo>"]
     connection = GvmConnection(timeout=0)
     with self.assertRaises(GvmError,
                            msg="Timeout while reading the response"):
         connection.read()
コード例 #2
0
 def test_feed_xml_error(self):
     connection = GvmConnection()
     connection._start_xml()
     with self.assertRaises(
             GvmError,
             msg="Cannot parse XML response. Response data read bla"):
         connection._feed_xml("bla")
コード例 #3
0
 def test_init_with_none(self):
     connection = GvmConnection(timeout=None)
     self.check_for_default_values(connection)
コード例 #4
0
 def test_init_no_args(self):
     connection = GvmConnection()
     self.check_for_default_values(connection)
コード例 #5
0
 def test_read_no_data(self, _read_mock):
     _read_mock.return_value = None
     connection = GvmConnection()
     with self.assertRaises(GvmError, msg="Remote closed the connection"):
         connection.read()
コード例 #6
0
    def test_is_end_xml_false(self):
        connection = GvmConnection()
        connection._start_xml()

        false = connection._is_end_xml()
        self.assertFalse(false)
コード例 #7
0
 def test_connect_not_implemented(self):
     connection = GvmConnection()
     with self.assertRaises(NotImplementedError):
         connection.connect()