本文整理汇总了Python中pyiso.base.BaseClient.handle_options方法的典型用法代码示例。如果您正苦于以下问题:Python BaseClient.handle_options方法的具体用法?Python BaseClient.handle_options怎么用?Python BaseClient.handle_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyiso.base.BaseClient
的用法示例。
在下文中一共展示了BaseClient.handle_options方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_handle_options_set
# 需要导入模块: from pyiso.base import BaseClient [as 别名]
# 或者: from pyiso.base.BaseClient import handle_options [as 别名]
def test_handle_options_set(self):
"""Can set options"""
bc = BaseClient()
bc.handle_options(test='a', another=20)
self.assertEqual(bc.options['test'], 'a')
self.assertEqual(bc.options['another'], 20)
self.assertFalse(bc.options['sliceable'])
示例2: test_handle_options_latest
# 需要导入模块: from pyiso.base import BaseClient [as 别名]
# 或者: from pyiso.base.BaseClient import handle_options [as 别名]
def test_handle_options_latest(self):
"""Correct processing of time-related options for latest"""
bc = BaseClient()
bc.handle_options(latest=True)
self.assertTrue(bc.options['latest'])
self.assertFalse(bc.options['sliceable'])
self.assertFalse(bc.options['forecast'])
示例3: test_handle_options_future
# 需要导入模块: from pyiso.base import BaseClient [as 别名]
# 或者: from pyiso.base.BaseClient import handle_options [as 别名]
def test_handle_options_future(self):
"""Correct processing of time-related options for future start and end times"""
bc = BaseClient()
bc.handle_options(start_at='2100-01-01', end_at='2100-02-01')
self.assertTrue(bc.options['sliceable'])
self.assertEqual(bc.options['start_at'], datetime(2100, 1, 1, 0, tzinfo=pytz.utc))
self.assertEqual(bc.options['end_at'], datetime(2100, 2, 1, 0, tzinfo=pytz.utc))
self.assertTrue(bc.options['forecast'])
示例4: test_handle_options_twice
# 需要导入模块: from pyiso.base import BaseClient [as 别名]
# 或者: from pyiso.base.BaseClient import handle_options [as 别名]
def test_handle_options_twice(self):
"""Overwrite options on second call"""
bc = BaseClient()
bc.handle_options(forecast=True)
self.assertTrue(bc.options['forecast'])
bc.handle_options(yesterday=True)
self.assertFalse(bc.options['forecast'])
示例5: test_handle_options_past
# 需要导入模块: from pyiso.base import BaseClient [as 别名]
# 或者: from pyiso.base.BaseClient import handle_options [as 别名]
def test_handle_options_past(self):
"""Correct processing of time-related options for historical start and end times"""
bc = BaseClient()
bc.handle_options(start_at="2014-01-01", end_at="2014-02-01")
self.assertTrue(bc.options["sliceable"])
self.assertEqual(bc.options["start_at"], datetime(2014, 1, 1, 0, tzinfo=pytz.utc))
self.assertEqual(bc.options["end_at"], datetime(2014, 2, 1, 0, tzinfo=pytz.utc))
self.assertFalse(bc.options["forecast"])
示例6: test_handle_options_forecast
# 需要导入模块: from pyiso.base import BaseClient [as 别名]
# 或者: from pyiso.base.BaseClient import handle_options [as 别名]
def test_handle_options_forecast(self):
"""Correct auto-setup of time-related options for forecast"""
bc = BaseClient()
bc.handle_options(forecast=True)
self.assertTrue(bc.options['sliceable'])
local_now = pytz.utc.localize(datetime.utcnow()).astimezone(pytz.utc).replace(microsecond=0)
self.assertEqual(bc.options['start_at'], local_now)
self.assertEqual(bc.options['end_at'], local_now + timedelta(days=2))
self.assertTrue(bc.options['forecast'])
示例7: test_handle_options_forecast
# 需要导入模块: from pyiso.base import BaseClient [as 别名]
# 或者: from pyiso.base.BaseClient import handle_options [as 别名]
def test_handle_options_forecast(self):
"""Correct auto-setup of time-related options for forecast"""
bc = BaseClient()
bc.handle_options(forecast=True)
self.assertTrue(bc.options['sliceable'])
local_now = pytz.utc.localize(datetime.utcnow()).astimezone(pytz.utc)
self.assertEqual(bc.options['start_at'], datetime(local_now.year, local_now.month, local_now.day, 0, tzinfo=pytz.utc))
self.assertEqual(bc.options['end_at'], datetime(local_now.year, local_now.month, local_now.day+2, 0, tzinfo=pytz.utc))
self.assertTrue(bc.options['forecast'])
示例8: test_handle_options_yesterday
# 需要导入模块: from pyiso.base import BaseClient [as 别名]
# 或者: from pyiso.base.BaseClient import handle_options [as 别名]
def test_handle_options_yesterday(self):
"""Correct auto-setup of time-related options for yesterday"""
bc = BaseClient()
bc.handle_options(yesterday=True)
self.assertTrue(bc.options['sliceable'])
local_now = pytz.utc.localize(datetime.utcnow()).astimezone(pytz.utc)
midnight_today = datetime(local_now.year, local_now.month, local_now.day, 0, tzinfo=pytz.utc)
self.assertEqual(bc.options['start_at'], midnight_today - timedelta(days=1))
self.assertEqual(bc.options['end_at'], midnight_today)
self.assertFalse(bc.options['forecast'])
示例9: test_handle_options_forecast
# 需要导入模块: from pyiso.base import BaseClient [as 别名]
# 或者: from pyiso.base.BaseClient import handle_options [as 别名]
def test_handle_options_forecast(self):
"""Correct auto-setup of time-related options for forecast"""
bc = BaseClient()
bc.handle_options(forecast=True)
self.assertTrue(bc.options["sliceable"])
local_now = pytz.utc.localize(datetime.utcnow()).astimezone(pytz.utc)
midnight_today = datetime(local_now.year, local_now.month, local_now.day, 0, tzinfo=pytz.utc)
self.assertEqual(bc.options["start_at"], midnight_today)
self.assertEqual(bc.options["end_at"], midnight_today + timedelta(days=2))
self.assertTrue(bc.options["forecast"])
示例10: test_handle_options_set_forecast
# 需要导入模块: from pyiso.base import BaseClient [as 别名]
# 或者: from pyiso.base.BaseClient import handle_options [as 别名]
def test_handle_options_set_forecast(self):
bc = BaseClient()
start = datetime(2020, 5, 26, 0, 0, tzinfo=pytz.utc)
bc.handle_options(start_at=start, end_at=start+timedelta(days=2))
self.assertTrue(bc.options['forecast'])