def test_delete_watched_dir(self):
        SLEEP_TIME = 0.4
        self.emitter.start()
        rm(p(''), recursive=True)
        sleep(SLEEP_TIME)
        self.emitter.stop()

        # What we need here for the tests to pass is a collection type
        # that is:
        #   * unordered
        #   * non-unique
        # A multiset! Python's collections.Counter class seems appropriate.
        expected = set([
            DirDeletedEvent(os.path.dirname(p(''))),
        ])

        got = set()
        while True:
            try:
                event, _ = self.event_queue.get_nowait()
                got.add(event)
            except queue.Empty:
                break

        self.assertEqual(expected, got)
    def test_delete_watched_dir(self):
        SLEEP_TIME = 0.4
        self.emitter.start()
        rm(p(''), recursive=True)
        sleep(SLEEP_TIME)
        self.emitter.stop()

        # What we need here for the tests to pass is a collection type
        # that is:
        #   * unordered
        #   * non-unique
        # A multiset! Python's collections.Counter class seems appropriate.
        expected = set(
            [

                DirDeletedEvent(os.path.dirname(p(''))),
            ]
        )

        got = set()
        while True:
            try:
                event, _ = self.event_queue.get_nowait()
                got.add(event)
            except queue.Empty:
                break

        self.assertEqual(expected, got)
Пример #3
0
    def test___init__(self):
        SLEEP_TIME = 0.4
        self.emitter.start()
        sleep(SLEEP_TIME)
        mkdir(p('project'))
        sleep(SLEEP_TIME)
        mkdir(p('project', 'blah'))
        sleep(SLEEP_TIME)
        touch(p('afile'))
        sleep(SLEEP_TIME)
        touch(p('fromfile'))
        sleep(SLEEP_TIME)
        mv(p('fromfile'), p('project', 'tofile'))
        sleep(SLEEP_TIME)
        touch(p('afile'))
        sleep(SLEEP_TIME)
        mv(p('project', 'blah'), p('project', 'boo'))
        sleep(SLEEP_TIME)
        rm(p('project'), recursive=True)
        sleep(SLEEP_TIME)
        rm(p('afile'))
        sleep(SLEEP_TIME)
        self.emitter.stop()

        # What we need here for the tests to pass is a collection type
        # that is:
        #   * unordered
        #   * non-unique
        # A multiset! Python's collections.Counter class seems appropriate.
        expected = set([
            DirModifiedEvent(p()),
            DirCreatedEvent(p('project')),
            DirModifiedEvent(p('project')),
            DirCreatedEvent(p('project', 'blah')),
            FileCreatedEvent(p('afile')),
            DirModifiedEvent(p()),
            FileCreatedEvent(p('fromfile')),
            DirModifiedEvent(p()),
            DirModifiedEvent(p()),
            FileMovedEvent(p('fromfile'), p('project', 'tofile')),
            FileModifiedEvent(p('afile')),
            DirModifiedEvent(p('project')),
            DirMovedEvent(p('project', 'blah'), p('project', 'boo')),
            DirModifiedEvent(p()),
            FileDeletedEvent(p('project', 'boo')),
            DirDeletedEvent(p('project', 'boo')),
            DirDeletedEvent(p('project')),
            DirModifiedEvent(p()),
            FileDeletedEvent(p('afile')),
        ])
        got = set()

        while True:
            try:
                event, _ = self.event_queue.get_nowait()
                got.add(event)
            except queue.Empty:
                break

        assert_equal(expected, got)
 def tearDown(self):
     global temp_dir
     rm(temp_dir, True)
     pass
    def test___init__(self):
        SLEEP_TIME = 0.4
        self.emitter.start()
        sleep(SLEEP_TIME)
        mkdir(p('project'))
        sleep(SLEEP_TIME)
        mkdir(p('project', 'blah'))
        sleep(SLEEP_TIME)
        touch(p('afile'))
        sleep(SLEEP_TIME)
        touch(p('fromfile'))
        sleep(SLEEP_TIME)
        mv(p('fromfile'), p('project', 'tofile'))
        sleep(SLEEP_TIME)
        touch(p('afile'))
        sleep(SLEEP_TIME)
        mv(p('project', 'blah'), p('project', 'boo'))
        sleep(SLEEP_TIME)
        rm(p('project'), recursive=True)
        sleep(SLEEP_TIME)
        rm(p('afile'))
        sleep(SLEEP_TIME)
        self.emitter.stop()

        # What we need here for the tests to pass is a collection type
        # that is:
        #   * unordered
        #   * non-unique
        # A multiset! Python's collections.Counter class seems appropriate.
        expected = set([
            DirModifiedEvent(p()),
            DirCreatedEvent(p('project')),

            DirModifiedEvent(p('project')),
            DirCreatedEvent(p('project', 'blah')),

            FileCreatedEvent(p('afile')),
            DirModifiedEvent(p()),

            FileCreatedEvent(p('fromfile')),
            DirModifiedEvent(p()),

            DirModifiedEvent(p()),
            FileMovedEvent(p('fromfile'), p('project', 'tofile')),

            FileModifiedEvent(p('afile')),

            DirModifiedEvent(p('project')),
            DirMovedEvent(p('project', 'blah'), p('project', 'boo')),

            DirModifiedEvent(p()),
            FileDeletedEvent(p('project', 'boo')),
            DirDeletedEvent(p('project', 'boo')),
            DirDeletedEvent(p('project')),

            DirModifiedEvent(p()),
            FileDeletedEvent(p('afile')),

        ])
        got = set()

        while True:
            try:
                event, _ = self.event_queue.get_nowait()
                got.add(event)
            except queue.Empty:
                break

        self.assertEqual(expected, got)
    def test___init__(self):
        SLEEP_TIME = 0.4
        self.emitter.start()
        sleep(SLEEP_TIME)
        mkdir(p('project'))
        sleep(SLEEP_TIME)
        mkdir(p('project', 'blah'))
        sleep(SLEEP_TIME)
        touch(p('afile'))
        sleep(SLEEP_TIME)
        touch(p('fromfile'))
        sleep(SLEEP_TIME)
        mv(p('fromfile'), p('project', 'tofile'))
        sleep(SLEEP_TIME)
        touch(p('afile'))
        sleep(SLEEP_TIME)
        mv(p('project', 'blah'), p('project', 'boo'))
        sleep(SLEEP_TIME)
        rm(p('project'), recursive=True)
        sleep(SLEEP_TIME)
        rm(p('afile'))
        sleep(SLEEP_TIME)
        self.emitter.stop()

        # What we need here for the tests to pass is a collection type
        # that is:
        #   * unordered
        #   * non-unique
        # A multiset! Python's collections.Counter class seems appropriate.
        expected = set(
            [
                DirModifiedEvent(p()),
                DirCreatedEvent(p('project')),

                DirModifiedEvent(p('project')),
                DirCreatedEvent(p('project', 'blah')),

                FileCreatedEvent(p('afile')),
                DirModifiedEvent(p()),

                FileCreatedEvent(p('fromfile')),
                DirModifiedEvent(p()),

                DirModifiedEvent(p()),
                FileModifiedEvent(p('afile')),

                DirModifiedEvent(p('project')),

                DirModifiedEvent(p()),
                FileDeletedEvent(p('project', 'tofile')),
                DirDeletedEvent(p('project', 'boo')),
                DirDeletedEvent(p('project')),

                DirModifiedEvent(p()),
                FileDeletedEvent(p('afile')),
            ]
        )

        if sys.platform.startswith("win"):
            # On Windows depending on circumstances, a rename may turn into a Delete/Create
            expected.add(FileDeletedEvent(p('fromfile')))
            expected.add(FileCreatedEvent(p('project', 'tofile')))
            expected.add(DirCreatedEvent(p('project', 'boo')))
            expected.add(DirDeletedEvent(p('project', 'blah')))
        else:
            expected.add(FileMovedEvent(p('fromfile'), p('project', 'tofile')))
            expected.add(DirMovedEvent(p('project', 'blah'), p('project', 'boo')))

        got = set()
        while True:
            try:
                event, _ = self.event_queue.get_nowait()
                got.add(event)
            except queue.Empty:
                break

        self.assertEqual(expected, got)
