def pessoaEmprestimos(): pessoa = Pessoa("Joaozinho") emprestimo = Emprestimo("Fone de Ouvido", "23/12/2020") pessoa.emprestimos.append(emprestimo) emprestimo = Emprestimo("Mouse", "21/12/2020") pessoa.emprestimos.append(emprestimo) for emprestimo in pessoa.emprestimos: print( f"Emprestimo do equipamento: {emprestimo.nomeEquipamento} com data de devolução para {emprestimo.dataDevolucao} " )
class Principal(Emprestimo, Copia): emp = Emprestimo() cop = Copia() soc = Socio() film = Filme()
def setUp(self): self.emprestimo = Emprestimo()
class TestEmprestimo(unittest.TestCase): def setUp(self): self.emprestimo = Emprestimo() def testEmprestimoExiste(self): assert self.emprestimo != None, "Emprestimo nao existe" def testInsereCodigo(self): self.emprestimo.setCodE(001) assert self.emprestimo.codE != None, "Codigo esta vazio" def testInsereDataEmprestimo(self): self.emprestimo.setdataE("23/02/2011") assert self.emprestimo.dataE != None, "Data de Emprestimo esta vazio" def testInsereDataDevolucao(self): self.emprestimo.setdataD("26/02/2011") assert self.emprestimo.dataD != None, "Data de Devolucao esta vazio" def testImprimeCodigo(self): self.emprestimo.setCodE(001) cod = self.emprestimo.getCodE() assert cod != None, "Codigo esta vazio" def testImprimeDataEmprestimo(self): self.emprestimo.setdataE("23/02/2011") dataE = self.emprestimo.getdataE() assert dataE != None, "Data de Emprestimo esta vazio" def testImprimeDataDevolucao(self): self.emprestimo.setdataD("26/02/2011") dataD = self.emprestimo.getdataD() assert dataD != None, "Data de Devolucao esta vazio" def testDevolucao(self): lFinal = self.emprestimo.devolver() pFinal = lFinal[0] pFinal = int(pFinal) self.assertEqual(pFinal, self.emprestimo.preco, msg="Erro: Preco Final com Valores Diferentes") def testCopiaRuim(self): lFinal = self.emprestimo.devolver() print "teste lista" print lFinal listaEstadoR = lFinal[2] if listaEstadoR == "ruim": self.assertNotEqual(self.emprestimo.listaEstadoR, None, msg="Erro: Socio Inadimplente") def testSocioInadimplente(self): pagar = self.emprestimo.socioStatus(001) if pagar == "nao": self.assertNotEqual(self.emprestimo.ListSocioI, None, msg="Erro: Socio Inadimplente") def testListaEmprestimo(self): listE = self.emprestimo.listaEmprestimo() numS = listE[0] dataE = listE[1] precoF = listE[2] dataD = listE[3] self.assertNotEqual(numS, None, msg="Erro: Valor esta Vazio") self.assertNotEqual(dataE, None, msg="Erro: Valor esta Vazio") self.assertNotEqual(precoF, None, msg="Erro: Valor esta Vazio") self.assertNotEqual(dataD, None, msg="Erro: Valor esta Vazio")
class TestEmprestimo(unittest.TestCase): def setUp(self): self.emprestimo = Emprestimo() def testEmprestimoExiste(self): assert self.emprestimo != None, "Emprestimo nao existe" def testInsereCodigo(self): self.emprestimo.setCodE(001) assert self.emprestimo.codE != None,"Codigo esta vazio" def testInsereDataEmprestimo(self): self.emprestimo.setdataE("23/02/2011") assert self.emprestimo.dataE != None,"Data de Emprestimo esta vazio" def testInsereDataDevolucao(self): self.emprestimo.setdataD("26/02/2011") assert self.emprestimo.dataD != None,"Data de Devolucao esta vazio" def testImprimeCodigo(self): self.emprestimo.setCodE(001) cod=self.emprestimo.getCodE() assert cod != None,"Codigo esta vazio" def testImprimeDataEmprestimo(self): self.emprestimo.setdataE("23/02/2011") dataE=self.emprestimo.getdataE() assert dataE != None,"Data de Emprestimo esta vazio" def testImprimeDataDevolucao(self): self.emprestimo.setdataD("26/02/2011") dataD=self.emprestimo.getdataD() assert dataD != None,"Data de Devolucao esta vazio" def testDevolucao(self): lFinal=self.emprestimo.devolver() pFinal=lFinal[0] pFinal=int(pFinal) self.assertEqual(pFinal,self.emprestimo.preco,msg="Erro: Preco Final com Valores Diferentes") def testCopiaRuim(self): lFinal=self.emprestimo.devolver() print "teste lista" print lFinal listaEstadoR=lFinal[2] if listaEstadoR=="ruim": self.assertNotEqual(self.emprestimo.listaEstadoR,None,msg="Erro: Socio Inadimplente") def testSocioInadimplente(self): pagar=self.emprestimo.socioStatus(001) if pagar=="nao": self.assertNotEqual(self.emprestimo.ListSocioI,None,msg="Erro: Socio Inadimplente") def testListaEmprestimo(self): listE=self.emprestimo.listaEmprestimo() numS=listE[0] dataE=listE[1] precoF=listE[2] dataD=listE[3] self.assertNotEqual(numS,None,msg="Erro: Valor esta Vazio") self.assertNotEqual(dataE,None,msg="Erro: Valor esta Vazio") self.assertNotEqual(precoF,None,msg="Erro: Valor esta Vazio") self.assertNotEqual(dataD,None,msg="Erro: Valor esta Vazio")
from Equipamento import Equipamento from Pessoa import Pessoa from Emprestimo import Emprestimo equipamentos = [] #Lista os equipamentos e seus respectiva data de devolução pré-estabelecida equipamentos.append(Equipamento('Cortador de grama', 30)) equipamentos.append(Equipamento('Betoneira', 60)) equipamentos.append(Equipamento('Fritadeira', 20)) pessoa_maicon = Pessoa('Maicon') pessoa_douglas = Pessoa('Douglas') pessoa_geri = Pessoa('géri') emprestimos = [] #Aqui são realizado vários emprestimos (como exemplo) #Maicon pegou emprestado o cortador de grama emprestimos.append(Emprestimo(pessoa_maicon, equipamentos[0], 0)) #Géri pegou emprestado uma betoneira emprestimos.append(Emprestimo(pessoa_geri, equipamentos[1], 0)) #Douglas pegou emprestado uma fritadeira, mandando "um dia" para devolucao emprestimos.append(Emprestimo(pessoa_douglas, equipamentos[2], 1)) for emprestimo in emprestimos: emprestimo.to_string()
from BibliotecaNegocio import BibliotecaNegocio from Emprestimo import Emprestimo biblioteca = BibliotecaNegocio() biblioteca.addLivros() biblioteca.addUsuarios() emprestimo = Emprestimo(biblioteca) emprestimo.realizaEmprestimo()
from Pessoa import Pessoa from Emprestimo import Emprestimo pessoa = Pessoa("Isabella") emprestimo = Emprestimo("Monitor", "31/12/2021") pessoa.listaEmprestimos.append(emprestimo) emprestimo = Emprestimo("Cabo HDMI", "31/12/2021") pessoa.listaEmprestimos.append(emprestimo) for emprestimo in pessoa.listaEmprestimos: print( f"Equipamento: {emprestimo.nome_equipamento} Data de devolução: {emprestimo.data_devolucao} " )