Exemplo n.º 1
0
 def test_global(self):
     models_session = [
         models_tests.generate_model_session(),
         models_tests.generate_model_session(),
         models_tests.generate_model_session()
     ]
     self.older_config_get_list_block_session_value = [
         models_tests.generate_block_session(session=models_session[0], use_data=False),
         models_tests.generate_block_session(session=models_session[1], use_data=False),
         models_tests.generate_block_session(session=models_session[2], use_data=True)
     ]
     self.older_config_get_current_block_Session_value = self.older_config_get_list_block_session_value
     configuration = mocks.MockOlderConfig()
     sessions = [
         mocks.MockSession(model=models_session[0], status_begin=5,
                           completed_time=dateutil.parser.parse("2015-09-21")),
         mocks.MockSession(model=models_session[1], status_begin=5,
                           completed_time=dateutil.parser.parse("2015-09-21")),
         mocks.MockSession(model=models_tests.generate_model_session(),
                           status_begin=5, completed_time=dateutil.parser.parse("2015-09-21")),
         mocks.MockSession(model=models_session[2], status_begin=5, completed_time=None),
         mocks.MockSession(model=models_tests.generate_model_session(), completed_time=None),
     ]
     list_sessions, sessions_made, sessions_use_data = main.generate_lists(configuration,
                                                                           sessions)
     self.assertEqual(list_sessions, models_session)
     self.assertEqual(sessions_made, [sessions[0], sessions[1]])
     self.assertEqual(sessions_use_data, [models_session[2]])
Exemplo n.º 2
0
 def setUp(self):
     self.days = map(lambda e: dateutil.parser.parse("2015/09/" + str(e)), range(21, 28))
     self.model_sessions = [
         models_tests.generate_model_session(),
         models_tests.generate_model_session(),
         models_tests.generate_model_session()
     ]
Exemplo n.º 3
0
 def test(self):
     list = [
         mocks.MockSession(self.model_sessions[0], publish_date=None, completed_time=self.days[0]),
         mocks.MockSession(self.model_sessions[0], publish_date=self.days[1], completed_time=self.days[2]),
         mocks.MockSession(models_tests.generate_model_session(), publish_date=self.days[0],
                           completed_time=self.days[0]),
         mocks.MockSession(self.model_sessions[0], publish_date=self.days[2], completed_time=self.days[2]),
         mocks.MockSession(models_tests.generate_model_session(), publish_date=self.days[2],
                           completed_time=self.days[2]),
         mocks.MockSession(self.model_sessions[1], publish_date=self.days[3], completed_time=self.days[3]),
         mocks.MockSession(models_tests.generate_model_session(), publish_date=self.days[4], completed_time=None),
         mocks.MockSession(self.model_sessions[2], publish_date=self.days[5], completed_time=None),
     ]
     not_done, not_done_pattern, s_week = main.get_counters(list, self.model_sessions, self.days[2])
     self.assertEqual(not_done, 2)
     self.assertEqual(not_done_pattern, 1)
     self.assertEqual(s_week, 3)
Exemplo n.º 4
0
    def test_with_data(self):
        self.tmp = 0

        def mock_get_percentile(older, session):
            self.tmp += 1
            return self.tmp

        main.get_percentile = mock_get_percentile

        ms1 = models_tests.generate_model_session(1)
        ms2 = models_tests.generate_model_session(2)
        ms3 = models_tests.generate_model_session(3)

        sessions = [
            models_tests.generate_session(model=ms1),
            models_tests.generate_session(model=ms1),
            models_tests.generate_session(model=ms1)
        ]

        p, m = main.get_average_data(None, sessions, [ms2, ms3])
        self.assertIsNone(p)
        self.assertIsNone(m)

        sessions = [
            models_tests.generate_session(model=ms1, motivation=1),
            models_tests.generate_session(model=ms2),
            models_tests.generate_session(model=ms3)
        ]
        p, m = main.get_average_data(None, sessions, [ms1])
        self.assertEqual(p, 1)
        self.assertEqual(m, 1)

        sessions = [
            models_tests.generate_session(model=ms1, motivation=1),
            models_tests.generate_session(model=ms2, motivation=5),
            models_tests.generate_session(model=ms3)
        ]
        p, m = main.get_average_data(None, sessions, [ms1, ms2])
        self.assertEqual(p, 2.5)
        self.assertEqual(m, 3)