Esempio n. 1
0
class CoreTest(TestCase):
    def setUp(self):
        self.application = Application()
        self.pubsub = BasePubSub(self.application)

        self.project_id = 'test'
        self.namespace = 'test'
        self.channel = 'test'

    def test_get_subscription_key(self):
        subscription_key = self.pubsub.get_subscription_key(
            self.project_id, self.namespace, self.channel)
        self.assertTrue(isinstance(subscription_key, str))

    def test_add_subscription(self):
        self.pubsub.add_subscription(self.project_id, self.namespace,
                                     self.channel, FakeClient())

        self.assertTrue(
            self.pubsub.get_subscription_key(self.project_id, self.namespace,
                                             self.channel) in
            self.pubsub.subscriptions)

    def test_remove_subscription(self):
        self.pubsub.remove_subscription(self.project_id, self.namespace,
                                        self.channel, FakeClient())

        self.assertTrue(
            self.pubsub.get_subscription_key(self.project_id, self.namespace,
                                             self.channel) not in
            self.pubsub.subscriptions)