Beispiel #1
0
 def test_store_availability_changes_on_rental(self):
     movie = Mock(spec_set=Movie)
     store = StoreBuilder(movies=[movie, movie]).build()
     rental = RentalBuilder(movie=movie).build()
     rental.start(store)
     RentalBuilder().build().start(store)
     self.assertEqual(1, store.get_availability(movie))
Beispiel #2
0
 def test_rental_does_not_start_if_not_available(self):
     movie = MovieBuilder().build()
     rental = RentalBuilder(movie=movie).build()
     store = StoreBuilder().build()
     rental.start(store)
     self.assertFalse(rental.is_started())
     self.assertEqual(store.get_availability(movie), 0)
Beispiel #3
0
 def test_rental_is_started_if_in_store(self):
     movie = MovieBuilder().build()
     rental = RentalBuilder(movie=movie).build()
     store = StoreBuilder(movie=movie).build()
     rental.start(store)
     self.assertTrue(rental.is_started())
     self.assertEqual(store.get_availability(movie), 0)
 def test_rental_does_not_start_if_not_available(self):
     movie_mock = Mock(spec_set=Movie)
     rental = RentalBuilder(movie=movie_mock).build()
     store_mock = Mock(spec_set=Store,
                       **{"get_availability.return_value": 0})
     rental.start(store_mock)
     self.assertFalse(rental.is_started())
     store_mock.check_out.assert_not_called()
 def test_rental_started_if_in_store(self):
     movie_mock = Mock(spec_set=Movie)
     rental = RentalBuilder(movie=movie_mock).build()
     store_mock = Mock(spec_set=Store,
                       **{"get_availability.return_value": 1})
     rental.start(store_mock)
     self.assertTrue(rental.is_started())
     store_mock.check_out.assert_called_with(movie_mock)
Beispiel #6
0
 def test_rental_is_started_if_in_store(self):
     movie = MovieBuilder().build()
     rental = RentalBuilder(movie=movie).build()
     store = Mock(spec_set=Store)
     store.configure_mock(**{'get_availability.return_value': 1})
     rental.start(store)
     self.assertTrue(rental.is_started())
     store.check_out.assert_called_with(movie)
Beispiel #7
0
 def test_rental_does_not_start_if_not_available(self):
     movie = MovieBuilder().build()
     rental = RentalBuilder(movie=movie).build()
     store = Mock(spec_set=Store)
     store.configure_mock(**{'get_availability.return_value': 0})
     rental.start(store)
     self.assertFalse(rental.is_started())
     store.check_out.assert_not_called()
     pass
Beispiel #8
0
 def test_new_release_and_regular_statement(self):
     self.assertEqual(
         "Rental record for Steve\n" + "\tGodfather 4 9.0\n" +
         "\tScarface 3.5\n" + "Amount owed is 12.5\n" +
         "You earned 3 frequent renter points",
         CustomerBuilder(name="Steve",
                         builders=[
                             RentalBuilder(builder=MovieBuilder(
                                 movietype=TYPE_NEW_RELEASE)),
                             RentalBuilder(builder=MovieBuilder(
                                 name="Scarface", movietype=TYPE_REGULAR))
                         ]).build().statement())
Beispiel #9
0
 def test_new_release_and_regular_html_statement(self):
     self.assertEqual(
         "<h1>Rental record for <em>Steve</em></h1>\n" +
         "<p>Godfather 4 9.0</p>\n" + "<p>Scarface 3.5</p>\n" +
         "<p>Amount owed is <em>12.5</em></p>\n" +
         "<p>You earned <em>3 frequent renter points</em></p>",
         CustomerBuilder(name="Steve",
                         builders=[
                             RentalBuilder(builder=MovieBuilder(
                                 movietype=TYPE_NEW_RELEASE)),
                             RentalBuilder(builder=MovieBuilder(
                                 name="Scarface", movietype=TYPE_REGULAR))
                         ]).build().html_statement())
Beispiel #10
0
 def test_all_rental_types_statement(self):
     self.assertEqual(
         "Rental record for Pat\n" + "\tGodfather 4 9.0\n" +
         "\tScarface 3.5\n" + "\tLion King 1.5\n" +
         "Amount owed is 14.0\n" + "You earned 4 frequent renter points",
         CustomerBuilder(name="Pat",
                         builders=[
                             RentalBuilder(builder=MovieBuilder(
                                 movietype=TYPE_NEW_RELEASE)),
                             RentalBuilder(builder=MovieBuilder(
                                 name="Scarface", movietype=TYPE_REGULAR)),
                             RentalBuilder(builder=MovieBuilder(
                                 name="Lion King", movietype=TYPE_CHILDREN))
                         ]).build().statement())
Beispiel #11
0
 def test_all_rental_types_html_statement(self):
     self.assertEqual(
         "<h1>Rental record for <em>Pat</em></h1>\n" +
         "<p>Godfather 4 9.0</p>\n" + "<p>Scarface 3.5</p>\n" +
         "<p>Lion King 1.5</p>\n" +
         "<p>Amount owed is <em>14.0</em></p>\n" +
         "<p>You earned <em>4 frequent renter points</em></p>",
         CustomerBuilder(name="Pat",
                         builders=[
                             RentalBuilder(builder=MovieBuilder(
                                 movietype=TYPE_NEW_RELEASE)),
                             RentalBuilder(builder=MovieBuilder(
                                 name="Scarface", movietype=TYPE_REGULAR)),
                             RentalBuilder(builder=MovieBuilder(
                                 name="Lion King", movietype=TYPE_CHILDREN))
                         ]).build().html_statement())
Beispiel #12
0
 def test_one_new_release_statement(self):
     self.assertEqual(
         "Rental record for John\n" + "\tGodfather 4 9.0\n" +
         "Amount owed is 9.0\n" + "You earned 2 frequent renter points",
         CustomerBuilder(
             name="John",
             builder=RentalBuilder(builder=MovieBuilder(
                 movietype=TYPE_NEW_RELEASE))).build().statement())
Beispiel #13
0
 def test_one_new_release_html_statement(self):
     self.assertEqual(
         "<h1>Rental record for <em>John</em></h1>\n" +
         "<p>Godfather 4 9.0</p>\n" +
         "<p>Amount owed is <em>9.0</em></p>\n" +
         "<p>You earned <em>2 frequent renter points</em></p>",
         CustomerBuilder(
             name="John",
             builder=RentalBuilder(builder=MovieBuilder(
                 movietype=TYPE_NEW_RELEASE))).build().html_statement())
Beispiel #14
0
 def test_rental_does_not_start_if_not_available(self):
     rental = RentalBuilder().build()
     store_mock = Mock(spec_set=Store,
                       **{"get_availability.return_value": 0})
     rental.start(store_mock)
     self.assertFalse(rental.is_started())
Beispiel #15
0
 def test_rental_started_if_in_store(self):
     rental = RentalBuilder().build()
     store_mock = Mock(spec_set=Store,
                       **{"get_availability.return_value": 1})
     rental.start(store_mock)
     self.assertTrue(rental.is_started())
Beispiel #16
0
 def test_invalid_title(self):
     with self.assertRaises(TypeError):
         CustomerBuilder(name="John",
                         builder=RentalBuilder(builder=MovieBuilder(
                             movietype=TYPE_UNKNOWN))).build()