예제 #1
0
파일: Test.py 프로젝트: wswco/MovieRental
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)]
예제 #2
0
파일: Test.py 프로젝트: wswco/MovieRental
def testMovieController():
    """
    Test MovieController
    """
    repo = MoviesRepository()
    repo.add(Movie(1, "a", "aa", "aaa"))
    movie = Movie(2, "b", "bb", "bbb")
    repo.add(movie)
    controller = MovieController(repo, RentRepository(), UnreController())
    controller.removeMovie(1)
    assert controller.getAll() == [movie]
    controller.removeMovie(2)
    assert controller.getAll() == []

    try:
        controller.searchMovie(23)
        assert False
    except ExceptionMess:
        pass
예제 #3
0
파일: Test.py 프로젝트: wswco/MovieRental
def testMovieRepository():
    """
    Test MovieRepository class
    """

    rep = MoviesRepository()
    assert len(rep) == 0
    assert rep.getAll() == []

    movie = Movie(1, "a", "aa", "aaa")
    rep.add(movie)
    assert len(rep) == 1
    assert rep.getAll() == [movie]
    assert rep.getMovie(1) == movie

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

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

    movie2 = Movie(2, "b", "bb", "bbb")
    rep.add(movie2)
    assert len(rep) == 2
    assert rep.getAll() == [movie, movie2]
    assert rep.getMovie(2) == movie2

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

    rep.remove(1)
    assert len(rep) == 1
    assert rep.getAll() == [movie2]
    assert rep.getMovie(2) == movie2

    rep.updateMovie(Movie(2, "z", "zz", "zzz"))
    movie3 = Movie(2, "z", "zz", "zzz")
    assert len(rep) == 1
    assert rep.getAll() == [movie3]
    assert rep.getMovie(2) == movie3