I am new to python and pytest the following code and a simple chatbot, but what I would like to know and if you give it to test everything up to the interface or the only function, and how should I create the test code for this function
def verificaChat():
if(txtChat.get() == ""):
tkinter.messagebox.showinfo("Informação", "Favor Escreva uma Mensagem!")
else:
msg = txtChat.get()
area.insert(tkinter.INSERT, 'Usuário: ' + msg + "\n")
chat = str(chatbot.get_response(msg))
area.insert(tkinter.INSERT, 'Bot PiuPiu: ' + chat + "\n")
txtChat.delete(0,'end')
# -*- coding: utf-8 -*-
import tkinter, tkinter.messagebox
from tkinter import scrolledtext
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
# CHATBOT
chatbot = ChatBot(
'PiuPiu',
trainer='chatterbot.trainers.ChatterBotCorpusTrainer'
)
chatbot.train(
'chatterbot.corpus.Portuguese'
)
# JANELA
janela = tkinter.Tk()
janela.title("ChatBot")
janela.iconbitmap('icone.ico')
janela.resizable(0,0)
#janela.overrideredirect(True)
janela.geometry("400x600+600+100")
# FRAMES
frameTop = tkinter.Frame(janela, height=50, bg='#777')
frameTop.pack(side='top', fill='x')
frameCenter = tkinter.Frame(janela)
frameCenter.pack()
frameBottom = tkinter.Frame(janela, height=60, bg='#777')
frameBottom.pack(side='bottom', fill='x')
# FUNÇÕES
def verificaChat():
if(txtChat.get() == ""):
tkinter.messagebox.showinfo("Informação", "Favor Escreva uma Mensagem!")
else:
msg = txtChat.get()
area.insert(tkinter.INSERT, 'Usuário: ' + msg + "\n")
chat = str(chatbot.get_response(msg))
area.insert(tkinter.INSERT, 'Bot PiuPiu: ' + chat + "\n")
txtChat.delete(0,'end')
# LABELS
lblTitulo = tkinter.Label(frameTop, text="CHATBOT", bg='#777', fg='#fff')
lblTitulo["font"] = ("Arial", "15", "bold")
lblTitulo.place(x=150,y=12)
lblSeparador1 = tkinter.Label(janela, text="----------------------------------------------------------------------------")
lblSeparador1.place(x=5, y=50)
lblSeparador2 = tkinter.Label(janela, text="----------------------------------------------------------------------------")
lblSeparador2.place(x=5, y=515)
# INPUTS
txtChat = tkinter.Entry(janela)
txtChat.focus()
txtChat["font"] = ("Arial", "11")
txtChat.place(width=260, height=25, x=15,y=550)
# AREA DO CHAT
area = tkinter.scrolledtext.ScrolledText(janela, width=40, height=24, padx=5, pady=5, state='normal')
area.see('end')
area["font"] = ("Arial", "12")
area.place(x=10, y=70)
# BUTTONS
btnEnviar = tkinter.Button(janela, width=10, text="Enviar", command=verificaChat)
btnEnviar["font"] = ("Arial", "10")
btnEnviar.bind('<Return>', verificaChat)
btnEnviar.place(x=290,y=550)
janela.mainloop()