Exemple #1
0
 def setUp(self):
     self.name = "test_feed"
     self.tracked_entries = Sqlite3TrackedEntries(":memory:")
     self.reader = mock.Mock()
     self.entries = [_make_entry(x) for x in xrange(5)]
     self.reader.get_entries = mock.Mock(return_value=self.entries)
     self.issue_creator = mock.Mock()
     self.binding = Binding(self.name, self.reader, self.issue_creator,
             self.tracked_entries.source_view(self.name))
Exemple #2
0
class TestBinding(unittest.TestCase):
    def setUp(self):
        self.name = "test_feed"
        self.tracked_entries = Sqlite3TrackedEntries(":memory:")
        self.reader = mock.Mock()
        self.entries = [_make_entry(x) for x in xrange(5)]
        self.reader.get_entries = mock.Mock(return_value=self.entries)
        self.issue_creator = mock.Mock()
        self.binding = Binding(self.name, self.reader, self.issue_creator,
                self.tracked_entries.source_view(self.name))

    def test_pump(self):
        # Make sure new issues get created
        self.binding.pump()
        expected_calls = [mock.call(x) for x in self.entries]
        self.issue_creator.create_issue.assert_has_calls(expected_calls)

        self.issue_creator.create_issue.reset_mock()

        # Make sure they don't get created again
        self.binding.pump()
        self.assertFalse(self.issue_creator.create_issue.called)

        # Clear the database and see that now the issues will be recreated
        self.tracked_entries.clear()
        self.binding.pump()
        self.issue_creator.create_issue.assert_has_calls(expected_calls)

    def test_reader_exception_logging(self):
        self.binding.logger.error = mock.Mock()
        self.reader.consecutive_failures = 1
        self.reader.get_entries.side_effect = RuntimeError("boom")
        self.binding.pump()
        expected_matcher = RegexMatcher("1 consecutive fail")
        self.binding.logger.error.assert_called_once_with(expected_matcher)
Exemple #3
0
class TestBinding(unittest.TestCase):
    def setUp(self):
        self.name = "test_feed"
        self.tracked_entries = Sqlite3TrackedEntries(":memory:")
        self.reader = mock.Mock()
        self.entries = [_make_entry(x) for x in xrange(5)]
        self.reader.get_entries = mock.Mock(return_value=self.entries)
        self.issue_creator = mock.Mock()
        self.binding = Binding(self.name, self.reader, self.issue_creator,
                self.tracked_entries.source_view(self.name))

    def test_pump(self):
        # Make sure new issues get created
        self.binding.pump()
        expected_calls = [mock.call(x) for x in self.entries]
        self.issue_creator.create_issue.assert_has_calls(expected_calls)

        self.issue_creator.create_issue.reset_mock()

        # Make sure they don't get created again
        self.binding.pump()
        self.assertFalse(self.issue_creator.create_issue.called)

        # Clear the database and see that now the issues will be recreated
        self.tracked_entries.clear()
        self.binding.pump()
        self.issue_creator.create_issue.assert_has_calls(expected_calls)

    def test_reader_exception_logging(self):
        self.binding.logger.exception = mock.Mock()
        self.reader.consecutive_failures = 1
        self.reader.get_entries.side_effect = RuntimeError("boom")
        self.binding.pump()
        expected_matcher = RegexMatcher("1 consecutive fail")
        self.binding.logger.exception.assert_called_once_with(expected_matcher)
Exemple #4
0
 def setUp(self):
     self.name = "test_feed"
     self.tracked_entries = Sqlite3TrackedEntries(":memory:")
     self.reader = mock.Mock()
     self.entries = [_make_entry(x) for x in xrange(5)]
     self.reader.get_entries = mock.Mock(return_value=self.entries)
     self.issue_creator = mock.Mock()
     self.binding = Binding(self.name, self.reader, self.issue_creator,
             self.tracked_entries.source_view(self.name))