예제 #1
0
 def setup_class(self, monkeypatch):
     self.acc_id = "dummy-twitter"
     self.core = Core(load_accounts=False)
     self.account = Account.new("twitter", "dummy")
     self.account.columns = [Column(self.account.id_, ColumnType.TIMELINE)]
     self.account2 = Account.new("twitter", "qux")
     self.account2.columns = [Column(self.account2.id_, ColumnType.TIMELINE)]
     self.all_accounts = [self.account, self.account2]
     monkeypatch.setattr(self.core.accman, "get", lambda x: self.account)
예제 #2
0
    def fetch(self):
        """
        Retrieve the user profile information and return the id of the account
        on success. This method authenticate the account.
        """
        self.profile = self.protocol.verify_credentials()
        self.lists = self.protocol.get_lists(self.profile.username)

        self.columns = [
            Column(self.id_, ColumnType.TIMELINE),
            Column(self.id_, ColumnType.REPLIES),
            Column(self.id_, ColumnType.DIRECTS),
            Column(self.id_, ColumnType.SENT),
            Column(self.id_, ColumnType.FAVORITES)] + self.lists
        return self.id_
예제 #3
0
    def __load_registered(self):
        self.__registered_columns = {}

        for column_id in self.config.get_stored_columns():
            account_id = get_account_id_from(column_id)
            column_slug = get_column_slug_from(column_id)
            if account_id not in self.__registered_columns:
                self.__registered_columns[account_id] = []
            self.__registered_columns[account_id].append(
                Column(account_id, column_slug))
예제 #4
0
 def columns_by_order(self):
     i = 1
     columns = []
     while True:
         column_num = "column%s" % i
         column_id = self.config.read('Columns', column_num)
         if column_id:
             account_id = get_account_id_from(column_id)
             column_slug = get_column_slug_from(column_id)
             columns.append(Column(account_id, column_slug))
             i += 1
         else:
             break
     return columns
예제 #5
0
 def all_columns(self):
     columns = {}
     for account in self.all_accounts():
         columns[account.id_] = {}
         if account.logged_in != LoginStatus.DONE: continue
         for col in account.get_columns():
             id_ = ""
             for reg in self.reg_columns:
                 if account.id_ == reg.account_id and reg.column_name == col:
                     id_ = reg.id_
                     break
             item = Column(id_, account.id_, account.protocol_id, col)
             columns[account.id_][col] = item
     return columns
예제 #6
0
    def get_stored_columns(self):
        stored_cols = self.read_section('Columns')
        indexes = stored_cols.keys()
        indexes.sort()
        columns = []

        for i in indexes:
            value = stored_cols[i]
            if value != '':
                temp = value.rfind('-')
                acc_id = value[:temp]
                pt_id = acc_id.split('-')[1]
                col_id = value[temp + 1:]
                id_ = "%s-%s" % (acc_id, col_id)
                columns.append(Column(id_, acc_id, pt_id, col_id))
        return columns
예제 #7
0
    def test_get_single_column(self, monkeypatch):
        dummy = Column(self.acc_id, "foo")
        monkeypatch.setattr(self.core.column_manager, "get", lambda x: dummy)

        column = self.core.get_single_column("dummy-twitter-column")
        assert isinstance(column, Column)
예제 #8
0
 def setup_class(self):
     self.column = Column("foo-twitter", "timeline")