def test_add_watches_to_udf_ancestors(self):
        """Test that the ancestor watches are not added."""

        class FakeVolume(object):
            """A fake UDF."""

            def __init__(self, ancestors):
                """Create a new instance."""
                self.ancestors = ancestors

        ancestors = ['~', '~\\Pictures', '~\\Pictures\\Home', ]
        volume = FakeVolume(ancestors)
        monitor = FilesystemMonitor(None, None)
        added = yield monitor.add_watches_to_udf_ancestors(volume)
        self.assertTrue(added, 'We should always return true.')
        # lets ensure that we never added the watches
        self.assertEqual(0, len(monitor._watch_manager._wdm.values()),
                         'No watches should have been added.')
    def test_add_watch_twice(self):
        """Check the deferred returned by a second add_watch."""
        self.patch(Watch, "start_watching", lambda self: self.started)
        monitor = FilesystemMonitor(None, None)
        # no need to stop watching because start_watching is fake

        parent_path = 'C:\\test'  # a valid windows path in utf-8 bytes
        child_path = parent_path + "\\child"
        d1 = monitor.add_watch(parent_path)
        d2 = monitor.add_watch(child_path)

        self.assertFalse(d1.called, "Should not be called yet.")
        self.assertFalse(d2.called, "Should not be called yet.")

        monitor._watch_manager._wdm.values()[0].started.callback(True)

        self.assertTrue(d1.called, "Should already be called.")
        self.assertTrue(d2.called, "Should already be called.")