Exemple #1
0
 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))
Exemple #2
0
 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))
Exemple #3
0
 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))
Exemple #4
0
 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))
Exemple #5
0
 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))
Exemple #6
0
 def test_returns_none_with_no_providers(self):
     registry = ProviderRegistry()
     self.assertIsNone(registry.get_encouragement(self.habit))
Exemple #7
0
 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))
Exemple #8
0
 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))
Exemple #9
0
 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))
Exemple #10
0
 def test_returns_none_with_no_providers(self):
     registry = ProviderRegistry()
     self.assertIsNone(registry.get_encouragement(self.habit))