예제 #1
0
 def test_get_all(self):
     with self.current_api.app_context():
         ClientService.add('admin1', '*****@*****.**')
         ClientService.add('admin2', '*****@*****.**')
         ClientService.add('admin3', '*****@*****.**')
         clients = ClientService.get_all()
         self.assertNotEqual(len(clients), 0)
예제 #2
0
from api import create_api, db
from api.clients.models import Client
from api.clients.services import ClientService
from api.finances.services import RecordService

api = create_api('config')

if __name__ == "__main__":
    with api.app_context():

        # remove todas as tabelas do banco
        db.drop_all()

        # (re)cria o banco de dados
        db.create_all()

        # Testes de consultas
        users = Client.query.all()

        # Adiciona um usuário
        for i in range(1000):
            username, email = f'admin{i}', f'admin{i}@finances.com'
            u = Client(username, email)
            db.session.add(u)
            db.session.commit()

        data = ClientService.get_all()
        print(data)

        data = RecordService.get_all()
        print(data)
예제 #3
0
def get_clients():
    clients = ClientService.get_all()
    clients_schema = ClientSchema(many=True)
    return clients_schema.jsonify(clients)