예제 #1
0
    def test_indicar_ausencia(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        funcionario1 = h.get_or_create_funcionario_posto('f1')

        cliente1 = h.get_or_create_cliente('c1')
        wsf1 = WSFila(cliente1)
        turno1 = wsf1.entrar_na_fila(posto1.fila)

        wsp1 = WSPosto(funcionario1)

        wsp1.receive()

        wsp1.ocupar_posto(posto1)

        wsp1.receive()

        wsp1.chamar_seguinte()

        wsp1.receive()
        wsp1.receive()

        wsp1.indicar_ausencia()

        posto1.refresh_from_db()
        self.assertEqual(wsp1.receive(), {
            "message": "POSTO",
            "data": {
                'posto': posto1.to_dict()
            }
        })

        self.assertIsNone(wsp1.receive())
예제 #2
0
    def test_desocupar(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        funcionario1 = h.get_or_create_funcionario_posto('f1')

        wsp1 = WSPosto(funcionario1)

        wsp1.receive()

        wsp1.ocupar_posto(posto1)

        wsp1.receive()

        wsp1.desocupar_posto()

        wsp1.receive()
        self.assertEqual(
            wsp1.receive(), {
                "message": "LOCAIS_DISPONIVEIS",
                "data": {
                    'locais': [model_to_dict(l) for l in Local.objects.all()]
                }
            })

        self.assertIsNone(wsp1.receive())
예제 #3
0
    def test_em_pausa_apos_atendendo(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        funcionario1 = h.get_or_create_funcionario_posto('f1')
        cliente1 = h.get_or_create_cliente('c1')

        wsp1 = WSPosto(funcionario1)
        wsf1 = WSFila(cliente1)

        turno1 = wsf1.entrar_na_fila(posto1.fila)

        wsp1.ocupar_posto(posto1)

        wsp1.chamar_seguinte()

        posto1.refresh_from_db()

        wsp1.atender()

        wsp1.finalizar_atencao()

        posto1.refresh_from_db()
        self.assertEqual(posto1.estado, Posto.EM_PAUSA)
        self.assertEqual(posto1.funcionario.pk, funcionario1.pk)
        self.assertEqual(posto1.turno_em_atencao, None)
예제 #4
0
    def test_cancelar_chamado(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        funcionario1 = h.get_or_create_funcionario_posto('f1')

        wsp1 = WSPosto(funcionario1)

        wsp1.receive()

        wsp1.ocupar_posto(posto1)

        wsp1.receive()

        wsp1.chamar_seguinte()

        wsp1.receive()

        wsp1.cancelar_chamado()

        posto1.refresh_from_db()
        self.assertEqual(wsp1.receive(), {
            "message": "POSTO",
            "data": {
                'posto': posto1.to_dict()
            }
        })

        self.assertIsNone(wsp1.receive())
예제 #5
0
    def test_esperando_cliente(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        funcionario1 = h.get_or_create_funcionario_posto('f1')

        wsp1 = WSPosto(funcionario1)
        wsp1.ocupar_posto(posto1)

        wsp1.chamar_seguinte()
        posto1.refresh_from_db()
        self.assertEqual(posto1.estado, Posto.ESPERANDO_CLIENTE)
예제 #6
0
    def test_em_pausa_apos_ocupado(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        funcionario1 = h.get_or_create_funcionario_posto('f1')

        wsp1 = WSPosto(funcionario1)
        wsp1.ocupar_posto(posto1)

        posto1.refresh_from_db()
        self.assertEqual(posto1.estado, Posto.EM_PAUSA)
        self.assertEqual(posto1.funcionario.pk, funcionario1.pk)
예제 #7
0
    def test_inativo_apos_desocupar(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        funcionario1 = h.get_or_create_funcionario_posto('f1')

        wsp1 = WSPosto(funcionario1)
        wsp1.ocupar_posto(posto1)

        wsp1.desocupar_posto()
        posto1.refresh_from_db()
        self.assertEqual(posto1.estado, Posto.INATIVO)
        self.assertIsNone(posto1.funcionario)
예제 #8
0
    def test_estima_espera_um_cliente_um_posto(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        cliente1 = h.get_or_create_cliente('c1')

        funcionario1 = h.get_or_create_funcionario_posto('f1')
        funcionario1.ocupar_posto(posto1)

        posto1.fila.media_espera = 11
        posto1.fila.save()

        t1 = cliente1.entrar_na_fila(posto1.fila.pk, test_mode=True)

        self.assertEqual(t1.estimar_tempo_espera(), 11)
예제 #9
0
    def test_estima_espera_multiples_clientes_multiples_postos(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        posto2 = h.get_or_create_posto(['l1', 'f1', 'p2'])
        posto3 = h.get_or_create_posto(['l1', 'f1', 'p3'])
        cliente1 = h.get_or_create_cliente('c1')
        cliente2 = h.get_or_create_cliente('c2')
        cliente3 = h.get_or_create_cliente('c3')
        funcionario1 = h.get_or_create_funcionario_posto('f1')
        funcionario2 = h.get_or_create_funcionario_posto('f2')

        funcionario1.ocupar_posto(posto1)
        funcionario2.ocupar_posto(posto2)

        posto1.fila.media_espera = 11
        posto1.fila.save()

        t1 = cliente1.entrar_na_fila(posto1.fila.pk, test_mode=True)
        t2 = cliente2.entrar_na_fila(posto1.fila.pk, test_mode=True)
        t3 = cliente3.entrar_na_fila(posto1.fila.pk, test_mode=True)

        self.assertEqual(t1.estimar_tempo_espera(), 5.5)
        self.assertEqual(t2.estimar_tempo_espera(), 11)
        self.assertEqual(t3.estimar_tempo_espera(), 16.5)
예제 #10
0
    def test_cliente_chamado(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        funcionario1 = h.get_or_create_funcionario_posto('f1')
        cliente1 = h.get_or_create_cliente('c1')

        wsp1 = WSPosto(funcionario1)
        wsf1 = WSFila(cliente1)

        wsp1.ocupar_posto(posto1)

        wsp1.chamar_seguinte()

        turno1 = wsf1.entrar_na_fila(posto1.fila)

        turno1.refresh_from_db()
        self.assertEqual(turno1.estado, Turno.CLIENTE_CHAMADO)
예제 #11
0
    def test_no_atendimento(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        funcionario1 = h.get_or_create_funcionario_posto('f1')
        cliente1 = h.get_or_create_cliente('c1')

        wsp1 = WSPosto(funcionario1)
        wsf1 = WSFila(cliente1)

        wsp1.ocupar_posto(posto1)

        wsp1.chamar_seguinte()

        turno1 = wsf1.entrar_na_fila(posto1.fila)

        wsp1.atender()

        turno1.refresh_from_db()
        self.assertEqual(turno1.estado, Turno.NO_ATENDIMENTO)
예제 #12
0
    def test_cliente_chamado_apos_espera_cliente(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        funcionario1 = h.get_or_create_funcionario_posto('f1')
        cliente1 = h.get_or_create_cliente('c1')

        wsp1 = WSPosto(funcionario1)
        wsf1 = WSFila(cliente1)

        wsp1.ocupar_posto(posto1)

        wsp1.chamar_seguinte()

        posto1.refresh_from_db()
        self.assertEqual(posto1.estado, Posto.ESPERANDO_CLIENTE)

        turno1 = wsf1.entrar_na_fila(posto1.fila)

        posto1.refresh_from_db()
        self.assertEqual(posto1.estado, Posto.CLIENTE_CHAMADO)
        self.assertEqual(posto1.turno_em_atencao.pk, turno1.pk)
예제 #13
0
    def test_get_postos_inativos(self):

        posto1 = h.get_or_create_posto(['l1', 'f1', 'p1'])
        funcionario1 = h.get_or_create_funcionario_posto('f1')

        wsp1 = WSPosto(funcionario1)

        wsp1.receive()

        wsp1.get_postos_inativos(Local.objects.first())

        self.assertEqual(
            wsp1.receive(), {
                "message": "POSTOS_INATIVOS",
                "data": {
                    'postos': [
                        model_to_dict(p) for p in posto1.local.postos.filter(
                            estado=Posto.INATIVO)
                    ]
                }
            })

        self.assertIsNone(wsp1.receive())