def test_update_repo(self): ''' testeaza functia update_repo si find_repo ''' listaE = EventRepository() event = Evenimente('1', '34', '123', 'dada') event2 = Evenimente('1', '35', '124', 'da1da') listaE.add_repository(event) assert listaE.get_size() == 1 try: listaE.update_repository('1', event2) assert listaE.get_size() == 1 event = listaE.find_repository('1') assert event.get_data() == '35' assert event.get_id() == '1' assert event.get_timp() == '124' assert event.get_descriere() == 'da1da' except ValueError: pass listaP = ParticipantiRepository() participant = Participanti('1', 'dada', '123') participant2 = Participanti('2', 'da1da', '13') listaP.add_repository(participant) assert listaP.get_size() == 1 try: listaP.update_repository('1', participant2) assert listaP.get_size() == 1 participant = listaP.find_repository('2') assert participant.get_nume() == 'da1da' assert participant.get_person_id() == '2' assert participant.get_adresa() == '13' except ValueError: pass
def test_add_repo(self): ''' testeaza funtia add_repo ''' listaP = ParticipantiRepository() participant = Participanti('1', 'das', 'dsad') listaP.add_repository(participant) assert listaP.get_size() == 1 try: listaP.add_repository(participant) assert listaP.get_size() == 1 assert False except ValueError: pass listaE = EventRepository() event = Evenimente('1', '34', '123', 'dada') listaE.add_repository(event) assert listaE.get_size() == 1 try: listaE.add_repository(event) assert listaE.get_size() == 1 assert False except ValueError: pass
def test_del_repo(self): ''' testeaza functia del_repo ''' listaE = EventRepository() event = Evenimente('1', '34', '123', 'dada') listaE.add_repository(event) assert listaE.get_size() == 1 try: listaE.delete_repository('1') assert listaE.get_size() == 0 assert True except ValueError: pass listaP = ParticipantiRepository() participant = Participanti('1', 'dada', '34') listaP.add_repository(participant) assert listaP.get_size() == 1 try: listaP.delete_repository('1') assert listaP.get_size() == 0 assert True except ValueError: pass
def test_updE(self): ''' testeaza functia updE ''' listaE = EventRepository() validator = EventValidator x = EventService(listaE, validator) event = x.addEvent('23', 'da', 'dresa', '34') event2 = Evenimente('2', 'd', 'sd', '3r') assert event.get_id() == '23' event = x.updateEvent('23', '2', 'd', 'sd', '3r') assert event.get_id() == '2'
def test_delE(self): ''' testeaza functia delP ''' listaE = EventRepository() validator = EventValidator x = EventService(listaE, validator) event = x.addEvent('23', 'da', 'dresa', '34') assert event.get_id() == '23' x.deleteEvent('2') assert x.repository.get_size() == 1 x.deleteEvent('23') assert x.repository.get_size() == 0
def test_addEvent(self): ''' testeaza functia addP ''' listaE = EventRepository() validator = EventValidator x = EventService(listaE, validator) event = x.addEvent('23', '23', '23', '23') assert event.get_id() == '23' try: x.addEvent('23', 'da', 'da', '32') assert False except ValueError: pass
def update_repository(self, id, element): EventRepository.update_repository(self, id, element) self.scrie_fisier()
def delete_repository(self, id): EventRepository.delete_repository(self, id) self.scrie_fisier()
def add_repository(self, element): EventRepository.add_repository(self, element) self.adaugaLaFisier(element)
def incarca_din_fisier(self): with open(self.__numeFisier, 'r') as fisier: for linie in fisier: linie = linie.strip().split(' ') EventRepository.add_repository(self, self.creeaza_event(linie))
def __init__(self, fisier): EventRepository.__init__(self) self.__numeFisier = fisier self.incarca_din_fisier()
Created on Nov 12, 2018 @author: Andrei """ from ui.console import Consola from repository.participantiRepository import ParticipantiRepository from repository.eventRepository import EventRepository from repository.inscriereRepository import InscriereRepository from domain.validator import EventValidator, ParticipantValidator, ValidatorInscriere from Service.eventService import EventService from Service.partiService import ParticipantiService from Service.inscriereService import InscriereService from repository.fileToMemory import * from repository.FileRepository import * listaEvent = EventRepository() listaEvent2 = FileToMemoryEvent('data/evenimente.txt') listaEvent3 = FileEvent('data/evenimente.txt') listaParticipanti = ParticipantiRepository() listaParticipanti2 = FileToMemoryParticipanti('data/participanti.txt') listaParticipanti3 = FileParticipanti('data/participanti.txt') listaInscriere = InscriereRepository() listaInscriere2 = FileToMemoryInscriere('data/inscrieri.txt') listaInscriere3 = FileInscrieri('data/inscrieri.txt') validatorEvent = EventValidator() validatorParticipanti = ParticipantValidator() validatorInscriere = ValidatorInscriere() serviceEvent = EventService(listaEvent3, validatorEvent)