예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
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')
예제 #4
0
    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')
예제 #5
0
 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)
예제 #6
0
 def tearDownClass(cls):
     mode.set_mode(cls._defaultmode)
예제 #7
0
def teardown_module():
    """Undo any set_mode() operations from this module
    """
    set_mode(DEFAULT_MODE)
예제 #8
0
 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)
예제 #9
0
def test_get_base(m, basestr):
    date = datetime.date(2015, 9, 14)
    mode.set_mode(m)
    assert mode.get_base(date) == basestr
예제 #10
0
파일: test_mode.py 프로젝트: gwpy/gwsumm
def teardown_module():
    """Undo any set_mode() operations from this module
    """
    mode.set_mode(DEFAULT_MODE)