def test_registering(self, monkeypatch): dummy = Account('twitter') monkeypatch.setattr(self.core.accman, "register", lambda x: self.acc_id) monkeypatch.setattr(self.core.column_manager, "register", lambda x: "dummy-twitter-column1") result = self.core.register_account(dummy) assert isinstance(result, str) result = self.core.register_column("dummy-twitter-column1") assert isinstance(result, str)
def register(self, username, protocol_id, passwd, auth): if username == '' or protocol_id == '': return None account_id = "%s-%s" % (username, protocol_id) if self.__accounts.has_key(account_id): self.log.debug('Account %s is already registered' % account_id) self.__accounts[account_id].update(passwd) else: account = Account(username, account_id, protocol_id, passwd, auth) timeout = int(self.config.read('Advanced', 'socket-timeout')) account.protocol.timeout = timeout self.log.debug('Using %i sec for socket timeout in account %s' % (account.protocol.timeout, account_id)) self.__accounts[account_id] = account self.log.debug('Account %s registered successfully' % account_id) return account_id
def load(self, account_id): cfg = AccountConfig(account_id) auth = cfg.read_section('OAuth') username = cfg.read('Login', 'username') protocol = cfg.read('Login', 'protocol') p = cfg.revert(cfg.read('Login', 'password'), username) if self.__accounts.has_key(account_id): self.log.debug('Account %s is already registered' % account_id) else: account = Account(username, account_id, protocol, p, auth, cfg) timeout = int(self.config.read('Advanced', 'socket-timeout')) account.protocol.timeout = timeout self.log.debug('Using %i sec for socket timeout in account %s' % (account.protocol.timeout, account_id)) self.__accounts[account_id] = account self.log.debug('Account %s loaded successfully' % account_id) return account_id
def test_init(self): account = Account('twitter') assert isinstance(account.protocol, MainTwitter) account = Account('identica') assert isinstance(account.protocol, MainIdentica)
def setup_class(self, monkeypatch): self.account = Account('twitter', 'foo')