def test_returns_an_encouragement_from_a_set_of_providers(self): registry = ProviderRegistry() providers = (lambda habit: None, lambda habit: "a", lambda habit: "b") for p in providers: registry.register(p) results = [registry.get_encouragement(self.habit) for i in range(100)] self.assertEqual(set(("a", "b")), set(results))
def test_returns_an_encouragement_from_a_set_of_providers(self): registry = ProviderRegistry() providers = ( lambda habit: None, lambda habit: 'a', lambda habit: 'b', ) for p in providers: registry.register(p) results = [registry.get_encouragement(self.habit) for i in range(100)] self.assertEqual(set(('a', 'b')), set(results))
def test_returns_habit_derived_encouragements_from_a_provider(self): provider = lambda habit: habit.pk registry = ProviderRegistry() registry.register(provider) self.assertEqual(4, registry.get_encouragement(self.habit))
def test_returns_none_if_the_provider_returns_none(self): provider = lambda habit: None registry = ProviderRegistry() registry.register(provider) self.assertIsNone(registry.get_encouragement(self.habit))
def test_returns_the_encouragement_from_a_single_provider(self): encouragement = object() provider = lambda habit: encouragement registry = ProviderRegistry() registry.register(provider) self.assertEqual(encouragement, registry.get_encouragement(self.habit))
def test_returns_none_with_no_providers(self): registry = ProviderRegistry() self.assertIsNone(registry.get_encouragement(self.habit))