Beispiel #1
0
class TestSoaFileWatcher(unittest.TestCase):
    def setUp(self):
        mock_inbox_q = mock.Mock()
        with mock.patch(
            'paasta_tools.deployd.watchers.pyinotify.WatchManager', autospec=True,
        ), mock.patch(
            'paasta_tools.deployd.watchers.YelpSoaEventHandler', autospec=True,
        ), mock.patch(
            'paasta_tools.deployd.watchers.pyinotify.Notifier', autospec=True,
        ) as mock_notifier_class, mock.patch(
            'paasta_tools.deployd.watchers.SoaFileWatcher.mask', autospec=True,
        ):
            self.mock_notifier = mock.Mock()
            mock_notifier_class.return_value = self.mock_notifier
            self.watcher = SoaFileWatcher(mock_inbox_q, 'westeros-prod', config=mock.Mock())
            assert mock_notifier_class.called

    def test_mask(self):
        with mock.patch(
            'paasta_tools.deployd.watchers.pyinotify.EventsCodes', autospec=True,
        ) as mock_event_codes:
            mock_event_codes.OP_FLAGS = {'UNION_JACK': 1, 'STARS_AND_STRIPES': 2, 'IN_OPEN': 4}
            assert self.watcher.mask == 3

    def test_run(self):
        self.watcher.run()
        self.mock_notifier.loop.assert_called_with(callback=self.watcher.startup_checker)

    def test_startup_checker(self):
        assert not self.watcher.is_ready
        self.watcher.startup_checker(mock.Mock())
        assert self.watcher.is_ready
Beispiel #2
0
 def setUp(self):
     mock_inbox_q = mock.Mock()
     with mock.patch(
         'paasta_tools.deployd.watchers.pyinotify.WatchManager', autospec=True,
     ), mock.patch(
         'paasta_tools.deployd.watchers.YelpSoaEventHandler', autospec=True,
     ), mock.patch(
         'paasta_tools.deployd.watchers.pyinotify.Notifier', autospec=True,
     ) as mock_notifier_class, mock.patch(
         'paasta_tools.deployd.watchers.SoaFileWatcher.mask', autospec=True,
     ):
         self.mock_notifier = mock.Mock()
         mock_notifier_class.return_value = self.mock_notifier
         self.watcher = SoaFileWatcher(mock_inbox_q, 'westeros-prod', config=mock.Mock())
         assert mock_notifier_class.called
Beispiel #3
0
 def setUp(self):
     mock_instances_to_bounce = mock.Mock()
     with mock.patch(
             "paasta_tools.deployd.watchers.pyinotify.WatchManager",
             autospec=True), mock.patch(
                 "paasta_tools.deployd.watchers.YelpSoaEventHandler",
                 autospec=True), mock.patch(
                     "paasta_tools.deployd.watchers.pyinotify.Notifier",
                     autospec=True
                 ) as mock_notifier_class, mock.patch(
                     "paasta_tools.deployd.watchers.SoaFileWatcher.mask",
                     autospec=True):
         self.mock_notifier = mock.Mock()
         mock_notifier_class.return_value = self.mock_notifier
         self.watcher = SoaFileWatcher(mock_instances_to_bounce,
                                       "westeros-prod",
                                       config=mock.Mock())
         assert mock_notifier_class.called
Beispiel #4
0
class TestSoaFileWatcher(unittest.TestCase):
    def setUp(self):
        mock_instances_to_bounce = mock.Mock()
        with mock.patch(
                "paasta_tools.deployd.watchers.pyinotify.WatchManager",
                autospec=True), mock.patch(
                    "paasta_tools.deployd.watchers.YelpSoaEventHandler",
                    autospec=True), mock.patch(
                        "paasta_tools.deployd.watchers.pyinotify.Notifier",
                        autospec=True
                    ) as mock_notifier_class, mock.patch(
                        "paasta_tools.deployd.watchers.SoaFileWatcher.mask",
                        autospec=True):
            self.mock_notifier = mock.Mock()
            mock_notifier_class.return_value = self.mock_notifier
            self.watcher = SoaFileWatcher(mock_instances_to_bounce,
                                          "westeros-prod",
                                          config=mock.Mock())
            assert mock_notifier_class.called

    def test_mask(self):
        with mock.patch("paasta_tools.deployd.watchers.pyinotify.EventsCodes",
                        autospec=True) as mock_event_codes:
            mock_event_codes.OP_FLAGS = {
                "UNION_JACK": 1,
                "STARS_AND_STRIPES": 2,
                "IN_OPEN": 4,
            }
            assert self.watcher.mask == 3

    def test_run(self):
        self.watcher.run()
        self.mock_notifier.loop.assert_called_with(
            callback=self.watcher.startup_checker)

    def test_startup_checker(self):
        assert not self.watcher.is_ready
        self.watcher.startup_checker(mock.Mock())
        assert self.watcher.is_ready