def test__parse_int_optional(self):
        from kayako.core.object import KayakoRequestParser

        assert KayakoRequestParser._parse_int('123', required=False, strict=False) == 123
        assert KayakoRequestParser._parse_int(None, required=False, strict=False) == None
        assert KayakoRequestParser._parse_int('', required=False, strict=False) == None
        assert KayakoRequestParser._parse_int('abc', required=False, strict=False) == None
    def test__parse_int_strict(self):
        from kayako.exception import KayakoResponseError
        from kayako.core.object import KayakoRequestParser

        assert KayakoRequestParser._parse_int('123', required=False, strict=True) == 123
        assert KayakoRequestParser._parse_int(None, required=False, strict=True) == None
        assert KayakoRequestParser._parse_int('', required=False, strict=True) == None
        self.assertRaises(KayakoResponseError, KayakoRequestParser._parse_int, 'abc', required=False, strict=True)
Beispiel #3
0
    def test__parse_int_optional(self):
        from kayako.core.object import KayakoRequestParser

        assert KayakoRequestParser._parse_int('123',
                                              required=False,
                                              strict=False) == 123
        assert KayakoRequestParser._parse_int(None,
                                              required=False,
                                              strict=False) == None
        assert KayakoRequestParser._parse_int('', required=False,
                                              strict=False) == None
        assert KayakoRequestParser._parse_int('abc',
                                              required=False,
                                              strict=False) == None
    def test__parse_int_required(self):
        from kayako.exception import KayakoResponseError
        from kayako.core.object import KayakoRequestParser

        assert KayakoRequestParser._parse_int('123', required=True) == 123
        self.assertRaises(KayakoResponseError, KayakoRequestParser._parse_int, None, required=True)
        self.assertRaises(KayakoResponseError, KayakoRequestParser._parse_int, '', required=True)
        self.assertRaises(KayakoResponseError, KayakoRequestParser._parse_int, 'abc', required=True)
Beispiel #5
0
    def test__parse_int_strict(self):
        from kayako.exception import KayakoResponseError
        from kayako.core.object import KayakoRequestParser

        assert KayakoRequestParser._parse_int('123',
                                              required=False,
                                              strict=True) == 123
        assert KayakoRequestParser._parse_int(None,
                                              required=False,
                                              strict=True) == None
        assert KayakoRequestParser._parse_int('', required=False,
                                              strict=True) == None
        self.assertRaises(KayakoResponseError,
                          KayakoRequestParser._parse_int,
                          'abc',
                          required=False,
                          strict=True)
Beispiel #6
0
    def test__parse_int_required(self):
        from kayako.exception import KayakoResponseError
        from kayako.core.object import KayakoRequestParser

        assert KayakoRequestParser._parse_int('123', required=True) == 123
        self.assertRaises(KayakoResponseError,
                          KayakoRequestParser._parse_int,
                          None,
                          required=True)
        self.assertRaises(KayakoResponseError,
                          KayakoRequestParser._parse_int,
                          '',
                          required=True)
        self.assertRaises(KayakoResponseError,
                          KayakoRequestParser._parse_int,
                          'abc',
                          required=True)