def test_get_base(self): date = datetime.date(2015, 9, 22) for m, basestr in zip( ['DAY', 'WEEK', 'MONTH', 'YEAR'], ['day/20150922', 'week/20150922', 'month/201509', 'year/2015']): mode.set_mode(m) base = mode.get_base(date) self.assertEqual(base, basestr)
def test_set_mode(): mode.set_mode(0) assert globalv.MODE == mode.Mode(0).value mode.set_mode('GPS') assert globalv.MODE == mode.Mode.gps.value with pytest.raises(ValueError): mode.set_mode('invalid mode')
def test_get_channel_trend(self): """Test get_channel for trends `get_channel` should query for the trend and the underlying raw channel """ # test simple query nchan = len(globalv.CHANNELS) chan = channels.get_channel(TREND_NAME) self.assertEqual(len(globalv.CHANNELS), nchan + 2) # test that raw doesn't get built again chan = channels.get_channel(TREND_NAME2) self.assertEqual(len(globalv.CHANNELS), nchan + 3) # test that raw matches trend raw = channels.get_channel(TREND_NAME.split('.')[0]) self.assertEqual(len(globalv.CHANNELS), nchan + 3) self.assertEqual(raw.name, TREND_NAME.split('.')[0]) # test default trend type set_mode('DAY') chan = channels.get_channel(TREND_NAME3) self.assertEqual(chan.type, 'm-trend') set_mode('GPS') chan = channels.get_channel(TREND_NAME4) self.assertEqual(chan.type, 's-trend')
def test_set_mode(self): mode.set_mode(0) self.assertEqual(globalv.MODE, mode.Mode(0)) self.assertEqual(globalv.MODE, mode.Mode.static) mode.set_mode('GPS') self.assertEqual(globalv.MODE, mode.Mode.gps)
def tearDownClass(cls): mode.set_mode(cls._defaultmode)
def teardown_module(): """Undo any set_mode() operations from this module """ set_mode(DEFAULT_MODE)
def test_set_mode(self): mode.set_mode(0) self.assertEqual(globalv.MODE, 0) self.assertEqual(globalv.MODE, mode.SUMMARY_MODE_DAY) mode.set_mode('GPS') self.assertEqual(globalv.MODE, mode.SUMMARY_MODE_GPS)
def test_get_base(m, basestr): date = datetime.date(2015, 9, 14) mode.set_mode(m) assert mode.get_base(date) == basestr
def teardown_module(): """Undo any set_mode() operations from this module """ mode.set_mode(DEFAULT_MODE)