Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

add welcome table to db #341

Merged
merged 8 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file renamed MirahezeBots/hasan.db → MirahezeBots/example.db
Binary file not shown.
15 changes: 14 additions & 1 deletion tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,23 @@ def __str__(self):
return NickNames.__str__(self)


class Welcome(Base):
__tablename__ = 'welcome'
welcome_id = Column(Integer, primary_key=True)
nick_id = Column(Integer)
account = Column(String)
channel = Column(String)
timestamp = Column(String)
message = Column(String)

def __str__(self):
return Welcome.__str__(self)


if __name__ == '__main__':
try:
engine = create_engine('sqlite:///{0}'.format(sys.argv[1]), echo=True)
except IndexError:
print('argument not provided')
engine = create_engine('sqlite:///hasan2.db', echo=True)
engine = create_engine('sqlite:///example-model.db', echo=True)
Base.metadata.create_all(engine)
6 changes: 3 additions & 3 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

def test_db_schema_is_same():
original, new = set(), set() # noqa: F841
with sqlite3.connect(os.path.join(PATH, 'hasan.db')) as conn:
with sqlite3.connect(os.path.join(PATH, 'example.db')) as conn:
conn.text_factory = str
res = conn.execute("SELECT name FROM sqlite_master WHERE type='table';")
[original.add(tbl[0]) for tbl in res if not tbl[0] == 'nick_ids' and not tbl[0] == 'sqlite_sequence']

try:
os.unlink(os.path.join(PATH, "hasan2.db"))
os.unlink(os.path.join(PATH, "example-model.db"))
except FileNotFoundError:
pass

engine = create_engine('sqlite:///{0}'.format(os.path.join(PATH, "..", "hasan2.db")))
engine = create_engine('sqlite:///{0}'.format(os.path.join(PATH, "..", "example-model.db")))
models.Base.metadata.create_all(bind=engine)
assert original == set(engine.table_names())

Expand Down