def testModel(self): """ Evaluates methods not annotated as @property""" ml = Model() ml.name = 'Test Model' ml.type = 'google' ml.public = True ml.data = 'matlab_function,1' db.session.add(ml) score = 6.5 day = datetime.date.today() - datetime.timedelta(days=3) for i in xrange(4): ms = ModelScore() ms.day = day + datetime.timedelta(days=i) ms.region = 'e' ms.value = score - i ms.model_id = 1 db.session.add(ms) db.session.commit() dbmodel = db.session.query(Model).first() expected = db.session.query(ModelScore).all() result_get_scores = dbmodel.get_scores(start=day, end=datetime.date.today(), region='e', resolution=1) self.assertEqual(result_get_scores, expected) result_regions = dbmodel.scores_for('e').all() self.assertEqual(result_regions, expected) result_get_data = dbmodel.get_data() self.assertEqual(result_get_data['matlab_function'], 'matlab_function') self.assertEqual(result_get_data['average_window_size'], 1)
def setUp(self): db.init_app(GoogleTest.create_app()) db.create_all() db.engine.execute('insert into model values (1, "Test Model", "google", 1, "matlab_function,1")') score = 6.5 start_date = datetime.date.today() - datetime.timedelta(days=5) for i in xrange(4): ms = ModelScore() ms.day = start_date + datetime.timedelta(days=i) ms.region = 'e' ms.value = score - i ms.model_id = 1 db.session.add(ms) gs = GoogleScore() gs.day = start_date + datetime.timedelta(days=i) gs.value = score - i gs.term_id = 1 db.session.add(gs) db.session.commit() db.engine.execute('insert into google_term values (1, "Term 1")') db.engine.execute('insert into model_google_terms values (1, 1)')