Пример #7
0
    def test___init__(self):
        SLEEP_TIME = 0.4
        self.emitter.start()
        sleep(SLEEP_TIME)
        mkdir(p('project'))
        sleep(SLEEP_TIME)
        mkdir(p('project', 'blah'))
        sleep(SLEEP_TIME)
        touch(p('afile'))
        sleep(SLEEP_TIME)
        touch(p('fromfile'))
        sleep(SLEEP_TIME)
        mv(p('fromfile'), p('project', 'tofile'))
        sleep(SLEEP_TIME)
        touch(p('afile'))
        sleep(SLEEP_TIME)
        mv(p('project', 'blah'), p('project', 'boo'))
        sleep(SLEEP_TIME)
        rm(p('project'), recursive=True)
        sleep(SLEEP_TIME)
        rm(p('afile'))
        sleep(SLEEP_TIME)
        self.emitter.stop()

        # What we need here for the tests to pass is a collection type
        # that is:
        #   * unordered
        #   * non-unique
        # A multiset! Python's collections.Counter class seems appropriate.
        expected = set([
            DirModifiedEvent(p()),
            DirCreatedEvent(p('project')),
            DirModifiedEvent(p('project')),
            DirCreatedEvent(p('project', 'blah')),
            FileCreatedEvent(p('afile')),
            DirModifiedEvent(p()),
            FileCreatedEvent(p('fromfile')),
            DirModifiedEvent(p()),
            DirModifiedEvent(p()),
            FileModifiedEvent(p('afile')),
            DirModifiedEvent(p('project')),
            DirModifiedEvent(p()),
            FileDeletedEvent(p('project', 'tofile')),
            DirDeletedEvent(p('project', 'boo')),
            DirDeletedEvent(p('project')),
            DirModifiedEvent(p()),
            FileDeletedEvent(p('afile')),
        ])

        if sys.platform.startswith("win"):
            # On Windows depending on circumstances, a rename may turn into a Delete/Create
            expected.add(FileDeletedEvent(p('fromfile')))
            expected.add(FileCreatedEvent(p('project', 'tofile')))
            expected.add(DirCreatedEvent(p('project', 'boo')))
            expected.add(DirDeletedEvent(p('project', 'blah')))
        else:
            expected.add(FileMovedEvent(p('fromfile'), p('project', 'tofile')))
            expected.add(
                DirMovedEvent(p('project', 'blah'), p('project', 'boo')))

        got = set()
        while True:
            try:
                event, _ = self.event_queue.get_nowait()
                got.add(event)
            except queue.Empty:
                break

        self.assertEqual(expected, got)
 def tearDown(self):
     global temp_dir
     rm(temp_dir, True)
     pass
Пример #9
0
 def finalizer():
     shell.rm(path, recursive=True)