def test_react_sneakers_subscriber(self): store = StorePublisher() sneakers_subscriber = SneakersSubscriber("Name1") store.new_goods = "кроссовки" self.assertEqual("SneakersSubscriber:" + f"{sneakers_subscriber.name} реагирует на новое поступление кроссовок", sneakers_subscriber.update(store))
def test_attach(self): sneakers_subscriber = SneakersSubscriber("Name1") hoodies_subscriber = HoodiesSubscriber("Name2") store = StorePublisher() store.attach(sneakers_subscriber) store.attach(hoodies_subscriber) self.assertEqual(type(sneakers_subscriber), type(store.subscribers[0])) self.assertEqual(type(hoodies_subscriber), type(store.subscribers[1]))
def test_noreact_sneakers_subscriber(self): store = StorePublisher() sneakers_subscriber = SneakersSubscriber("Name1") store.new_goods = "толстовка" self.assertEqual(1, sneakers_subscriber.update(store))