예제 #1
0
def main():

    #runTests()
    typee = console.getTheTypeOfRepository()
    if typee == 'in memory':
        moviesRepository = repository()
        customersRepository = repository()
        rentsRepository = repository()

    elif typee == 'in file':
        scriptpath = os.path.dirname(__file__)
        fileNameM = os.path.join(scriptpath, "movies.txt")
        fileNameC = os.path.join(scriptpath, "customers.txt")
        fileNameR = os.path.join(scriptpath, "rents.txt")
        moviesRepository = fileRepository(fileNameM, movie.readFromStr,
                                          movie.writeToStr)
        customersRepository = fileRepository(fileNameC, customer.readFromStr,
                                             customer.writeToStr)
        rentsRepository = fileRepository(fileNameR, rent.readFromStr,
                                         rent.writeToStr)

    c = console(
        moviesService(moviesRepository, validatorMovie()),
        customersService(customersRepository, validatorCustomer()),
        rentsService(moviesRepository, customersRepository, rentsRepository,
                     validatorRent()),
        serviceReports(rentsRepository, customersRepository, moviesRepository))

    c.interface()
예제 #2
0
def testServiceC():
    customersRepository = repository()
    ctrl = customersService(customersRepository, validatorCustomer())
    c = ctrl.createCustomer(1, "Berinde", 1672030123345)
    assert c.getId() == 1
    assert c.getName() == "Berinde"
    assert c.getCnp() == 1672030123345

    ctrl.update(1, "Modoi", 1672030128888)
    new = customer(1, "Modoi", 1672030128888)
    assert ctrl.get(1) == new

    ctrl.remove(1)
    assert ctrl.getNrCustomers() == 0

    c = ctrl.createCustomer(1, "Istvanc", 1672030129999)
    ctrl.find("id", 1)
    assert ctrl.get(1) == c

    assert ctrl.getNrCustomers() == 1
예제 #3
0
 def testServiceCustomer(self):
     return testRepoCustomer.testCustomer(self)
     self.__repoCustomer=repository()
     self.__validator=validatorCustomer()
     self._service=customersService(self.__repoCustomer,self.__validator)
     self._service.createCustomer(2,"John",2991010343434)
     self.assertEqual(self._service.getNrCustomers(),1)
 
     ''' black box testing'''
     try:
         self._service.createCustomer(2,"Laur",2991010343436)
         assert False
     except ValueError:
         assert True
         
     try:
         self._service.createCustomer(4,"Laur",2010343436)
         assert False
     except ValueError:
         assert True
     
     try:
         self._service.update(10,"Laur",2010343436222)
         assert False
     except ValueError:
         assert True
         
     try:
         self._service.remove(10,"Lindsey",2010343436333)
         assert False
     except ValueError:
         assert True
 
     try:
         self._service.removeAll()
         assert True
     except ValueError:
         assert False
예제 #4
0
 def __init__(self, srvRent):
     self.__serviceRent = srvRent
     self.valid = validatorCommands()
     self.validM = validatorMovie()
     self.validC = validatorCustomer()
     self.validR = validatorRent()