示例#1
0
    def test_base_media(self):
        b = BaseMedia()

        with pytest.raises(NotImplementedError):
            x = b.size

        with pytest.raises(NotImplementedError):
            x = b.id

        with pytest.raises(NotImplementedError):
            x = b.description

        with pytest.raises(NotImplementedError):
            x = b.orig_name

        with pytest.raises(NotImplementedError):
            x = b.create_date

        with pytest.raises(NotImplementedError):
            x = b.modify_date

        with pytest.raises(NotImplementedError):
            x = b.mime_type

        with pytest.raises(NotImplementedError):
            x = b.url

        with patch('gphotos.BaseMedia.os_name',
                   new_callable=PropertyMock(return_value='nt')):
            assert b.validate_encoding('hello.txt') == 'hello.txt'
        """Download archived images in test library using flat folders (and
        windows file name restrictions)
        """
        s = ts.SetupDbAndCredentials()
        args = [
            '--archived', '--skip-albums', '--start-date', '2019-10-01',
            '--use-flat-path'
        ]
        s.test_setup('test_base_media',
                     args=args,
                     trash_files=True,
                     trash_db=True)
        s.gp.start(s.parsed_args)

        db = LocalData(s.root)

        # Total of 1 out of media items
        db.cur.execute("SELECT COUNT() FROM SyncFiles")
        count = db.cur.fetchone()
        self.assertEqual(1, count[0])

        pat = str(photos_root / '2019-11' / '*.*')
        files = sorted(s.root.glob(pat))
        self.assertEqual(1, len(files))
示例#2
0
    def test_base_media(self):
        """Download archived images in test library using flat folders (and
        windows file name restrictions)
        """
        b = BaseMedia()

        with pytest.raises(NotImplementedError):
            x = b.size

        with pytest.raises(NotImplementedError):
            x = b.id

        with pytest.raises(NotImplementedError):
            x = b.description

        with pytest.raises(NotImplementedError):
            x = b.orig_name

        with pytest.raises(NotImplementedError):
            x = b.create_date

        with pytest.raises(NotImplementedError):
            x = b.modify_date

        with pytest.raises(NotImplementedError):
            x = b.mime_type

        with pytest.raises(NotImplementedError):
            x = b.url
            print(x)  # for pylint

        s = ts.SetupDbAndCredentials()
        args = [
            "--skip-albums",
            "--start-date",
            "2020-01-01",
            "--use-flat-path",
        ]
        s.test_setup("test_base_media",
                     args=args,
                     trash_files=True,
                     trash_db=True)
        s.gp.start(s.parsed_args)

        db = LocalData(s.root)

        # Total of 1 out of media items
        db.cur.execute("SELECT COUNT() FROM SyncFiles")
        count = db.cur.fetchone()
        self.assertEqual(1, count[0])

        pat = str(photos_root / "2020-04" / "*.*")
        files = sorted(s.root.glob(pat))
        self.assertEqual(1, len(files))
示例#3
0
    def test_db_row(self):
        d = DbRow(None)
        b = BaseMedia()

        with pytest.raises(NotImplementedError):
            x = d.to_media()

        with pytest.raises(NotImplementedError):
            x = d.from_media(b)

        with pytest.raises(ValueError):
            x = d.make(bad_column=1)

        if d:
            assert False, "empty DBRow returns true as Bool"