Пример #1
0
def test_default_importer_returns_false_when_bad_file(mocker):
    mockopen = mocker.patch('passpie.importers.default_importer.open',
                            mock_open(),
                            create=True)()
    mockopen.read.side_effect = OSError

    result = DefaultImporter().match('filepath')
    assert result is False
Пример #2
0
def test_default_importer_match_returns_false_when_bad_yaml(mocker):
    mocker.patch('passpie.importers.default_importer.open',
                 mock_open(),
                 create=True)
    mocker.patch('passpie.importers.default_importer.yaml.load',
                 side_effect=[yaml.scanner.ScannerError])

    result = DefaultImporter().match('filepath')
    assert result is False
Пример #3
0
def test_default_importer_returns_loaded_credentials_from_yaml_file(mocker):
    dict_content = {'credentials': {'name': 'foo', 'name': 'bar'}}
    mocker.patch('passpie.importers.default_importer.open',
                 mock_open(),
                 create=True)
    mocker.patch('passpie.importers.default_importer.yaml.load',
                 return_value=dict_content)

    result = DefaultImporter().handle('filepath')
    assert result is dict_content.get('credentials')
Пример #4
0
def test_default_importer_returns_false_when_version_keys_isnt_float(mocker):
    dict_content = {'version': '1.0'}
    mocker.patch('passpie.importers.default_importer.open',
                 mock_open(),
                 create=True)
    mocker.patch('passpie.importers.default_importer.yaml.load',
                 return_value=dict_content)

    result = DefaultImporter().match('filepath')
    assert result is False
Пример #5
0
def test_default_importer_match_passpie_exported_yaml(mocker):
    dict_content = {'handler': 'passpie', 'version': 1.0}
    mocker.patch('passpie.importers.default_importer.open',
                 mock_open(),
                 create=True)
    mocker.patch('passpie.importers.default_importer.yaml.load',
                 return_value=dict_content)

    result = DefaultImporter().match('filepath')
    assert result is True