Exemplo n.º 1
0
def test_cli_batch_plugin_googlephotos():
    auth_file = helper.get_file('plugins/googlephotos/auth_file.json')
    secrets_file = helper.get_file('plugins/googlephotos/secrets_file.json')
    config_string = """
    [Plugins]
    plugins=GooglePhotos

    [PluginGooglePhotos]
    auth_file={}
    secrets_file={}
            """
    config_string_fmt = config_string.format(auth_file, secrets_file)
    with open('%s/config.ini-cli-batch-plugin-googlephotos' % gettempdir(),
              'w') as f:
        f.write(config_string_fmt)

    if hasattr(load_config, 'config'):
        del load_config.config

    final_file_path_1 = helper.get_file('plain.jpg')
    final_file_path_2 = helper.get_file('no-exif.jpg')
    sample_metadata_1 = Photo(final_file_path_1).get_metadata()
    sample_metadata_2 = Photo(final_file_path_2).get_metadata()
    gp = GooglePhotos()
    gp.after('', '', final_file_path_1, sample_metadata_1)
    gp.after('', '', final_file_path_2, sample_metadata_1)

    runner = CliRunner()
    result = runner.invoke(elodie._batch)

    if hasattr(load_config, 'config'):
        del load_config.config

    assert "elodie/elodie/tests/files/plain.jpg uploaded successfully.\"}\n" in result.output, result.output
    assert "elodie/elodie/tests/files/no-exif.jpg uploaded successfully.\"}\n" in result.output, result.output
Exemplo n.º 2
0
def test_googlephotos_set_session():
    with open('%s/config.ini-googlephotos-set-session' % gettempdir(), 'w') as f:
        f.write(config_string_fmt)
    if hasattr(load_config, 'config'):
        del load_config.config

    gp = GooglePhotos()

    if hasattr(load_config, 'config'):
        del load_config.config

    assert gp.session is None, gp.session
    gp.set_session()
    assert gp.session is not None, gp.session
Exemplo n.º 3
0
def test_googlephotos_batch():
    with open('%s/config.ini-googlephotos-batch' % gettempdir(), 'w') as f:
        f.write(config_string_fmt)
    if hasattr(load_config, 'config'):
        del load_config.config

    final_file_path = helper.get_file('plain.jpg')
    gp = GooglePhotos()
    gp.after('', '', final_file_path, sample_metadata)
    db_row = gp.db.get(final_file_path)
    assert db_row == 'foobar', db_row

    status, count = gp.batch()
    db_row_after = gp.db.get(final_file_path)
    assert status == True, status
    assert count == 1, count
    assert db_row_after is None, db_row_after


    if hasattr(load_config, 'config'):
        del load_config.config

        
    gp.set_session()
    status = gp.upload(helper.get_file('invalid.jpg'))
    
    assert status is None, status
Exemplo n.º 4
0
def test_googlephotos_upload():
    with open('%s/config.ini-googlephotos-upload' % gettempdir(), 'w') as f:
        f.write(config_string_fmt)
    if hasattr(load_config, 'config'):
        del load_config.config

    gp = GooglePhotos()

    if hasattr(load_config, 'config'):
        del load_config.config

    gp.set_session()
    status = gp.upload(helper.get_file('plain.jpg'))
    
    assert status is not None, status
Exemplo n.º 5
0
def test_googlephotos_after_supported():
    with open('%s/config.ini-googlephotos-after-supported' % gettempdir(), 'w') as f:
        f.write(config_string_fmt)
    if hasattr(load_config, 'config'):
        del load_config.config

    final_file_path = helper.get_file('plain.jpg')
    gp = GooglePhotos()
    gp.after('', '', final_file_path, sample_metadata)
    db_row = gp.db.get(final_file_path)

    if hasattr(load_config, 'config'):
        del load_config.config

    assert db_row == 'foobar', db_row
Exemplo n.º 6
0
def test_googlephotos_upload_dne():
    with open('%s/config.ini-googlephotos-upload-dne' % gettempdir(), 'w') as f:
        f.write(config_string_fmt)
    if hasattr(load_config, 'config'):
        del load_config.config

    gp = GooglePhotos()

    if hasattr(load_config, 'config'):
        del load_config.config

    gp.set_session()
    status = gp.upload('/file/does/not/exist')
    
    assert status is None, status
Exemplo n.º 7
0
def test_googlephotos_after_unsupported():
    with open('%s/config.ini-googlephotos-after-unsupported' % gettempdir(), 'w') as f:
        f.write(config_string_fmt)
    if hasattr(load_config, 'config'):
        del load_config.config

    final_file_path = helper.get_file('audio.m4a')
    sample_photo = Audio(final_file_path)
    sample_metadata = sample_photo.get_metadata()
    sample_metadata['original_name'] = 'foobar'
    gp = GooglePhotos()
    gp.after('', '', final_file_path, sample_metadata)
    db_row = gp.db.get(final_file_path)

    if hasattr(load_config, 'config'):
        del load_config.config

    assert db_row == None, db_row