Beispiel #1
0
    def test__get_boolean_strict(self):
        from kayako.exception import KayakoResponseError
        from kayako.core.object import KayakoRequestParser

        assert KayakoRequestParser._get_boolean(self._etree_with_data('1'),
                                                required=False,
                                                strict=True) == True
        assert KayakoRequestParser._get_boolean(self._etree_with_data('0'),
                                                required=False,
                                                strict=True) == False
        assert KayakoRequestParser._get_boolean(None,
                                                required=False,
                                                strict=True) == None
        assert KayakoRequestParser._get_boolean(self._etree_with_data(''),
                                                required=False,
                                                strict=True) == None
        self.assertRaises(KayakoResponseError,
                          KayakoRequestParser._get_boolean,
                          self._etree_with_data('abc'),
                          required=False,
                          strict=True)
        self.assertRaises(KayakoResponseError,
                          KayakoRequestParser._get_boolean,
                          self._etree_with_data('2'),
                          required=False,
                          strict=True)
    def test__get_boolean_required(self):
        from kayako.exception import KayakoResponseError
        from kayako.core.object import KayakoRequestParser

        assert KayakoRequestParser._get_boolean(self._etree_with_data('1'), required=True) == True
        assert KayakoRequestParser._get_boolean(self._etree_with_data('0'), required=True) == False
        self.assertRaises(KayakoResponseError, KayakoRequestParser._get_boolean, None, required=True)
        self.assertRaises(KayakoResponseError, KayakoRequestParser._get_boolean, self._etree_with_data(''), required=True)
        self.assertRaises(KayakoResponseError, KayakoRequestParser._get_boolean, self._etree_with_data('abc'), required=True)
    def test__get_boolean_optional(self):
        from kayako.core.object import KayakoRequestParser

        assert KayakoRequestParser._get_boolean(self._etree_with_data('1'), required=False, strict=False) == True
        assert KayakoRequestParser._get_boolean(self._etree_with_data('0'), required=False, strict=False) == False
        assert KayakoRequestParser._get_boolean(None, required=False, strict=False) == None
        assert KayakoRequestParser._get_boolean(self._etree_with_data(''), required=False, strict=False) == None
        assert KayakoRequestParser._get_boolean(self._etree_with_data('abc'), required=False, strict=False) == None
        assert KayakoRequestParser._get_boolean(self._etree_with_data('2'), required=False, strict=False) == True
Beispiel #4
0
    def test__get_boolean_optional(self):
        from kayako.core.object import KayakoRequestParser

        assert KayakoRequestParser._get_boolean(self._etree_with_data('1'),
                                                required=False,
                                                strict=False) == True
        assert KayakoRequestParser._get_boolean(self._etree_with_data('0'),
                                                required=False,
                                                strict=False) == False
        assert KayakoRequestParser._get_boolean(None,
                                                required=False,
                                                strict=False) == None
        assert KayakoRequestParser._get_boolean(self._etree_with_data(''),
                                                required=False,
                                                strict=False) == None
        assert KayakoRequestParser._get_boolean(self._etree_with_data('abc'),
                                                required=False,
                                                strict=False) == None
        assert KayakoRequestParser._get_boolean(self._etree_with_data('2'),
                                                required=False,
                                                strict=False) == True