-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #218 from jeremycline/configurable-topics
Make the topic the FMN consumer subscribes to configurable
- Loading branch information
Showing
3 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of FMN. | ||
# Copyright (C) 2017 Red Hat, Inc. | ||
# | ||
# This library is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2.1 of the License, or (at your option) any later version. | ||
# | ||
# This library is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this library; if not, write to the Free Software | ||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
"""Tests for the :mod:`fmn.consumer.consumer` module""" | ||
from __future__ import absolute_import | ||
|
||
import unittest | ||
|
||
import mock | ||
|
||
from fmn.consumer import consumer | ||
|
||
|
||
class FMNConsumerTests(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.config = { | ||
'fmn.consumer.enabled': True, | ||
'validate_signatures': False, | ||
'fmn.sqlalchemy.uri': 'sqlite://', | ||
} | ||
self.hub = mock.Mock(config=self.config) | ||
|
||
def test_default_topic(self): | ||
"""Assert the default topic for the FMN consumer is everything.""" | ||
fmn_consumer = consumer.FMNConsumer(self.hub) | ||
|
||
self.assertEqual(b'*', fmn_consumer.topic) | ||
self.hub.subscribe.assert_called_once_with(b'*', fmn_consumer._consume_json) | ||
|
||
def test_custom_topics(self): | ||
"""Assert the default topic for the FMN consumer is everything.""" | ||
self.config['fmn.topics'] = [b'my.custom.topic'] | ||
fmn_consumer = consumer.FMNConsumer(self.hub) | ||
|
||
self.assertEqual([b'my.custom.topic'], fmn_consumer.topic) | ||
self.hub.subscribe.assert_called_once_with(b'my.custom.topic', fmn_consumer._consume_json) |