예제 #1
0
    def test_check_existing_dirs_file_added(self, get_mp3_files, listdir,
                                            match, meta):
        files = ["one.mp3", "two.mp3", "three.mp3"]
        get_mp3_files.return_value = files
        listdir.return_value = files

        ids = {
            "/a/directory/audio/subdir/one.mp3": {
                "meta": {
                    "recordingid": self.file1id
                }
            },
            "/a/directory/audio/subdir/two.mp3": {
                "meta": {
                    "recordingid": self.file2id
                }
            }
        }

        def metadata_side(path, *args, **kwargs):
            return ids[path]

        meta.side_effect = metadata_side

        jobs._check_existing_directories(self.collection)
        match.assert_called_once_with(self.collection.collectionid,
                                      "/a/directory/audio/subdir")
예제 #2
0
    def test_check_existing_dirs_file_removed(self, listdir, meta):
        listdir.return_value = ["one.mp3"]
        meta.return_value = {"meta": {"recordingid": self.file1id}}

        self.assertEqual(2, len(self.directory.collectionfile_set.all()))
        jobs._check_existing_directories(self.collection)

        self.assertEqual(1, len(self.directory.collectionfile_set.all()))
예제 #3
0
    def test_check_existing_dirs_file_removed(self, listdir, meta):
        listdir.return_value = ["one.mp3"]
        meta.return_value = {"meta": {"recordingid": self.file1id}}

        self.assertEqual(2, len(self.directory.collectionfile_set.all()))
        jobs._check_existing_directories(self.collection)

        self.assertEqual(1, len(self.directory.collectionfile_set.all()))
예제 #4
0
    def test_check_existing_dirs_file_added(self, listdir, match, meta):
        listdir.return_value = ["one.mp3", "two.mp3", "three.mp3"]
        ids = {"/a/directory/audio/subdir/one.mp3": {"meta": {"recordingid": self.file1id}},
                "/a/directory/audio/subdir/two.mp3": {"meta": {"recordingid": self.file2id}}}
        def metadata_side(path, *args, **kwargs):
            return ids[path]
        meta.side_effect = metadata_side

        jobs._check_existing_directories(self.collection)
        match.assert_called_once_with(self.collection.collectionid, "/a/directory/audio/subdir")
예제 #5
0
    def test_check_existing_dirs_file_changed(self, meta, listdir):
        newuuid = str(uuid.uuid4())
        def metadata_side(path, *args, **kwargs):
            if path == "/a/directory/audio/subdir/one.mp3":
                return {"meta": {"recordingid": self.file1id}}
            elif path == "/a/directory/audio/subdir/two.mp3":
                return {"meta": {"recordingid": newuuid}}
        listdir.return_value = ["one.mp3", "two.mp3"]
        meta.side_effect = metadata_side

        jobs._check_existing_directories(self.collection)

        cf = models.CollectionFile.objects.get(pk=self.file2.pk)
        self.assertEqual(str(cf.recordingid), newuuid)
예제 #6
0
    def test_check_existing_dirs_file_changed(self, meta, listdir):
        newuuid = str(uuid.uuid4())

        def metadata_side(path, *args, **kwargs):
            if path == "/a/directory/audio/subdir/one.mp3":
                return {"meta": {"recordingid": self.file1id}}
            elif path == "/a/directory/audio/subdir/two.mp3":
                return {"meta": {"recordingid": newuuid}}

        listdir.return_value = ["one.mp3", "two.mp3"]
        meta.side_effect = metadata_side

        jobs._check_existing_directories(self.collection)

        cf = models.CollectionFile.objects.get(pk=self.file2.pk)
        self.assertEqual(str(cf.recordingid), newuuid)