예제 #1
0
    def test_timeline_organize_pictures(self):
        _, inbox_path = resources.copytree()
        timeline = TimeLine(inbox_path)

        timeline.organize()

        for name, file_details in resources.files.iteritems():
            file_path = os.path.join(inbox_path, file_details['expected_path'])
            assert_that(
                os.path.exists(file_path),
                is_(True),
                'File is missing: {} -> {}'.format(name, file_path))
            assert_that(
                resources.md5sum(file_path),
                is_(file_details['md5sum']),
                'wrong md5sum for {} at {}'.format(name, file_path)
            )
예제 #2
0
    def test_main_linking(self):
        repo_path, inbox_path = resources.copytree()
        timeline_path = os.path.join(repo_path, 'timeline')
        album_path = os.path.join(repo_path, 'album')

        os.chdir(repo_path)
        cmd.main([
            '--inbox', inbox_path,
            '--calendar', 'https://raw.githubusercontent.com/JoProvost/calbum/master/tests/resources/calendar.ics',
            '--save-events',
            '--link-only',
        ])

        timeline = MediaCollection(timeline_path)
        pictures = list(timeline)

        assert_that(len(pictures), is_(len(resources.files)))

        for name, file_details in resources.files.iteritems():
            file_path = os.path.join(
                timeline_path, file_details['expected_path'])
            assert_that(
                os.path.exists(file_path),
                is_(True),
                'File is missing: {} -> {}'.format(name, file_path))
            assert_that(
                resources.md5sum(file_path),
                is_(file_details['md5sum']),
                'wrong md5sum for {} at {}'.format(name, file_path)
            )

            if file_details['event_name']:
                file_path = os.path.join(
                    album_path, file_details['event_name'],
                    file_details['expected_path'])
                assert_that(
                    resources.md5sum(file_path),
                    is_(file_details['md5sum']),
                    'wrong md5sum for {} at {}'.format(name, file_path)
                )

            assert_that(
                os.path.exists(os.path.join(inbox_path, name)),
                is_(True),
                'File is absent from inbox: {}'.format(name))