def setUp(self): self.pubnub = MagicMock(spec=PubNub, config=pnconf, sdk_name=sdk_name, timestamp=MagicMock(return_value=123), uuid=None) self.pubnub.uuid = "UUID_UnitTest" self.pubnub._telemetry_manager = TelemetryManager() self.history = History(self.pubnub)
def setUp(self): self.pubnub = MagicMock( spec=PubNub, config=pnconf, sdk_name=sdk_name, timestamp=MagicMock(return_value=123), uuid=None ) self.pubnub.uuid = "UUID_UnitTest" self.history = History(self.pubnub)
class TestHistory(unittest.TestCase): def setUp(self): self.pubnub = MagicMock(spec=PubNub, config=pnconf, sdk_name=sdk_name, timestamp=MagicMock(return_value=123), uuid=None) self.pubnub.uuid = "UUID_UnitTest" self.pubnub._telemetry_manager = TelemetryManager() self.history = History(self.pubnub) def test_history_basic(self): self.history.channel('ch') self.assertEquals(self.history.build_path(), History.HISTORY_PATH % (pnconf.subscribe_key, 'ch')) self.assertEqual(self.history.build_params_callback()({}), { 'pnsdk': sdk_name, 'uuid': self.pubnub.uuid, 'count': '100' }) def test_history_full(self): self.history.channel('ch').start(100000).end(200000).reverse( False).count(3).include_timetoken(True) self.assertEquals(self.history.build_path(), History.HISTORY_PATH % (pnconf.subscribe_key, 'ch')) self.assertEqual( self.history.build_params_callback()({}), { 'pnsdk': sdk_name, 'uuid': self.pubnub.uuid, 'count': '3', 'start': '100000', 'end': '200000', 'reverse': 'false', 'include_token': 'true' })
class TestHistory(unittest.TestCase): def setUp(self): self.pubnub = MagicMock( spec=PubNub, config=pnconf, sdk_name=sdk_name, timestamp=MagicMock(return_value=123), uuid=None ) self.pubnub.uuid = "UUID_UnitTest" self.history = History(self.pubnub) def test_history_basic(self): self.history.channel('ch') self.assertEquals(self.history.build_path(), History.HISTORY_PATH % (pnconf.subscribe_key, 'ch')) self.assertEqual(self.history.build_params_callback()({}), { 'pnsdk': sdk_name, 'uuid': self.pubnub.uuid, 'count': '100' }) def test_history_full(self): self.history.channel('ch').start(100000).end(200000).reverse(False).count(3).include_timetoken(True) self.assertEquals(self.history.build_path(), History.HISTORY_PATH % (pnconf.subscribe_key, 'ch')) self.assertEqual(self.history.build_params_callback()({}), { 'pnsdk': sdk_name, 'uuid': self.pubnub.uuid, 'count': '3', 'start': '100000', 'end': '200000', 'reverse': 'false', 'include_token': 'true' })