def client(): app.config['TESTING'] = True client = app.test_client() app.config['SQLALCHEMY_DATABASE_URI'] = f'postgresql://{DB_LOGIN}:{DB_PASSWORD}@{DB_URL}/{DB_NAME}_test' db.drop_all() db.create_all() yield client
""" Citizen = db.Table( 'citizen', db.metadata, db.Column('id', db.Integer, primary_key=True), db.Column('import_id', db.Integer, db.ForeignKey(Import.c.id)), db.Column('citizen_id', db.Integer, nullable=False), db.Column('town', db.String, nullable=False), db.Column('street', db.String, nullable=False), db.Column('building', db.String, nullable=False), db.Column('apartment', db.Integer, nullable=False), db.Column('name', db.String, nullable=False), db.Column('birth_date', db.Date, nullable=False), db.Column('gender', db.String, nullable=False) ) """ Relationship entry between citizens. Consists of a composite primary key: citizen_id, relative_id both referencing citizen's id field. """ Relative = db.Table( 'relative', db.metadata, db.Column('citizen_id', db.Integer, db.ForeignKey('citizen.id'), primary_key=True), db.Column('relative_id', db.Integer, db.ForeignKey('citizen.id'), primary_key=True) ) if __name__ == '__main__': db.drop_all() db.create_all()