def test_history(self): self.get_counters_value = (0, 0, 0) mocks.MockPatternHistory.list_mocks = [] self.configuration.pattern = models_tests.generate_pattern() self.configuration.block = models_tests.generate_block() self.configuration.level = 2 self.configuration.older = models.Older() self.configuration.warnings = [mocks.MockWarning(), mocks.MockWarning()] main.run(self.configuration, "monday") self.assertEqual(len(mocks.MockPatternHistory.list_mocks), 1) historic = mocks.MockPatternHistory.list_mocks[0] self.assertEqual(self.configuration.pattern, historic.pattern) self.assertEqual(self.configuration.block, historic.block) self.assertEqual(self.configuration.level, historic.level) self.assertEqual(self.configuration.older, historic.older) self.assertEqual(self.configuration.warnings, historic.warnings) self.assertEqual(len(historic.sessions), 2)
def setUp(self): def generate_sessions(): list_mock_sessions = [] for level in range(1, 5): list_mock_sessions.extend([ models_tests.generate_block_session(level * 5, level=level, session=models.ModelSession(), order=10), models_tests.generate_block_session(level * 5 + 1, level=level, session=models.ModelSession(), order=20), models_tests.generate_block_session(level * 5 + 2, level=level, session=models.ModelSession(), order=30), ]) return list_mock_sessions self.configuration = models.OlderConfig() self.b1 = models_tests.generate_block(order=10, sessions=generate_sessions()) self.b2 = models_tests.generate_block(order=20, sessions=generate_sessions()) self.b3 = models_tests.generate_block(order=30, sessions=generate_sessions()) self.configuration.pattern = models_tests.generate_pattern(blocks=[self.b1, self.b3, self.b2])