Пример #1
0
    def test_load(self, monkeypatch):
        monkeypatch.setattr('libturpial.config.AccountConfig', DummyConfig)

        with pytest.raises(ErrorLoadingAccount):
            Account.load('foo-twitter')

        # Monkeypatching Account.exists
        monkeypatch.setattr(os.path, 'isfile', lambda x: True)

        # Monkeypatching AppConfig create
        monkeypatch.setattr(os, 'makedirs', lambda x: None)
        monkeypatch.setattr(__builtin__, 'open', lambda x, y: DummyFileHandler())
        monkeypatch.setattr(AccountConfig, 'create', lambda: None)
        monkeypatch.setattr(AccountConfig, 'load_oauth_credentials', lambda x: ('123', '456'))

        monkeypatch.setattr('libturpial.api.models.account.Account', DummyAccount)
        Account.load('foo-twitter')
Пример #2
0
    def test_load(self, monkeypatch):
        monkeypatch.setattr('libturpial.config.AccountConfig', DummyConfig)

        with pytest.raises(ErrorLoadingAccount):
            Account.load('foo-twitter')

        # Monkeypatching Account.exists
        monkeypatch.setattr(os.path, 'isfile', lambda x: True)

        # Monkeypatching AppConfig create
        monkeypatch.setattr(os, 'makedirs', lambda x: None)
        monkeypatch.setattr(__builtin__, 'open',
                            lambda x, y: DummyFileHandler())
        monkeypatch.setattr(AccountConfig, 'create', lambda: None)
        monkeypatch.setattr(AccountConfig, 'load_oauth_credentials', lambda x:
                            ('123', '456'))

        monkeypatch.setattr('libturpial.api.models.account.Account',
                            DummyAccount)
        Account.load('foo-twitter')
Пример #3
0
    def load(self, account_id):
        """
        Load and existing account identified by *account_id*. If the load
        fails an :class:`libturpial.exceptions.ErrorLoadingAccount` exception
        will raise. Return the id of the account loaded on success
        """
        # TODO: Set the timeout
        #timeout = int(self.config.read('Advanced', 'socket-timeout'))
        #self.protocol.timeout = timeout

        self.__accounts[account_id] = Account.load(account_id)
        return account_id
Пример #4
0
    def load(self, account_id):
        """
        Load and existing account identified by *account_id*. If the load
        fails an :class:`libturpial.exceptions.ErrorLoadingAccount` exception
        will raise. Return the id of the account loaded on success
        """
        # TODO: Set the timeout
        #timeout = int(self.config.read('Advanced', 'socket-timeout'))
        #self.protocol.timeout = timeout

        self.__accounts[account_id] = Account.load(account_id)
        return account_id