def filter_test_reports(filter_test_types, session): types = filter_test_types # Constructing test data manually, rather than using factories because of: # https://github.com/FactoryBoy/factory_boy/issues/636 ret = [ factories.ReportFactory( # models.Report( created_at=datetime.datetime.now() - datetime.timedelta(days=1), samples=[factories.SampleFactory( data=[] )], meta=[ factories.ReportMetaFactory.build( report_meta_key='key_1', report_meta_value='1', report=None ), factories.ReportMetaFactory.build( report_meta_key='key_2', report_meta_value=1, report=None ), ] ), # models.Report( factories.ReportFactory( created_at=datetime.datetime.now() - datetime.timedelta(days=2), samples=[factories.SampleFactory( data=[] )], meta=[ factories.ReportMetaFactory.build( report_meta_key='key_1', report_meta_value='2', report=None ), factories.ReportMetaFactory.build( report_meta_key='key_2', report_meta_value=2, report=None ), ] ), # models.Report( factories.ReportFactory( created_at=datetime.datetime.now() - datetime.timedelta(days=3), samples=[factories.SampleFactory( data=[] )], meta=[ factories.ReportMetaFactory.build( report_meta_key='key_1', report_meta_value='3', report=None ), factories.ReportMetaFactory.build( report_meta_key='key_2', report_meta_value=3, report=None ), ] ) ] for i, report in enumerate(ret): report.samples[0].data = [ factories.SampleDataFactory.build(data_type=types[0], value=i + 1, report=report), factories.SampleDataFactory.build(data_type=types[1], value=i + 1, report=report), ] session.expunge_all() session.add_all(ret) session.commit() return ret
def report(session): r = factories.ReportFactory() session.add(r) session.commit() return r
def filter_test_reports(filter_test_types, session): types = filter_test_types # Constructing test data manually, rather than using factories because of: # https://github.com/FactoryBoy/factory_boy/issues/636 ret = [ factories.ReportFactory( # models.Report( created_at=datetime.datetime.now() - datetime.timedelta(days=1), samples=[factories.SampleFactory(data=[])], meta=[ factories.ReportMetaFactory.build(report_meta_key="key_1", report_meta_value="1", report=None), factories.ReportMetaFactory.build(report_meta_key="key_2", report_meta_value=1, report=None), ], ), # models.Report( factories.ReportFactory( created_at=datetime.datetime.now() - datetime.timedelta(days=2), samples=[factories.SampleFactory(data=[])], meta=[ factories.ReportMetaFactory.build(report_meta_key="key_1", report_meta_value="2", report=None), factories.ReportMetaFactory.build(report_meta_key="key_2", report_meta_value=2, report=None), ], ), # models.Report( factories.ReportFactory( created_at=datetime.datetime.now() - datetime.timedelta(days=3), samples=[factories.SampleFactory(data=[])], meta=[ factories.ReportMetaFactory.build(report_meta_key="key_1", report_meta_value="3", report=None), factories.ReportMetaFactory.build(report_meta_key="key_2", report_meta_value=3, report=None), ], ), ] words = ["aardvark", "badger", "caboose", "dachshund", "eagle"] for i, report in enumerate(ret): report.samples[0].data = [ factories.SampleDataFactory.build(data_type=types[0], value=i + 1, report=report), factories.SampleDataFactory.build(data_type=types[1], value=words[i], report=report), ] session.expunge_all() session.add_all(ret) session.commit() return ret