Exemplo n.º 1
0
def test_columns(db_uri: str, tables_name: List[str], columns: Dict):
    engine, base = get_sqlalchemy_engine(db_uri)
    for table_name in tables_name:
        table = getattr(base.classes, table_name, None)
        cols = [f'{table_name}.{column.key}' for column in table.__table__.columns]
        assert table is not None
        assert cols == columns[table_name]
Exemplo n.º 2
0
 def __init__(self, db_uri):
     self.engine, self.base = get_sqlalchemy_engine(db_uri)
     self.session = get_sqlalchemy_session(self.engine)
     self.tables = get_sqlalchemy_tables(self.base)
     self.tag = None  # hash of string composed of last challenge solve user id and challenge id
     # list of visible challenges ids
     self.challenges = get_visible_challenges(self.session, self.tables)
Exemplo n.º 3
0
def tables(db_uri: str) -> CTFdTables:
    engine, base = get_sqlalchemy_engine(db_uri)
    return get_sqlalchemy_tables(base)
Exemplo n.º 4
0
def session(db_uri: str) -> Session:
    engine, base = get_sqlalchemy_engine(db_uri)
    return get_sqlalchemy_session(engine)
Exemplo n.º 5
0
def test_tables(db_uri: str, tables_name: List[str]):
    engine, base = get_sqlalchemy_engine(db_uri)
    assert tables_name == engine.table_names()