Пример #1
0
Файл: db.py Проект: kennyeric/dm
class Item(Base):
    __tablename__ = "item"

    id = Column('item_id', Integer, primary_key=True, autoincrement=True)
    tags = Column(VARCHAR(2048))
    link = Column(VARCHAR(256))
    source = Column(VARCHAR(256))
    source_id = Column(VARCHAR(512), ColumnDefault(""))
    title = Column(VARCHAR(1024))
    description = Column(VARCHAR(1024))
    publish_date = Column(DATETIME, ColumnDefault(datetime.datetime.now()))
    tag = Column(VARCHAR(2048))
    old_id = Column(Integer)
    url = Column(VARCHAR(256))
    review = Column(Integer)

    def __init__(self, tags, link, source, source_id, title, description,
                 publish_date, tag, old_id, url, review):
        self.tags = tags
        self.link = link
        self.source = source
        self.source_id = source_id
        self.title = title
        self.description = description
        self.publish_date = publish_date
        self.tag = tag
        self.old_id = old_id
        self.url = url
        self.review = review

    def __repr__(self):
        return "<Item('%s', '%s', '%s', '%s', '%s', '%s', '%s')>" % (
            self.tags, self.link, self.source, self.source_id, self.title,
            self.description, self.publish_date, self.tag, self.old_id,
            self.url, self.review)
Пример #2
0
 def test_post_default_value_0(self):
     new_default = ColumnDefault(0)
     new_default.column = self.test_sql_tables.People.prog.\
         property.columns[0]
     self.test_sql_tables.People.prog.property.\
         columns[0].default = new_default
     prog = self.domain['people']['schema']['prog']
     prog['default'] = 0
     self.app.set_defaults()
     data = {'firstname': 'Isaac'}
     self.assertPostItem(data, 'prog', 0)
     # reset default
     self.test_sql_tables.People.prog.property.columns[0].default = None
Пример #3
0
class RelationTag(Base):
    __tablename__ = "relation_tag"

    id = Column('relation_tag_id', Integer, primary_key=True, autoincrement=True)
    source_id = Column(Integer)
    target_id = Column(Integer)
    relation = Column(Float, ColumnDefault(0.5))

    def __init__(self, source_id, target_id, relation):
        self.source_id = source_id
        self.target_id = target_id
        self.relation = relation

    def __repr__(self):
        return "<RelationTag('%s', '%s', '%s')>" % (self.source_id, self.target_id, self.relation)
Пример #4
0
 def test_post_default_value_empty_string(self):
     old_default = self.test_sql_tables.People.title.\
         property.columns[0].default
     new_default = ColumnDefault('')
     new_default.column = self.test_sql_tables.People.title.\
         property.columns[0]
     self.test_sql_tables.People.title.property.\
         columns[0].default = new_default
     title = self.domain['people']['schema']['title']
     title['default'] = ''
     self.app.set_defaults()
     data = {'firstname': 'Douglas'}
     self.assertPostItem(data, 'title', '')
     # reset default
     self.test_sql_tables.People.title.property.\
         columns[0].default = old_default