Exemplo n.º 1
0
def test_get_all():
    accion_repo = AccionRepository()
    evento_repo = EventoRepository()

    accion_repo.purge_table()
    a = Accion(idd=Idd(Idefier()),
               nombre="accion_buen_humor",
               script_url="git://script_url",
               tipo=TipoAccion(nombre="buenhumor"))
    a1 = Accion(idd=Idd(Idefier()),
                nombre="accion_buen_humor1",
                script_url="git://script_url",
                tipo=TipoAccion(nombre="buenhumor"))

    a2 = Accion(idd=Idd(Idefier()),
                nombre="accion_mal_humor",
                script_url="git://script_url",
                tipo=TipoAccion(nombre="malhumor"))
    accion_repo.append_accion(a, evento_repo)
    accion_repo.append_accion(a1, evento_repo)
    accion_repo.append_accion(a2, evento_repo)

    count = 0
    for acc in accion_repo.get_all_json():
        assert isinstance(acc, dict)
        count = count + 1
    assert count == 3
 def serialize(comando: Comando) -> str:
     if isinstance(comando, ComandoNuevaTarea):
         return json.dumps({
             "clase": "ComandoNuevaTarea",
             "idd": str(comando.idd),
             "tarea": TareaRepository.to_json(comando.tarea)
         })
     if isinstance(comando, ComandoNuevaAccion):
         return json.dumps({
             "clase":
             "ComandoNuevaAccion",
             "idd":
             str(comando.idd),
             "accion":
             AccionRepository.to_json(accion=comando.accion)
         })
Exemplo n.º 3
0
def test_get_by_id():

    accion_repo = AccionRepository()
    evento_repo = EventoRepository()
    accion_repo.purge_table()
    a = Accion(idd=Idd(Idefier()),
               nombre="nombreaccion",
               script_url="git://script_url",
               tipo=TipoAccion(nombre="buenhumor"))

    accion_repo.append_accion(a, evento_repo)
    a2 = Accion(idd=Idd(Idefier()),
                nombre="nombreaccion2",
                script_url="git://script_url2",
                tipo=TipoAccion(nombre="malhumor"))

    with pytest.raises(AccionNotFoundException):
        acc = accion_repo.get_accion_by_id(a2.idd)

    acc = accion_repo.get_accion_by_id(a.idd)
    assert acc.idd == a.idd
    assert acc.tipo == a.tipo
 def deserialize_comando_nueva_accion(comando: dict) -> ComandoNuevaAccion:
     return ComandoNuevaAccion(idd=Idd(Idefier(), idd_str=comando['idd']),
                               accion=AccionRepository.deserialize(
                                   comando['accion']))
Exemplo n.º 5
0

from trasto.infrastructure.awsmultiprocess.accion_repository import \
    AccionRepository
from trasto.infrastructure.awsmultiprocess.comando_repository import \
    ComandoRepository
from trasto.infrastructure.memory.repositories import (EstadoDeHumorRepository,
                                                       Idefier,
                                                       LoggerRepository)
from trasto.model.commands import ComandoNuevaAccion, ComandoNuevaTarea
from trasto.model.entities import Accion, Tarea, TipoAccion
from trasto.model.value_entities import Idd

logger = LoggerRepository('web')

accion_repo = AccionRepository()
accion_repo.purge_table()

app = Flask(__name__)


@app.route('/', methods=[
    'GET',
])
def get_service():
    logger.debug("Solicitada get_service")
    return {
        "service": "trastobrain",
    }

Exemplo n.º 6
0
def start():
    Comander().listen_to_command(ComandoRepository(), TareaRepository(),
                                 AccionRepository(), EventoRepository())
Exemplo n.º 7
0
def start():
    Ejecutor().listen_for_next_tarea(Idefier(), TareaRepository(), EventoRepository(), AccionRepository())