How to use the foremast.utils.FileLookup function in foremast

To help you get started, we’ve selected a few foremast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github foremast / foremast / tests / utils / test_file_lookups.py View on Github external
def test_init(gitlab):
    """Check init."""
    my_git = FileLookup()
    assert my_git.git_short == ''
    assert my_git.server == gitlab.Gitlab.return_value
    my_git.server.projects.get.assert_called_with(my_git.git_short)
github foremast / foremast / tests / utils / test_file_lookups.py View on Github external
def test_json(gitlab, mock_lookup):
    """Check _json_ method."""
    my_git = FileLookup()

    result = my_git.json()
    assert isinstance(result, dict)
    assert result['ship'] == 'pirate'
github foremast / foremast / tests / utils / test_file_lookups.py View on Github external
def test_runway_get(gitlab, tmpdir):
    """Make sure Git is not called when runway is specified."""
    filename = 'test.json'

    tmpdir.join(filename).write(TEST_JSON)

    my_git = FileLookup(runway_dir=str(tmpdir))
    result = my_git.get(filename=filename)

    assert isinstance(result, str)
    assert result == TEST_JSON

    with pytest.raises(FileNotFoundError):
        my_git.get(filename='parrot')
github foremast / foremast / tests / utils / test_file_lookups.py View on Github external
def test_invalid_json(gitlab, mock_lookup):
    """Check invalid JSON."""
    my_git = FileLookup()

    with pytest.raises(SystemExit):
        my_git.json()
github foremast / foremast / tests / utils / test_file_lookups.py View on Github external
def test_project_success(mock_gitlab):
    """Check resolving GitLab Project ID is successful."""
    mock_gitlab.Gitlab.return_value.projects.get.return_value = object
    seeker = FileLookup()
    assert seeker.project is object
github foremast / foremast / tests / utils / test_file_lookups.py View on Github external
def test_filelookup_attr():
    """Make sure Git related attributes are missing when runway is specified."""
    my_git = FileLookup(runway_dir='/poop_deck')

    assert my_git.git_short == ''
    assert my_git.server is None
github foremast / foremast / tests / utils / test_file_lookups.py View on Github external
def test_get(gitlab, mock_lookup):
    """Check _get_ method."""
    my_git = FileLookup()

    result = my_git.get()
    assert isinstance(result, str)
    assert TEST_JSON == my_git.get()
github foremast / foremast / tests / utils / test_file_lookups.py View on Github external
def test_project_exception(mock_gitlab):
    """Check resolving GitLab Project ID fails with exception."""
    mock_gitlab.Gitlab.return_value.projects.get.return_value = False

    with pytest.raises(GitLabApiError):
        FileLookup()