def test__get_int_strict(self): from kayako.core.lib import NodeParser assert NodeParser._get_int(self._etree_with_data("123"), required=False, strict=True) == 123 assert NodeParser._get_int(None, required=False, strict=True) == None assert NodeParser._get_int(self._etree_with_data(""), required=False, strict=True) == None self.assertRaises(ValueError, NodeParser._get_int, self._etree_with_data("abc"), required=False, strict=True)
def test__get_int_optional(self): from kayako.core.lib import NodeParser assert NodeParser._get_int(self._etree_with_data("123"), required=False, strict=False) == 123 assert NodeParser._get_int(None, required=False, strict=False) == None assert NodeParser._get_int(self._etree_with_data(""), required=False, strict=False) == None assert NodeParser._get_int(self._etree_with_data("abc"), required=False, strict=False) == None
def test__get_int_optional(self): from kayako.core.lib import NodeParser assert NodeParser._get_int(self._etree_with_data('123'), required=False, strict=False) == 123 assert NodeParser._get_int(None, required=False, strict=False) == None assert NodeParser._get_int(self._etree_with_data(''), required=False, strict=False) == None assert NodeParser._get_int(self._etree_with_data('abc'), required=False, strict=False) == None
def test__get_int_strict(self): from kayako.core.lib import NodeParser assert NodeParser._get_int(self._etree_with_data('123'), required=False, strict=True) == 123 assert NodeParser._get_int(None, required=False, strict=True) == None assert NodeParser._get_int(self._etree_with_data(''), required=False, strict=True) == None self.assertRaises(ValueError, NodeParser._get_int, self._etree_with_data('abc'), required=False, strict=True)
def test__get_int_required(self): from kayako.core.lib import NodeParser assert NodeParser._get_int(self._etree_with_data("123"), required=True) == 123 self.assertRaises(AttributeError, NodeParser._get_int, None, required=True) self.assertRaises(TypeError, NodeParser._get_int, self._etree_with_data(""), required=True) self.assertRaises(ValueError, NodeParser._get_int, self._etree_with_data("abc"), required=True)
def _get_int(node, required=True, strict=True): try: return NodeParser._get_int(node, required=required, strict=strict) except Exception as error: raise KayakoResponseError( 'There was an error parsing the response (_get_int(%s, required=%s, strict=%s):\n\t%s' % (node, required, strict, error))
def test__get_int_required(self): from kayako.core.lib import NodeParser assert NodeParser._get_int(self._etree_with_data('123'), required=True) == 123 self.assertRaises(AttributeError, NodeParser._get_int, None, required=True) self.assertRaises(TypeError, NodeParser._get_int, self._etree_with_data(''), required=True) self.assertRaises(ValueError, NodeParser._get_int, self._etree_with_data('abc'), required=True)
def _get_int(node, required=True, strict=True): try: return NodeParser._get_int(node, required=required, strict=strict) except Exception as error: raise KayakoResponseError('There was an error parsing the response (_get_int(%s, required=%s, strict=%s):\n\t%s' % (node, required, strict, error))