Esempio n. 1
0
 def read(self, iprot):
     if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(
             iprot.trans, TTransport.CReadableTransport
     ) and self.thrift_spec is not None and fastbinary is not None:
         fastbinary.decode_binary(self, iprot.trans,
                                  (self.__class__, self.thrift_spec))
         return
     iprot.readStructBegin()
     while True:
         (fname, ftype, fid) = iprot.readFieldBegin()
         if ftype == TType.STOP:
             break
         if fid == 0:
             if ftype == TType.STRING:
                 self.success = iprot.readString()
             else:
                 iprot.skip(ftype)
         elif fid == 1:
             if ftype == TType.STRUCT:
                 self.userException = EDAMUserException()
                 self.userException.read(iprot)
             else:
                 iprot.skip(ftype)
         elif fid == 2:
             if ftype == TType.STRUCT:
                 self.systemException = EDAMSystemException()
                 self.systemException.read(iprot)
             else:
                 iprot.skip(ftype)
         else:
             iprot.skip(ftype)
         iprot.readFieldEnd()
     iprot.readStructEnd()
Esempio n. 2
0
 def read(self, iprot):
     if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
         fastbinary.decode_binary(self, iprot.trans,
                                  (self.__class__, self.thrift_spec))
         return
     iprot.readStructBegin()
     while True:
         (fname, ftype, fid) = iprot.readFieldBegin()
         if ftype == TType.STOP:
             break
         if fid == 0:
             if ftype == TType.STRING:
                 self.success = iprot.readString()
             else:
                 iprot.skip(ftype)
         elif fid == 1:
             if ftype == TType.STRUCT:
                 self.userException = EDAMUserException()
                 self.userException.read(iprot)
             else:
                 iprot.skip(ftype)
         elif fid == 2:
             if ftype == TType.STRUCT:
                 self.systemException = EDAMSystemException()
                 self.systemException.read(iprot)
             else:
                 iprot.skip(ftype)
         else:
             iprot.skip(ftype)
         iprot.readFieldEnd()
     iprot.readStructEnd()
Esempio n. 3
0
def test_cli_program_error_rate_limit(mocker, caplog):
    cli_mock = mocker.patch("evernote_backup.cli.cli")
    cli_mock.side_effect = EDAMSystemException(errorCode=19,
                                               rateLimitDuration=10)

    with pytest.raises(SystemExit):
        cli_module.main()

    assert "Rate limit reached" in caplog.messages[0]
Esempio n. 4
0
def test_cli_program_error_unexpected_edam(mocker, caplog):
    cli_mock = mocker.patch("evernote_backup.cli.cli")
    cli_mock.side_effect = EDAMSystemException(errorCode=100)

    with pytest.raises(SystemExit):
        cli_module.main()

    assert "EDAMSystemException" in caplog.messages[0]
    assert "Traceback" in caplog.messages[0]
Esempio n. 5
0
    def getUser(self, authenticationToken):
        if self.fake_values.fake_network_counter > 0:
            self.fake_values.fake_network_counter -= 1
            raise ConnectionError

        if self.fake_values.fake_auth_verify_unexpected_error:
            raise EDAMUserException()
        if self.fake_values.fake_is_token_expired:
            raise EDAMUserException(errorCode=EDAMErrorCode.AUTH_EXPIRED,
                                    parameter="authenticationToken")
        if self.fake_values.fake_is_token_invalid:
            raise EDAMUserException(errorCode=EDAMErrorCode.INVALID_AUTH,
                                    parameter="authenticationToken")
        if self.fake_values.fake_is_token_bad:
            raise EDAMSystemException(errorCode=EDAMErrorCode.BAD_DATA_FORMAT,
                                      message="authenticationToken")
        return MagicMock(username=self.fake_values.fake_user)
Esempio n. 6
0
class getNoteStoreUrl_result(object):
    """
    Attributes:
     - success
     - userException
     - systemException
    """

    thrift_spec = ((
        0,
        TType.STRING,
        'success',
        None,
        None,
    ), (
        1,
        TType.STRUCT,
        'userException',
        (EDAMUserException, EDAMUserException.thrift_spec),
        None,
    ), (
        2,
        TType.STRUCT,
        'systemException',
        (EDAMSystemException, EDAMSystemException.thrift_spec),
        None,
    ))

    def __init__(
        self,
        success=None,
        userException=None,
        systemException=None,
    ):
        self.success = success
        self.userException = userException
        self.systemException = systemException

    def read(self, iprot):
        if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(
                iprot.trans, TTransport.CReadableTransport
        ) and self.thrift_spec is not None and fastbinary is not None:
            fastbinary.decode_binary(self, iprot.trans,
                                     (self.__class__, self.thrift_spec))
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 0:
                if ftype == TType.STRING:
                    self.success = iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 1:
                if ftype == TType.STRUCT:
                    self.userException = EDAMUserException()
                    self.userException.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRUCT:
                    self.systemException = EDAMSystemException()
                    self.systemException.read(iprot)
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
            if self.thrift_spec is not None and fastbinary is not None:
                oprot.trans.write(
                    fastbinary.encode_binary(
                        self, (self.__class__, self.thrift_spec)))
                return
        oprot.writeStructBegin('getNoteStoreUrl_result')
        if self.success is not None:
            oprot.writeFieldBegin('success', TType.STRING, 0)
            oprot.writeString(self.success)
            oprot.writeFieldEnd()
        if self.userException is not None:
            oprot.writeFieldBegin('userException', TType.STRUCT, 1)
            self.userException.write(oprot)
            oprot.writeFieldEnd()
        if self.systemException is not None:
            oprot.writeFieldBegin('systemException', TType.STRUCT, 2)
            self.systemException.write(oprot)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value) for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other,
                          self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)
Esempio n. 7
0
class getNoteStoreUrl_result(object):
    """
    Attributes:
     - success
     - userException
     - systemException
    """

    thrift_spec = (
        (0, TType.STRING, 'success', None, None,),
        (1, TType.STRUCT, 'userException', (EDAMUserException,
                                            EDAMUserException.thrift_spec), None,),
        (2, TType.STRUCT, 'systemException', (EDAMSystemException, EDAMSystemException.thrift_spec), None,)
    )

    def __init__(self, success=None, userException=None, systemException=None,):
        self.success = success
        self.userException = userException
        self.systemException = systemException

    def read(self, iprot):
        if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
            fastbinary.decode_binary(self, iprot.trans,
                                     (self.__class__, self.thrift_spec))
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 0:
                if ftype == TType.STRING:
                    self.success = iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 1:
                if ftype == TType.STRUCT:
                    self.userException = EDAMUserException()
                    self.userException.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRUCT:
                    self.systemException = EDAMSystemException()
                    self.systemException.read(iprot)
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated:
            if self.thrift_spec is not None and fastbinary is not None:
                oprot.trans.write(fastbinary.encode_binary(self, (self.__class__,
                                                                  self.thrift_spec)))
                return
        oprot.writeStructBegin('getNoteStoreUrl_result')
        if self.success is not None:
            oprot.writeFieldBegin('success', TType.STRING, 0)
            oprot.writeString(self.success)
            oprot.writeFieldEnd()
        if self.userException is not None:
            oprot.writeFieldBegin('userException', TType.STRUCT, 1)
            self.userException.write(oprot)
            oprot.writeFieldEnd()
        if self.systemException is not None:
            oprot.writeFieldBegin('systemException', TType.STRUCT, 2)
            self.systemException.write(oprot)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.iteritems()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)