def test_react_hoodies_subscriber(self): store = StorePublisher() hoodies_subscriber = HoodiesSubscriber("Name1") store.new_goods = "толстовка" self.assertEqual("SneakersSubscriber:" + f"{hoodies_subscriber.name} реагирует на новое поступление толстовки", hoodies_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_hoodies_subscriber(self): store = StorePublisher() hoodies_subscriber = HoodiesSubscriber("Name1") store.new_goods = "кроссовки" self.assertEqual(1, hoodies_subscriber.update(store))