コード例 #1
0
 def test_channel_filters(self):
     """
     Tests that the include/exclude logic works
     """
     # Include
     worker = Worker(None, only_channels=["yes.*", "maybe.*"])
     self.assertEqual(
         worker.apply_channel_filters(["yes.1", "no.1"]),
         ["yes.1"],
     )
     self.assertEqual(
         worker.apply_channel_filters(["yes.1", "no.1", "maybe.2", "yes"]),
         ["yes.1", "maybe.2"],
     )
     # Exclude
     worker = Worker(None, exclude_channels=["no.*", "maybe.*"])
     self.assertEqual(
         worker.apply_channel_filters(["yes.1", "no.1", "maybe.2", "yes"]),
         ["yes.1", "yes"],
     )
     # Both
     worker = Worker(None, exclude_channels=["no.*"], only_channels=["yes.*"])
     self.assertEqual(
         worker.apply_channel_filters(["yes.1", "no.1", "maybe.2", "yes"]),
         ["yes.1"],
     )