コード例 #1
0
ファイル: test_equipment.py プロジェクト: ymae/pytrainer
 def setUp(self):
     initialize_gettext('locale/')
     self.ddbb = DDBB()
     self.ddbb.connect()
     self.ddbb.create_tables()
     self.equipment_service = EquipmentService(self.ddbb)
     self.equipment_ui = EquipmentUi('glade/', self.equipment_service)
コード例 #2
0
ファイル: test_waypoint.py プロジェクト: nanoss/pytrainer
 def setUp(self):
     self.ddbb = DDBB()
     main = Mock()
     main.ddbb = self.ddbb
     main.ddbb.connect()
     main.ddbb.create_tables(add_default=False)
     self.waypoint = WaypointService(parent=main)
コード例 #3
0
ファイル: test_garminfit.py プロジェクト: ymae/pytrainer
 def setUp(self):
     self.ddbb = DDBB()
     self.ddbb.connect()
     self.ddbb.create_tables(add_default=True)
     self.parent = mock.Mock()
     self.parent.parent = mock.Mock()
     self.parent.parent.ddbb = self.ddbb
コード例 #4
0
ファイル: test_athlete.py プロジェクト: ymae/pytrainer
 def setUp(self):
     self.ddbb = DDBB()
     main = Mock()
     main.ddbb = self.ddbb
     main.profile = Profile()
     main.ddbb.connect()
     main.ddbb.create_tables(add_default=False)
     self.athlete = Athlete(parent=main)
コード例 #5
0
ファイル: test_garmin-tcxv2.py プロジェクト: ymae/pytrainer
 def setUp(self):
     self.ddbb = DDBB()
     self.ddbb.connect()
     self.ddbb.create_tables(add_default=True)
     main = mock.Mock()
     main.ddbb = self.ddbb
     main.startup_options = mock.Mock()
     main.profile = mock.Mock()
     main.profile.plugindir = 'plugins'
     plugins = Plugins(parent=main)
     self.plugin = plugins.importClass('plugins/garmin-tcxv2')
     tree = etree.parse('pytrainer/test/imports/sample.tcx')
     self.activity = self.plugin.getActivities(tree)[0]
コード例 #6
0
ファイル: test_activity.py プロジェクト: ymae/pytrainer
 def setUp(self):
     self.ddbb = DDBB()
     main = Mock()
     main.ddbb = self.ddbb
     main.profile = Profile()
     main.ddbb.connect()
     main.ddbb.create_tables(add_default=True)  # We need a sport
     self.uc = UC()
     self.uc.set_us(False)
     self.service = ActivityService(pytrainer_main=main)
     records_table = DeclarativeBase.metadata.tables['records']
     self.ddbb.session.execute(
         records_table.insert({
             'distance': 46.18,
             'maxspeed': 44.6695617695,
             'maxpace': 1.2,
             'title': u'test activity',
             'unegative': 564.08076273,
             'upositive': 553.05993673,
             'average': 22.3882142185,
             'date_time_local': u'2016-07-24 12:58:23+0300',
             'calories': 1462,
             'beats': 115.0,
             'comments': u'test comment',
             'pace': 2.4,
             'date_time_utc': u'2016-07-24T09:58:23Z',
             'date': datetime.date(2016, 7, 24),
             'duration': 7426,
             'sport': 1,
             'maxbeats': 120.0
         }))
     laps_table = DeclarativeBase.metadata.tables['laps']
     self.ddbb.session.execute(
         laps_table.insert({
             'distance': 46181.9,
             'lap_number': 0,
             'calories': 1462,
             'elapsed_time': u'7426.0',
             'record': 1,
             'intensity': u'active',
             'avg_hr': 136,
             'max_hr': 173,
             'laptrigger': u'manual'
         }))
     self.activity = self.service.get_activity(1)
