Пример #1
0
class TestAddEmptySubTopic(unittest.TestCase):
    def setUp(self):
        self._list = PassageList("topic")
        self._list.add_empty_subtopic("Name", "Description")
        self._added_subtopic = self._list.subtopics[0]

    def testShouldHaveOneSubTopic(self):
        self.assertEqual(len(self._list.subtopics), 1)

    def testAddedSubTopicShouldBeEmpty(self):
        self.assertEqual(len(self._added_subtopic.subtopics), 0)
        self.assertEqual(len(self._added_subtopic.passages), 0)

    def testAddedSubTopicShouldHaveCorrectDetails(self):
        self.assertEqual(self._added_subtopic.name, "Name")
        self.assertEqual(self._added_subtopic.description, "Description")
Пример #2
0
class TestAddEmptySubTopic(unittest.TestCase):
	def setUp(self):
		self._list = PassageList("topic")
		self._list.add_empty_subtopic("Name", "Description")
		self._added_subtopic = self._list.subtopics[0]
	
	def testShouldHaveOneSubTopic(self):
		self.assertEqual(len(self._list.subtopics), 1)
	
	def testAddedSubTopicShouldBeEmpty(self):
		self.assertEqual(len(self._added_subtopic.subtopics), 0)
		self.assertEqual(len(self._added_subtopic.passages), 0)

	def testAddedSubTopicShouldHaveCorrectDetails(self):
		self.assertEqual(self._added_subtopic.name, "Name")
		self.assertEqual(self._added_subtopic.description, "Description")
Пример #3
0
class TestPassageListSubTopicListener(unittest.TestCase):
	def setUp(self):
		self._passage_list = PassageList("topic")
		self._num_times_observer_called = 0
		self._passage_list.add_subtopic_observers += self._addSubTopic
	
	def testAddSubTopicShouldCallListener(self):
		self._passage_list.add_subtopic(PassageList("a"))
		self._checkObserverHasBeenCalled()
	
	def testAddEmptySubListShouldCallListener(self):
		self._passage_list.add_empty_subtopic("topic", "description")
		self._checkObserverHasBeenCalled()

	def _checkObserverHasBeenCalled(self):
		self.assertEqual(self._num_times_observer_called, 1)
	
	def _addSubTopic(self, subtopic):
		self._num_times_observer_called += 1
Пример #4
0
class TestPassageListSubTopicListener(unittest.TestCase):
    def setUp(self):
        self._passage_list = PassageList("topic")
        self._num_times_observer_called = 0
        self._passage_list.add_subtopic_observers += self._addSubTopic

    def testAddSubTopicShouldCallListener(self):
        self._passage_list.add_subtopic(PassageList("a"))
        self._checkObserverHasBeenCalled()

    def testAddEmptySubListShouldCallListener(self):
        self._passage_list.add_empty_subtopic("topic", "description")
        self._checkObserverHasBeenCalled()

    def _checkObserverHasBeenCalled(self):
        self.assertEqual(self._num_times_observer_called, 1)

    def _addSubTopic(self, subtopic):
        self._num_times_observer_called += 1