Beispiel #1
0
    def test_activities(self):

        user = random_test_user()
        bootstrap_db(user, m(V), '5', mm(DEV), configurator=default)
        config = bootstrap_db(user, m(V), '5', 'constants', 'set', 'SRTM1.dir',
                              '/home/andrew/archive/srtm1', mm(FORCE))
        constants(config)

        with TemporaryDirectory() as f:
            config = bootstrap_db(
                user, mm(BASE), f, m(V), '5', mm(DEV), 'upload',
                'data/test/source/personal/2018-08-27-rec.fit')
            upload(config)

        with config.db.session_context() as s:
            n_raw = s.query(count(StatisticJournalFloat.id)). \
                join(StatisticName). \
                filter(StatisticName.name == N.RAW_ELEVATION).scalar()
            self.assertEqual(2099, n_raw)
            n_fix = s.query(count(StatisticJournalFloat.id)). \
                join(StatisticName). \
                filter(StatisticName.name == N.ELEVATION).scalar()
            self.assertEqual(2099, n_fix)
            # WHY does this jump around?
            n = s.query(count(StatisticJournal.id)).scalar()
            # self.assertEqual(62525, n)
            self.assertTrue(n > 30000)
            self.assertTrue(n < 100000)
            journal = s.query(ActivityJournal).one()
            self.assertNotEqual(journal.start, journal.finish)
            print(n)
 def test_constant(self):
     user = random_test_user()
     config = bootstrap_db(user, m(V), '5')
     bootstrap_db(user, m(V), '5', mm(DEV), configurator=default)
     with config.db.session_context() as s:
         n = s.query(count(Constant.id)).scalar()
         self.assertEqual(n, 14)
     config = bootstrap_db(user, m(V), '5', 'constants', 'set', 'fthr:%', '154', mm(FORCE))
     constants(config)
     with config.db.session_context() as s:
         n = s.query(count(Constant.id)).scalar()
         self.assertEqual(n, 14)
Beispiel #3
0
 def test_constant(self):
     with NamedTemporaryFile() as f:
         args, db = bootstrap_file(f, m(V), '5')
         bootstrap_file(f, m(V), '5', mm(DEV), configurator=default)
         with db.session_context() as s:
             n = s.query(count(Constant.id)).scalar()
             self.assertEqual(n, 10)
         args, db = bootstrap_file(f, m(V), '5', 'constants', '--set',
                                   'FTHR.%', '154')
         constants(args, db)
         with db.session_context() as s:
             n = s.query(count(Constant.id)).scalar()
             self.assertEqual(n, 10)
Beispiel #4
0
 def test_constant(self):
     with TemporaryDirectory() as f:
         args, data = bootstrap_dir(f, m(V), '5')
         bootstrap_dir(f, m(V), '5', mm(DEV), configurator=default)
         with data.db.session_context() as s:
             n = s.query(count(Constant.id)).scalar()
             self.assertEqual(n, 14)
         args, data = bootstrap_dir(f, m(V), '5', 'constants', 'set',
                                    'fthr:%', '154', mm(FORCE))
         constants(args, data)
         with data.db.session_context() as s:
             n = s.query(count(Constant.id)).scalar()
             self.assertEqual(n, 14)
 def test_constant(self):
     # this is currently failing because there are multiple statistics called Active Distance
     with NamedTemporaryFile() as f:
         args, db = bootstrap_file(f, m(V), '5')
         bootstrap_file(f, m(V), '5', mm(DEV), configurator=default)
         with db.session_context() as s:
             n = s.query(count(Constant.id)).scalar()
             self.assertEqual(n, 13)
         args, db = bootstrap_file(f, m(V), '5', 'constants', '--set',
                                   'FTHR.%', '154')
         constants(args, db)
         with db.session_context() as s:
             n = s.query(count(Constant.id)).scalar()
             self.assertEqual(n, 13)
Beispiel #6
0
    def test_activities(self):

        with TemporaryDirectory() as base:

            bootstrap_dir(base, m(V), '5')

            bootstrap_dir(base, m(V), '5', mm(DEV), configurator=default)

            args, data = bootstrap_dir(base, m(V), '5', 'constants', 'set',
                                       'SRTM1.dir',
                                       '/home/andrew/archive/srtm1', mm(FORCE))
            constants(args, data)

            args, data = bootstrap_dir(
                base, m(V), '5', mm(DEV), 'read',
                'data/test/source/personal/2018-08-27-rec.fit')
            read(args, data)

            # run('sqlite3 %s ".dump"' % f.name, shell=True)

            run_pipeline(data,
                         PipelineType.CALCULATE,
                         force=True,
                         start='2018-01-01',
                         n_cpu=1)

            # run('sqlite3 %s ".dump"' % f.name, shell=True)

            with data.db.session_context() as s:
                n_raw = s.query(count(StatisticJournalFloat.id)). \
                    join(StatisticName). \
                    filter(StatisticName.name == N.RAW_ELEVATION).scalar()
                self.assertEqual(2099, n_raw)
                n_fix = s.query(count(StatisticJournalFloat.id)). \
                    join(StatisticName). \
                    filter(StatisticName.name == N.ELEVATION).scalar()
                self.assertEqual(2099, n_fix)
                # WHY does this jump around?
                n = s.query(count(StatisticJournal.id)).scalar()
                # self.assertEqual(50403, n)
                self.assertTrue(n > 30000)
                self.assertTrue(n < 100000)
                journal = s.query(ActivityJournal).one()
                self.assertNotEqual(journal.start, journal.finish)
Beispiel #7
0
    def test_activities(self):

        with NamedTemporaryFile() as f:

            args, db = bootstrap_file(f, m(V), '5')

            bootstrap_file(f, m(V), '5', mm(DEV), configurator=default)

            args, db = bootstrap_file(f, m(V), '5', 'constants', '--set',
                                      'FTHR.%', '154')
            constants(args, db)

            args, db = bootstrap_file(f, m(V), '5', 'constants', 'FTHR.%')
            constants(args, db)

            args, db = bootstrap_file(f, m(V), '5', 'constants', '--set',
                                      'SRTM1.dir',
                                      '/home/andrew/archive/srtm1')
            constants(args, db)

            args, db = bootstrap_file(
                f, m(V), '5', mm(DEV), 'activities', mm(FAST),
                'data/test/source/personal/2018-08-27-rec.fit')
            activities(args, db)

            # run('sqlite3 %s ".dump"' % f.name, shell=True)

            run_pipeline(db,
                         PipelineType.STATISTIC,
                         force=True,
                         start='2018-01-01',
                         n_cpu=1)

            # run('sqlite3 %s ".dump"' % f.name, shell=True)

            with db.session_context() as s:
                n_raw = s.query(count(StatisticJournalFloat.id)). \
                    join(StatisticName). \
                    filter(StatisticName.name == RAW_ELEVATION).scalar()
                self.assertEqual(2099, n_raw)
                n_fix = s.query(count(StatisticJournalFloat.id)). \
                    join(StatisticName). \
                    filter(StatisticName.name == ELEVATION).scalar()
                self.assertEqual(2099, n_fix)
                n = s.query(count(StatisticJournal.id)).scalar()
                self.assertEqual(23655, n)
                journal = s.query(ActivityJournal).one()
                self.assertNotEqual(journal.start, journal.finish)