Skip to content

Commit

Permalink
Merge pull request #406 from fga-eps-mds/feature#405/intent-stop
Browse files Browse the repository at this point in the history
Feature#405/intent stop
  • Loading branch information
DouglasMonteles authored Oct 26, 2021
2 parents 2b38b7f + c1487af commit 15ebf8a
Show file tree
Hide file tree
Showing 17 changed files with 99 additions and 88 deletions.
4 changes: 0 additions & 4 deletions actions/ResponderQuantidadeInfectadosPorPeriodoAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,4 @@ def run(

dispatcher.utter_message(text=mensagem)


return [AllSlotsReset()]



2 changes: 0 additions & 2 deletions actions/ResponderQuantidadeMortosPorPeriodoAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,4 @@ def run(

dispatcher.utter_message(text=mensagem)


return [AllSlotsReset()]

1 change: 0 additions & 1 deletion actions/ResponderQuantidadeVacinadosPorPeriodoAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ def run(
dispatcher.utter_message(text=mensagem)

return [AllSlotsReset()]

1 change: 0 additions & 1 deletion actions/ResponderSobreCovidAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,4 @@ def run(

dispatcher.utter_message(text=mensagem)


return [AllSlotsReset()]
1 change: 0 additions & 1 deletion actions/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
from actions.ResponderQuantidadeInfectadosPorPeriodoAction import ResponderQuantidadeInfectadosPorPeriodoAction
from actions.ResponderQuantidadeMortosPorPeriodoAction import ResponderQuantidadeMortosPorPeriodoAction
from actions.ResponderQuantidadeVacinadosPorPeriodoAction import ResponderQuantidadeVacinadosPorPeriodoAction

15 changes: 7 additions & 8 deletions actions/tests/test_ResponderLembreteProximaVacinaAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.events import AllSlotsReset
from actions.ResponderLembreteProximaVacinaAction import ActionCadastrarLembrete, ActionLembrarUsuario

from actions.ResponderLembreteProximaVacinaAction import ActionCadastrarLembrete, ActionLembrarUsuario


class FakeDomain:
Expand All @@ -12,11 +11,10 @@ def __init__(self):


class FakeTracker:
def get_slot(self, slot):
def get_slot(self, slot):
pass



class ActionCadastrarLembreteTest:

def setup(self, mocker):
Expand All @@ -25,13 +23,13 @@ def setup(self, mocker):
self.tracker = FakeTracker()
self.domain = FakeDomain()

def test_name(self,mocker):
def test_name(self, mocker):
self.setup(mocker)
assert self.service.name() == "action_cadastrar_lembrete_proxima_dose"


def test_ActionCadastrarLembrete(mocker):
ActionCadastrarLembreteTest().test_name(mocker)
ActionCadastrarLembreteTest().test_name(mocker)


class ActionLembrarUsuarioTest:
Expand All @@ -42,9 +40,10 @@ def setup(self, mocker):
self.tracker = FakeTracker()
self.domain = FakeDomain()

def test_name(self,mocker):
def test_name(self, mocker):
self.setup(mocker)
assert self.service.name() == "action_enviar_lembrete_da_proxima_dose_da_vacina"


def test_ActionLembrarUsuario(mocker):
ActionLembrarUsuarioTest().test_name(mocker)
ActionLembrarUsuarioTest().test_name(mocker)
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@
def teste_nome():
return ResponderQuantidadeInfectadosPorPeriodoAction()


@pytest.fixture
def test_name(teste_nome):
name = teste_nome.name()
assert name == 'action_responder_quantidade_infectados_por_periodo'


class FakeDomain:
def __init__(self):
pass


class FakeTracker:
def get_slot(self, slot):
def get_slot(self, slot):
pass



class ResponderQuantidadeInfectadosPorPeriodoActionTest:

def setup(self, mocker):
Expand All @@ -32,18 +33,20 @@ def setup(self, mocker):
self.tracker = FakeTracker()
self.domain = FakeDomain()

def test_name(self,mocker):
def test_name(self, mocker):
self.setup(mocker)
assert self.service.name() == 'action_responder_quantidade_infectados_por_periodo'

def test_bot(self,mocker):
def test_bot(self, mocker):
self.setup(mocker)
mocker.patch.object(self.tracker,"get_slot",return_value="23/12/1970")
mocker.patch.object(self.tracker, "get_slot",
return_value="23/12/1970")

self.service.run(self.dispatcher,self.tracker,self.domain)
assert self.dispatcher.messages[0]['text'].startswith('Não consegui encontrar nenhum registro para a data 23/12/1970-23/12/1970-23/12/1970 🥺. Lembre-se de informar valores válidos e somente o número do dia, do mês e do ano 😉')
self.service.run(self.dispatcher, self.tracker, self.domain)
assert self.dispatcher.messages[0]['text'].startswith(
'Não consegui encontrar nenhum registro para a data 23/12/1970-23/12/1970-23/12/1970 🥺. Lembre-se de informar valores válidos e somente o número do dia, do mês e do ano 😉')


def test_ResponderQuantidadeVacinadosPorPeriodoAction(mocker):
ResponderQuantidadeInfectadosPorPeriodoActionTest().test_bot(mocker)
ResponderQuantidadeInfectadosPorPeriodoActionTest().test_name(mocker)
ResponderQuantidadeInfectadosPorPeriodoActionTest().test_name(mocker)
18 changes: 10 additions & 8 deletions actions/tests/test_ResponderQuantidadeMortosPorPeriodoAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
from rasa_sdk.events import AllSlotsReset
from actions.ResponderQuantidadeMortosPorPeriodoAction import ResponderQuantidadeMortosPorPeriodoAction


class FakeDomain:
def __init__(self):
pass


class FakeTracker:
def get_slot(self, slot):
def get_slot(self, slot):
pass



class ResponderQuantidadeMortosPorPeriodoActionTest:

def setup(self, mocker):
Expand All @@ -23,18 +23,20 @@ def setup(self, mocker):
self.tracker = FakeTracker()
self.domain = FakeDomain()

def test_name(self,mocker):
def test_name(self, mocker):
self.setup(mocker)
assert self.service.name() == 'action_responder_quantidade_mortos_por_periodo'

def test_bot(self,mocker):
def test_bot(self, mocker):
self.setup(mocker)
mocker.patch.object(self.tracker,"get_slot",return_value="23/12/1970")
mocker.patch.object(self.tracker, "get_slot",
return_value="23/12/1970")

self.service.run(self.dispatcher,self.tracker,self.domain)
assert self.dispatcher.messages[0]['text'].startswith('Não consegui encontrar nenhum registro para a data 23/12/1970-23/12/1970-23/12/1970 🥺. Lembre-se de informar valores válidos e somente o número do dia, do mês e do ano 😉')
self.service.run(self.dispatcher, self.tracker, self.domain)
assert self.dispatcher.messages[0]['text'].startswith(
'Não consegui encontrar nenhum registro para a data 23/12/1970-23/12/1970-23/12/1970 🥺. Lembre-se de informar valores válidos e somente o número do dia, do mês e do ano 😉')


def test_ResponderQuantidadeMortosPorPeriodoAction(mocker):
ResponderQuantidadeMortosPorPeriodoActionTest().test_bot(mocker)
ResponderQuantidadeMortosPorPeriodoActionTest().test_name(mocker)
ResponderQuantidadeMortosPorPeriodoActionTest().test_name(mocker)
19 changes: 9 additions & 10 deletions actions/tests/test_ResponderQuantidadeVacinadosPorPeriodoAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@
from actions.ResponderQuantidadeVacinadosPorPeriodoAction import ResponderQuantidadeVacinadosPorPeriodoAction



class FakeDomain:
def __init__(self):
pass


class FakeTracker:
def get_slot(self, slot):
def get_slot(self, slot):
pass




class ResponderQuantidadeVacinadosPorPeriodoActionTest:

def setup(self, mocker):
Expand All @@ -26,18 +23,20 @@ def setup(self, mocker):
self.tracker = FakeTracker()
self.domain = FakeDomain()

def test_name(self,mocker):
def test_name(self, mocker):
self.setup(mocker)
assert self.service.name() == 'action_responder_quantidade_vacinados_por_periodo'

def test_bot(self,mocker):
def test_bot(self, mocker):
self.setup(mocker)
mocker.patch.object(self.tracker,"get_slot",return_value="23/12/1970")
mocker.patch.object(self.tracker, "get_slot",
return_value="23/12/1970")

self.service.run(self.dispatcher,self.tracker,self.domain)
assert self.dispatcher.messages[0]['text'].startswith('Não consegui encontrar nenhum registro para a data 23/12/1970-23/12/1970-23/12/1970 🥺. Lembre-se de informar valores válidos e somente o número do dia, do mês e do ano 😉')
self.service.run(self.dispatcher, self.tracker, self.domain)
assert self.dispatcher.messages[0]['text'].startswith(
'Não consegui encontrar nenhum registro para a data 23/12/1970-23/12/1970-23/12/1970 🥺. Lembre-se de informar valores válidos e somente o número do dia, do mês e do ano 😉')


def test_ResponderQuantidadeVacinadosPorPeriodoAction(mocker):
ResponderQuantidadeVacinadosPorPeriodoActionTest().test_bot(mocker)
ResponderQuantidadeVacinadosPorPeriodoActionTest().test_name(mocker)
ResponderQuantidadeVacinadosPorPeriodoActionTest().test_name(mocker)
22 changes: 9 additions & 13 deletions actions/tests/test_ResponderSobreCovidAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,16 @@
from actions.ResponderSobreCovidAction import ResponderSobreCovidAction






class FakeDomain:
def __init__(self):
pass


class FakeTracker:
def get_slot(self, slot):
def get_slot(self, slot):
pass




class ResponderSobreCovidActionTest:

def setup(self, mocker):
Expand All @@ -29,18 +23,20 @@ def setup(self, mocker):
self.tracker = FakeTracker()
self.domain = FakeDomain()

def test_name(self,mocker):
def test_name(self, mocker):
self.setup(mocker)
assert self.service.name() == 'action_dados_covid_baseados_em_localizacao'

def test_bot(self,mocker):
def test_bot(self, mocker):
self.setup(mocker)
mocker.patch.object(self.tracker,"get_slot",return_value="nao-existe")
mocker.patch.object(self.tracker, "get_slot",
return_value="nao-existe")

self.service.run(self.dispatcher,self.tracker,self.domain)
assert self.dispatcher.messages[0]['text'].startswith('Não consegui encontrar o estado NAO-EXISTE 🥺. Lembre-se de informar somente a sigla, exemplo: DF 😉')
self.service.run(self.dispatcher, self.tracker, self.domain)
assert self.dispatcher.messages[0]['text'].startswith(
'Não consegui encontrar o estado NAO-EXISTE 🥺. Lembre-se de informar somente a sigla, exemplo: DF 😉')


def test_ResponderVacinadosEmUmEstadoAction(mocker):
ResponderSobreCovidActionTest().test_bot(mocker)
ResponderSobreCovidActionTest().test_name(mocker)
ResponderSobreCovidActionTest().test_name(mocker)
19 changes: 10 additions & 9 deletions actions/tests/test_ResponderVacinadosEmUmEstadoAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ def __init__(self):


class FakeTracker:
def get_slot(self, slot):
def get_slot(self, slot):
pass


class ResponderVacinadosEmUmEstadoActionTest:

def setup(self, mocker):
Expand All @@ -22,20 +23,20 @@ def setup(self, mocker):
self.tracker = FakeTracker()
self.domain = FakeDomain()


def test_name(self, mocker):
self.setup(mocker)
assert self.service.name() == "action_responder_vacinados_em_um_estado"


def test_bot(self,mocker):
def test_bot(self, mocker):
self.setup(mocker)
mocker.patch.object(self.tracker,"get_slot",return_value="nao-existe")
mocker.patch.object(self.tracker, "get_slot",
return_value="nao-existe")

self.service.run(self.dispatcher, self.tracker, self.domain)
assert self.dispatcher.messages[0]['text'].startswith(
'Então... eu não achei o estado NAO-EXISTE')

self.service.run(self.dispatcher,self.tracker,self.domain)
assert self.dispatcher.messages[0]['text'].startswith('Então... eu não achei o estado NAO-EXISTE')


def test_ResponderVacinadosEmUmEstadoAction(mocker):
ResponderVacinadosEmUmEstadoActionTest().test_bot(mocker)
ResponderVacinadosEmUmEstadoActionTest().test_name(mocker)
ResponderVacinadosEmUmEstadoActionTest().test_name(mocker)
4 changes: 1 addition & 3 deletions actions/tests/test_dependencias.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ def test_tensorflow_instalado():
texto = "tensorflow-text" in pacote_instalados

if sys.platform == "win32":
assert not texto


assert not texto
9 changes: 8 additions & 1 deletion bot/data/nlu.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "2.0"
version: "2.0"

nlu:
- intent: start
Expand Down Expand Up @@ -650,3 +650,10 @@ nlu:
- Registrar a data da segunda dose da vacina
- Cadastrar próxima dose da vacina
- intent: stop
examples: |
- Adeus para sempre
- Adeus
- Até nunca mais bot
- Foi boa, adeus
Loading

0 comments on commit 15ebf8a

Please sign in to comment.