Exemple #1
0
 def test_movie_world_rent_dvd_already_rented_by_user(self):
     movie_world = MovieWorld("Test")
     d = DVD("A", 1, 1254, "February", 10)
     c = Customer("Pesho", 20, 4)
     movie_world.add_customer(c)
     movie_world.add_dvd(d)
     movie_world.rent_dvd(4, 1)
     result = movie_world.rent_dvd(4, 1)
     self.assertEqual(result, "Pesho has already rented A")
Exemple #2
0
 def test_movie_world_return_dvd_success(self):
     movie_world = MovieWorld("Test")
     d = DVD("A", 1, 1254, "February", 10)
     c = Customer("Pesho", 20, 4)
     movie_world.add_customer(c)
     movie_world.add_dvd(d)
     movie_world.rent_dvd(4, 1)
     result = movie_world.return_dvd(4, 1)
     self.assertEqual(result, "Pesho has successfully returned A")
     self.assertEqual(c.rented_dvds, [])
     self.assertEqual(d.is_rented, False)
Exemple #3
0
 def test_movie_world_repr(self):
     movie_world = MovieWorld("Test")
     d = DVD("A", 1, 1254, "February", 10)
     c = Customer("Pesho", 20, 4)
     movie_world.add_customer(c)
     movie_world.add_dvd(d)
     movie_world.rent_dvd(4, 1)
     actual = repr(movie_world).strip('\n')
     expected = "4: Pesho of age 20 has 1 rented DVD's (A)\n1: A (February 1254) has age restriction 10. Status: rented"
     self.assertEqual(actual, expected)
Exemple #4
0
 def test_movie_world_return_dvd_unsuccessful(self):
     movie_world = MovieWorld("Test")
     d = DVD("A", 1, 1254, "February", 10)
     c = Customer("Pesho", 20, 4)
     movie_world.add_customer(c)
     movie_world.add_dvd(d)
     result = movie_world.return_dvd(4, 1)
     self.assertEqual(result, "Pesho does not have that DVD")
Exemple #5
0
 def test_movie_world_rent_dvd_no_permision(self):
     movie_world = MovieWorld("Test")
     d = DVD("A", 1, 1254, "February", 18)
     c = Customer("Pesho", 16, 4)
     movie_world.add_customer(c)
     movie_world.add_dvd(d)
     result = movie_world.rent_dvd(4, 1)
     self.assertEqual(result,
                      "Pesho should be at least 18 to rent this movie")
    def __init__(self, name: str, age: int, id: int):
        self.name = name
        self.age = age
        self.id = id
        self.rented_dvds = []

    def __repr__(self):
        return f"{self.id}: {self.name} of age {self.age} has {len(self.rented_dvds)} " \
               f"rented DVD's ({', '.join([dvd.name for dvd in self.rented_dvds])})"


c1 = Customer("John", 16, 1)
c2 = Customer("Anna", 55, 2)

d1 = DVD("Black Widow", 1, 2020, "April", 18)
d2 = DVD.from_date(2, "The Croods 2", "23.12.2020", 3)

movie_world = MovieWorld("The Best Movie Shop")

movie_world.add_customer(c1)
movie_world.add_customer(c2)

movie_world.add_dvd(d1)
movie_world.add_dvd(d2)

print(movie_world.rent_dvd(1, 1))
print(movie_world.rent_dvd(2, 1))
print(movie_world.rent_dvd(1, 2))

print(movie_world)
Exemple #7
0
 def test_movie_world_rent_dvd_already_rented(self):
     movie_world = MovieWorld("Test")
     d = DVD("A", 1, 1254, "February", 10)
     c = Customer("Pesho", 20, 4)
     c2 = Customer("Gosho", 26, 2)
     movie_world.add_customer(c)
     movie_world.add_customer(c2)
     movie_world.add_dvd(d)
     movie_world.rent_dvd(4, 1)
     result = movie_world.rent_dvd(2, 1)
     self.assertEqual(result, "DVD is already rented")
Exemple #8
0
 def test_movie_world_add_dvd_overflow(self):
     movie_world = MovieWorld("Test")
     for _ in range(16):
         movie_world.add_dvd(DVD("A", 1, 1254, "February", 10))
     self.assertEqual(len(movie_world.dvds), 15)
Exemple #9
0
 def test_movie_world_add_dvd_success(self):
     movie_world = MovieWorld("Test")
     d = DVD("A", 1, 1254, "February", 10)
     movie_world.add_dvd(d)
     self.assertEqual(movie_world.dvds, [d])
Exemple #10
0
 def test_movie_world_add_customer_overflow(self):
     movie_world = MovieWorld("Test")
     for _ in range(11):
         movie_world.add_customer(Customer("Pesho", 20, 4))
     self.assertEqual(len(movie_world.customers), 10)
Exemple #11
0
 def test_movie_world_add_customer_success(self):
     movie_world = MovieWorld("Test")
     c = Customer("Pesho", 20, 4)
     movie_world.add_customer(c)
     self.assertEqual(movie_world.customers, [c])
Exemple #12
0
 def tests_movie_world_customer_capacity(self):
     self.assertEqual(MovieWorld.customer_capacity(), 10)
Exemple #13
0
 def tests_movie_world_dvd_capacity(self):
     self.assertEqual(MovieWorld.dvd_capacity(), 15)
Exemple #14
0
 def test_movie_init(self):
     movie = MovieWorld("Test")
     self.assertEqual(movie.name, "Test")
     self.assertEqual(movie.customers, [])
     self.assertEqual(movie.dvds, [])
Exemple #15
0
from project.customer import Customer
from project.dvd import DVD
from project.movie_world import MovieWorld

customer = Customer('Atanas', 18, 123)
dvd = DVD('CONG: In the Wild', 555, 1998, 'August', 18)
dvd2 = DVD.from_date(777, 'CHE', '12.09.1988', 18)
# dvd.is_rented = True

movie_world = MovieWorld("Gaco")
movie_world.add_customer(customer)
movie_world.add_dvd(dvd)
movie_world.add_dvd(dvd2)

print(movie_world.rent_dvd(123, 555))
print(movie_world.rent_dvd(123, 555))
print(movie_world.return_dvd(123, 555))
print(movie_world.return_dvd(123, 555))
print(movie_world.rent_dvd(123, 777))

print(movie_world)