Beispiel #1
0
    def test_topic_subscription_no_corp_num(self, mock_deliver_hook,
                                            mock_is_reg_valid):
        mock_is_reg_valid.return_value = True

        instance = HookableCredential(topic_status="Topic")

        with self.assertRaises(Exception):
            hook_utils.find_and_fire_hook(self.event_name + "-topic", instance)
Beispiel #2
0
    def test_invalid_subscription(self, mock_is_reg_valid):

        mock_is_reg_valid.return_value = True

        with self.assertRaises(Exception):
            instance = HookableCredential(topic_status="Invalid")

            hook_utils.find_and_fire_hook(self.event_name + "-invalid", instance)
Beispiel #3
0
    def test_topic_subscription_success(self, mock_deliver_hook, mock_is_reg_valid):
        mock_is_reg_valid.return_value = True

        instance = HookableCredential(topic_status="Stream", corp_num="123")

        hook_utils.find_and_fire_hook(self.event_name + "-topic", instance)

        mock_is_reg_valid.assert_called_once_with(self.topichook)

        mock_deliver_hook.assert_called_once_with(self.topichook, instance)
Beispiel #4
0
    def test_stream_subscription_no_cred_type(
        self, mock_deliver_hook, mock_is_reg_valid
    ):
        mock_is_reg_valid.return_value = True

        instance = HookableCredential(topic_status="Stream", corp_num="123")

        hook_utils.find_and_fire_hook(self.event_name + "-stream", instance)

        assert not mock_deliver_hook.called
Beispiel #5
0
    def test_new_subscription_success(self, mock_deliver_hook, mock_is_reg_valid):
        mock_is_reg_valid.return_value = True

        instance = HookableCredential(topic_status="New")

        hook_utils.find_and_fire_hook(self.event_name + "-new", instance)

        mock_is_reg_valid.assert_called_once_with(self.newhook)

        mock_deliver_hook.assert_called_once_with(self.newhook, instance)