예제 #1
0
파일: tests.py 프로젝트: eachan/behabitual
 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))
예제 #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))
예제 #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))
예제 #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))
예제 #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))
예제 #6
0
 def test_returns_none_with_no_providers(self):
     registry = ProviderRegistry()
     self.assertIsNone(registry.get_encouragement(self.habit))
예제 #7
0
파일: tests.py 프로젝트: eachan/behabitual
 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))
예제 #8
0
파일: tests.py 프로젝트: eachan/behabitual
 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))
예제 #9
0
파일: tests.py 프로젝트: eachan/behabitual
 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))
예제 #10
0
파일: tests.py 프로젝트: eachan/behabitual
 def test_returns_none_with_no_providers(self):
     registry = ProviderRegistry()
     self.assertIsNone(registry.get_encouragement(self.habit))