From b65832b0545bcc6bf58900867bc71d4f86db873e Mon Sep 17 00:00:00 2001 From: Nile Walker Date: Thu, 14 Jan 2021 09:20:55 -0500 Subject: [PATCH] Readded Tiles --- communicator/__init__.py | 9 ++++++--- tests/services/test_graph_service.py | 24 ++++++++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/communicator/__init__.py b/communicator/__init__.py index 9b5d6ba..92f179e 100644 --- a/communicator/__init__.py +++ b/communicator/__init__.py @@ -233,8 +233,10 @@ def index(): table = SampleTable(group_columns(filtered_samples[(page - 1) * 10:((page - 1) * 10) + 10])) return render_template('layouts/default.html', - base_href=BASE_HREF, - content=render_template( + base_href=BASE_HREF, + dates = important_dates, + overall_totals_data = overall_totals_data, + content=render_template( 'pages/index.html', form = form, dates = important_dates, @@ -247,7 +249,8 @@ def index(): daily_charts_data = daily_charts_data, hourly_charts_data = hourly_charts_data, weekday_charts_data = weekday_charts_data, - + + overall_totals_data = overall_totals_data, location_stats_data = location_stats_data, )) diff --git a/tests/services/test_graph_service.py b/tests/services/test_graph_service.py index 58f6fd5..b9efaab 100644 --- a/tests/services/test_graph_service.py +++ b/tests/services/test_graph_service.py @@ -4,16 +4,29 @@ import pytz from tests.base_test import BaseTest -from communicator import app +from communicator import db, app from communicator.models import Sample -from communicator.services.graph_service import GraphService +from communicator.services.graph_service import GraphService, daterange from datetime import date, timedelta - +import json class TestGraphService(BaseTest): + def populate_test_db(self): + days = 50 + + + for day in daterange(date.today() - timedelta(days), date.today()): + _sample = Sample(barcode="000000111-202009091449-4321", location = 50, station = 30, student_id = "000000111", + computing_id = "abc12d") + _sample.date = day + db.session.add(_sample) + db.session.commit() + samples = db.session.query(Sample).all() + self.assertNotEqual(0, len(samples)) def test_get_totals_last_week(self): graph = GraphService() + self.populate_test_db() graph.update_search_filters({ "start_date": datetime.date(2020,11,1), "end_date": datetime.date(2020,11,1), @@ -25,6 +38,7 @@ class TestGraphService(BaseTest): def test_get_totals_by_hour(self): graph = GraphService() + self.populate_test_db() graph.update_search_filters({ "start_date": datetime.date(2020,11,1), "end_date": datetime.date(2020,11,1), @@ -36,6 +50,7 @@ class TestGraphService(BaseTest): def test_get_totals_by_day(self): graph = GraphService() + self.populate_test_db() graph.update_search_filters({ "start_date": datetime.date(2020,11,1), "end_date": datetime.date(2020,11,1), @@ -47,13 +62,14 @@ class TestGraphService(BaseTest): def test_get_totals_by_weekday(self): graph = GraphService() + self.populate_test_db() graph.update_search_filters({ "start_date": date.today() - timedelta(100), "end_date": date.today(), "location": "50" }) result = graph.get_totals_by_weekday() - + print(result) self.assertTrue(20 not in result) self.assertEqual(result[50][0][1],17) self.assertEqual(result[50][10][1],16)