Пример #1
0
    def incarca_din_fisier(self):

        with open(self.__numeFisier, 'r') as fisier:
            for linie in fisier:
                linie = linie.strip().split(' ')
                ParticipantiRepository.add_repository(
                    self, self.creeaza_participant(linie))
Пример #2
0
    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
Пример #3
0
    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
Пример #4
0
    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
Пример #5
0
 def test_updP(self):
     '''
     testeaza functia  updateParticipant
     '''
     listaP = ParticipantiRepository()
     validator = ParticipantValidator()
     x = ParticipantiService(listaP, validator)
     participant = x.addParticipant('23', 'da', 'dresa')
     participant2 = Participanti('2', 'd', 'sd')
     assert participant.get_person_id() == '23'
     participant = x.updateParticipant('23', '2', 'd', 'sd')
     assert participant.get_person_id() == '2'
Пример #6
0
    def test_delP(self):
        '''
        testeaza functia delP
        '''
        listaP = ParticipantiRepository()
        validator = ParticipantValidator
        x = ParticipantiService(listaP, validator)
        participant = x.addParticipant('23', 'da', 'dresa')
        assert participant.get_person_id() == '23'

        x.deleteParticipant('2')
        assert x.repository.get_size() == 1
        x.deleteParticipant('23')
        assert x.repository.get_size() == 0
Пример #7
0
 def test_addP(self):
     '''
     testeaza functia addP
     '''
     listaP = ParticipantiRepository()
     validator = ParticipantValidator
     x = ParticipantiService(listaP, validator)
     participant = x.addParticipant('23', 'da', 'dresa')
     assert participant.get_person_id() == '23'
     try:
         x.addParticipant('23', 'da', 'da')
         assert False
     except ValueError:
         pass
Пример #8
0
 def __init__(self, fisier):
     ParticipantiRepository.__init__(self)
     self.__numeFisier = fisier
     self.incarca_din_fisier()
Пример #9
0
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)
serviceParti = ParticipantiService(listaParticipanti3, validatorParticipanti)
serviceInscrisi = InscriereService(listaEvent3, listaParticipanti3,
                                   listaInscriere3, validatorInscriere)
console = Consola(serviceParti, serviceEvent, serviceInscrisi)