import pytest

from models.model import Student
from mysql_orm.client import MysqlORMClient
from utils.builder_orm import MysqlORMBuilder


class MysqlBase:

    # is called from setup fixture on every test. test can override this method for its custom data prepare
    def prepare(self):
        pass

    @pytest.fixture(scope='function', autouse=True)
    def setup(self, mysql_orm_client):
        self.mysql: MysqlORMClient = mysql_orm_client
        self.mysql_builder: MysqlORMBuilder = MysqlORMBuilder(self.mysql)

        self.prepare()

    def get_students(self, prepod_id=None):
        self.mysql.session.commit()  # need to expire current models and get updated data from MySQL
        students = self.mysql.session.query(Student)

        # additionally filter by prepod_id
        if prepod_id is not None:
            students = students.filter_by(prepod_id=prepod_id)
        return students.all()

7d0bc5cefef88e885929ae24a594ccc85a3f285c
<mask token>


class MysqlBase:

    def prepare(self):
        pass
    <mask token>
    <mask token>

<mask token>


class MysqlBase:

    def prepare(self):
        pass
    <mask token>

    def get_students(self, prepod_id=None):
        self.mysql.session.commit()
        students = self.mysql.session.query(Student)
        if prepod_id is not None:
            students = students.filter_by(prepod_id=prepod_id)
        return students.all()

<mask token>


class MysqlBase:

    def prepare(self):
        pass

    @pytest.fixture(scope='function', autouse=True)
    def setup(self, mysql_orm_client):
        self.mysql: MysqlORMClient = mysql_orm_client
        self.mysql_builder: MysqlORMBuilder = MysqlORMBuilder(self.mysql)
        self.prepare()

    def get_students(self, prepod_id=None):
        self.mysql.session.commit()
        students = self.mysql.session.query(Student)
        if prepod_id is not None:
            students = students.filter_by(prepod_id=prepod_id)
        return students.all()

import pytest
from models.model import Student
from mysql_orm.client import MysqlORMClient
from utils.builder_orm import MysqlORMBuilder


class MysqlBase:

    def prepare(self):
        pass

    @pytest.fixture(scope='function', autouse=True)
    def setup(self, mysql_orm_client):
        self.mysql: MysqlORMClient = mysql_orm_client
        self.mysql_builder: MysqlORMBuilder = MysqlORMBuilder(self.mysql)
        self.prepare()

    def get_students(self, prepod_id=None):
        self.mysql.session.commit()
        students = self.mysql.session.query(Student)
        if prepod_id is not None:
            students = students.filter_by(prepod_id=prepod_id)
        return students.all()

import pytest

from models.model import Student
from mysql_orm.client import MysqlORMClient
from utils.builder_orm import MysqlORMBuilder


class MysqlBase:

    # is called from setup fixture on every test. test can override this method for its custom data prepare
    def prepare(self):
        pass

    @pytest.fixture(scope='function', autouse=True)
    def setup(self, mysql_orm_client):
        self.mysql: MysqlORMClient = mysql_orm_client
        self.mysql_builder: MysqlORMBuilder = MysqlORMBuilder(self.mysql)

        self.prepare()

    def get_students(self, prepod_id=None):
        self.mysql.session.commit()  # need to expire current models and get updated data from MySQL
        students = self.mysql.session.query(Student)

        # additionally filter by prepod_id
        if prepod_id is not None:
            students = students.filter_by(prepod_id=prepod_id)
        return students.all()
