Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
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'
            })
Ejemplo n.º 4
0
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'
        })