Esempio n. 1
0
def testRentController():
    """
    Test RentController
    """
    client = ClientsRepository()
    client.add(Client(1, "a", 11111))
    client.add(Client(2, "aa", 12121))

    movie = MoviesRepository()
    movie.add(Movie(3, "b", "bb", "bbb"))
    movie.add(Movie(4, "c", "cc", "ccc"))

    rent = RentRepository()
    unre = UnreController()
    controller = RentController(client, movie, rent, unre)

    controller.rentMovie(Rent(1, 3))
    controller.rentMovie(Rent(2, 3))

    assert controller.findByMovie(4) == []
    assert controller.findByMovie(3) == [1, 2]
    controller.rentMovie(Rent(1, 4))

    assert controller.GetListClients() == [(1, 2), (2, 1)]
    assert controller.GetListMovies() == [(3, 2), (4, 1)]
Esempio n. 2
0
def testClientController():
    """
    Test ClientController
    """
    repo = ClientsRepository()
    repo.add(Client(1, "a", 11111))
    client = Client(2, "aa", 12121)
    repo.add(client)
    controller = ClientController(repo, RentRepository(), UnreController())
    controller.removeClient(1)
    assert controller.getAll() == [client]
    controller.removeClient(2)
    assert controller.getAll() == []

    try:
        controller.searchClient(23)
        assert False
    except ExceptionMess:
        pass
Esempio n. 3
0
def testClientsRepository():
    """
    Test ClientsRepository
    """
    rep = ClientsRepository()
    assert len(rep) == 0
    assert rep.getAll() == []

    client = Client(1, "a", 123)
    rep.add(client)
    assert len(rep) == 1
    assert rep.getAll() == [client]
    assert rep.getClient(1) == client

    try:
        rep.add(client)
        assert False
    except ExceptionMess:
        pass

    try:
        rep.remove(12)
        assert False
    except ExceptionMess:
        pass

    client2 = Client(2, "b", 456)

    rep.add(client2)
    assert len(rep) == 2
    assert rep.getAll() == [client, client2]
    assert rep.getClient(1) == client
    assert rep.getClient(2) == client2

    try:
        rep.getClient(1123)
        assert False
    except ExceptionMess:
        pass

    assert rep.isClient(1)
    assert not rep.isClient(1231)
    rep.remove(1)
    assert len(rep) == 1
    assert rep.getAll() == [client2]
    assert rep.getClient(2) == client2

    rep.updateClient(Client(2, "bb", 444))
    client3 = Client(2, "bb", 444)
    assert rep.getClient(2) == client3