コード例 #7
0
ファイル: test_record.py プロジェクト: ymae/pytrainer
 def setUp(self):
     self.ddbb = DDBB()
     self.ddbb.connect()
     self.ddbb.create_tables(add_default=True)
     self.main = mock.Mock()
     self.main.ddbb = self.ddbb
     self.main.activitypool = ActivityService(pytrainer_main=self.main)
     self.main.profile.gpxdir = '/nonexistent'
     self.record = Record(SportService(self.ddbb), parent=self.main)
     time = 7426
     distance = 46.18
     speed = distance * 3600 / time
     time_hhmmss = [time // 3600, (time / 60) % 60, time % 60]
     self.summary = {}
     self.summary['rcd_gpxfile'] = u'/nonexistent'
     self.summary['rcd_sport'] = u"Run"
     self.summary['rcd_date'] = u'2016-07-24'
     self.summary['rcd_calories'] = 1462
     self.summary['rcd_comments'] = u'test comment'
     self.summary['rcd_title'] = u'test 1'
     self.summary['rcd_time'] = time_hhmmss
     self.summary['rcd_distance'] = "%0.2f" % distance
     self.summary['rcd_pace'] = "%d.%02d" % ((3600 / speed) / 60,
                                             (3600 / speed) % 60)
     self.summary['rcd_maxpace'] = "%d.%02d" % ((3600 / 72) / 60,
                                                (3600 / 72) % 60)
     self.summary['rcd_average'] = speed
     self.summary['rcd_maxvel'] = 72
     self.summary['rcd_beats'] = 115.0
     self.summary['rcd_maxbeats'] = 120
     self.summary['rcd_upositive'] = 553.1
     self.summary['rcd_unegative'] = 564.1
     self.summary['date_time_local'] = u'2016-07-24 12:58:23+03:00'
     self.summary['date_time_utc'] = u'2016-07-24T09:58:23Z'
     self.laps = [{
         'distance': 46181.9,
         'lap_number': 0,
         'calories': 1462,
         'elapsed_time': u'7426.0',
         'intensity': u'active',
         'avg_hr': 136,
         'max_hr': 173,
         'laptrigger': u'manual'
     }]
コード例 #8
0
 def setUp(self):
     env = Environment()
     env.data_path = os.curdir
     env.create_directories()
     self.main = mock.Mock()
     self.main.ddbb = DDBB()
     self.main.ddbb.connect()
     self.main.ddbb.create_tables()
     self.main.profile = Profile()
     self.main.uc = UC()
     self.sport_service = SportService(self.main.ddbb)
     non_linear_sport = self.sport_service.get_sport(1)
     self.main.ddbb.session.delete(non_linear_sport)
     self.main.ddbb.session.commit()
     make_transient(non_linear_sport)
     non_linear_sport.id = None
     self.main.ddbb.session.add(non_linear_sport)
     self.main.ddbb.session.commit()
     self.main.record = Record(self.sport_service, parent=self.main)
     self.parent = Main(self.sport_service, parent=self.main)
     self.main.ddbb.session.add(
         Activity(sport=non_linear_sport,
                  date=datetime.datetime(2018, 5, 6, 10, 0, 0),
                  duration=1000,
                  distance=25))
     self.main.ddbb.session.add(
         Activity(sport=non_linear_sport,
                  date=datetime.datetime(2018, 1, 6, 10, 0, 0),
                  duration=10000,
                  distance=150))
     self.main.ddbb.session.add(
         Activity(sport=self.sport_service.get_sport(2),
                  date=datetime.datetime(2018, 1, 6, 10, 0, 0),
                  duration=10000,
                  distance=100))
     self.main.ddbb.session.commit()
コード例 #9
0
 def test_basic_url(self):
     self.ddbb = DDBB(url='sqlite:///test_url')
     self.assertEqual(self.ddbb.url, 'sqlite:///test_url')
コード例 #10
0
 def setUp(self):
     self.ddbb = DDBB()
     self.ddbb.connect()
     self.ddbb.create_tables(add_default=False)
コード例 #11
0
ファイル: test_equipment.py プロジェクト: nanoss/pytrainer
 def setUp(self):
     self.ddbb = DDBB()
     self.ddbb.connect()
     self.ddbb.create_tables()
コード例 #12
0
ファイル: test_equipment.py プロジェクト: nanoss/pytrainer
 def setUp(self):
     self.mock_ddbb = DDBB()
     self.mock_ddbb.connect()
     self.mock_ddbb.create_tables()
     self.equipment_service = EquipmentService(self.mock_ddbb)
     self.equipment_table = DeclarativeBase.metadata.tables['equipment']
コード例 #13
0
 def test_singleton(self):
     self.ddbb = DDBB(url='sqlite:///test_url')
     self.assertEqual(self.ddbb.url, 'sqlite:///test_url')
     self.ddbb = DDBB()
     self.assertEqual(self.ddbb.url, 'sqlite:///test_url')
コード例 #14
0
 def test_env_mysql_url(self):
     self.ddbb = DDBB()
     self.assertEqual(self.ddbb.url, 'mysql://pytrainer@localhost/pytrainer?charset=utf8')
コード例 #15
0
 def test_env_url(self):
     self.ddbb = DDBB()
     self.assertEqual(self.ddbb.url, 'sqlite:///envtest')
コード例 #16
0
 def setUp(self):
     self.mock_ddbb = DDBB()
     self.mock_ddbb.connect()
     self.mock_ddbb.create_tables(add_default=False)
     self.sport_service = SportService(self.mock_ddbb)
コード例 #17
0
 def test_none_url(self):
     self.ddbb = DDBB()
     self.assertEqual(self.ddbb.url, 'sqlite://')
コード例 #18
0
 def setUp(self):
     # DDBB is a singleton, make sure to destroy it between tests
     self.ddbb = DDBB()
     del(DDBB.self)