def test_find_repository_id_missing_exception():
    with mock_shed_client() as tsi:
        exception = None
        try:
            shed.find_repository_id(ctx=None, tsi=tsi, path=".", name="test_repo_absent", owner="iuc")
        except Exception as e:
            exception = e
        assert exception is not None
def test_find_repository_id_missing_exception():
    with mock_shed_context() as shed_context:
        exception = None
        try:
            shed.find_repository_id(ctx=None,
                                    shed_context=shed_context,
                                    path=".",
                                    name="test_repo_absent",
                                    owner="iuc")
        except Exception as e:
            exception = e
        assert exception is not None
def test_create_simple():
    with mock_shed_client() as tsi:
        path = os.path.join(TEST_REPOS_DIR, "single_tool")
        repo_config = shed.shed_repo_config(path)
        create_response = shed.create_repository_for(None, tsi, "single_tool", repo_config)
        assert "id" in create_response
        repo_id = shed.find_repository_id(ctx=None, tsi=tsi, path=".", name="single_tool", owner="iuc")
        assert repo_id == create_response["id"]
def test_find_repository_id_missing():
    with mock_shed_context() as shed_context:
        repo_id = shed.find_repository_id(ctx=None,
                                          shed_context=shed_context,
                                          path=".",
                                          name="test_repo_absent",
                                          owner="iuc",
                                          allow_none=True)
        assert repo_id is None
def test_find_repository_id():
    with mock_shed_context() as shed_context:
        repo_id = shed.find_repository_id(
            ctx=None,
            shed_context=shed_context,
            path=".",
            name="test_repo_1",
            owner="iuc",
        )
        assert repo_id == "r1"
Example #6
0
def test_find_repository_id():
    with mock_shed_context() as shed_context:
        repo_id = shed.find_repository_id(
            ctx=None,
            shed_context=shed_context,
            path=".",
            name="test_repo_1",
            owner="iuc",
        )
        assert repo_id == "r1"
def test_find_repository_id():
    with mock_shed_client() as tsi:
        repo_id = shed.find_repository_id(
            ctx=None,
            tsi=tsi,
            path=".",
            name="test_repo_1",
            owner="iuc",
        )
        assert repo_id == "r1"
Example #8
0
def test_find_repository_id_missing():
    with mock_shed_context() as shed_context:
        repo_id = shed.find_repository_id(
            ctx=None,
            shed_context=shed_context,
            path=".",
            name="test_repo_absent",
            owner="iuc",
            allow_none=True
        )
        assert repo_id is None
Example #9
0
def __find_repository(ctx, tsi, path, **kwds):
    """More advanced error handling for finding a repository by ID
    """
    try:
        repo_id = shed.find_repository_id(ctx, tsi, path, **kwds)
        return repo_id
    except Exception as e:
        error("Could not update %s" % path)
        try:
            error(e.read())
        except AttributeError:
            # I've seen a case where the error couldn't be read, so now
            # wrapped in try/except
            error("Could not find repository in toolshed")
    return None
Example #10
0
def test_create_simple():
    with mock_shed_context() as shed_context:
        path = os.path.join(TEST_REPOS_DIR, "single_tool")
        repo_config = shed.shed_repo_config(shed_context, path)
        create_response = shed.create_repository_for(
            None,
            shed_context.tsi,
            "single_tool",
            repo_config,
        )
        assert "id" in create_response
        repo_id = shed.find_repository_id(ctx=None,
                                          shed_context=shed_context,
                                          path=".",
                                          name="single_tool",
                                          owner="iuc")
        assert repo_id == create_response["id"]
Example #11
0
def test_find_repository_id():
    with mock_shed_client() as tsi:
        repo_id = shed.find_repository_id(ctx=None, tsi=tsi, path=".", name="test_repo_1", owner="iuc")
        assert repo_id == "r1"