Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mamba_gator/envmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,8 @@ def update_packages(packages, pkg_info, tr_channels):
for package in packages:
name = package["name"]
if name in pkg_info:
package["summary"] = pkg_info[name].get("summary", "")
# Prefer description over summary, fall back to summary if description is empty
package["summary"] = pkg_info[name].get("description", "") or pkg_info[name].get("summary", "")
Comment thread
RRosio marked this conversation as resolved.
Comment thread
RRosio marked this conversation as resolved.
package["home"] = pkg_info[name].get("home", "")
# May return None so "or" with empty list
package["keywords"] = pkg_info[name].get("keywords", []) or []
Expand Down
72 changes: 61 additions & 11 deletions mamba_gator/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,24 @@ async def clone_env(conda_fetch, wait_for_task, original_name, new_name):
location = response.headers.get("Location")
return await wait_for_task(location)

def assert_packages_equal(actual_body, expected):
"""
Assert that package list response matches expected,
using substring matching for summary field.
"""
assert len(actual_body["packages"]) == len(expected["packages"]), \
f"Expected {len(expected['packages'])} packages, got {len(actual_body['packages'])}"
assert actual_body["with_description"] == expected["with_description"]

for actual_pkg, expected_pkg in zip(actual_body["packages"], expected["packages"]):
assert expected_pkg["summary"] in actual_pkg["summary"], \
f"Package {actual_pkg['name']}: summary should contain '{expected_pkg['summary']}', got '{actual_pkg['summary']}'"

for key in expected_pkg:
if key != "summary":
assert actual_pkg[key] == expected_pkg[key], \
f"Package {actual_pkg['name']}: mismatch on '{key}'"

# =============================================================================
# TestChannelsHandler
# =============================================================================
Expand Down Expand Up @@ -1163,15 +1181,15 @@ async def test_package_list_available(conda_fetch, wait_for_task):
"name": "numpydoc",
"platform": None,
"version": ["0.9.1", "0.9.0", "0.8.0"],
"summary": "Sphinx extension to support docstrings in Numpy format",
"summary": "Numpy's documentation uses several custom extensions to Sphinx.",
"home": "https://github.com/numpy/numpydoc",
"keywords": [],
"tags": [],
},
],
"with_description": True,
}
assert body == expected
assert_packages_equal(body, expected)


@pytest.mark.skipif(sys.platform.startswith("win"), reason="TODO test not enough reliability")
Expand Down Expand Up @@ -1311,9 +1329,41 @@ async def test_package_list_available_local_channel(conda_fetch, wait_for_task):

with tempfile.TemporaryDirectory() as local_channel:
with open(os.path.join(local_channel, "channeldata.json"), "w+") as d:
d.write(
'{ "channeldata_version": 1, "packages": { "numpydoc": { "activate.d": false, "binary_prefix": false, "deactivate.d": false, "description": "Numpy\'s documentation uses several custom extensions to Sphinx. These are shipped in this numpydoc package, in case you want to make use of them in third-party projects.", "dev_url": "https://github.com/numpy/numpydoc", "doc_source_url": "https://github.com/numpy/numpydoc/blob/master/README.rst", "doc_url": "https://pypi.python.org/pypi/numpydoc", "home": "https://github.com/numpy/numpydoc", "icon_hash": null, "icon_url": null, "identifiers": null, "keywords": null, "license": "BSD 3-Clause", "post_link": false, "pre_link": false, "pre_unlink": false, "recipe_origin": null, "run_exports": {}, "source_git_url": null, "source_url": "https://pypi.io/packages/source/n/numpydoc/numpydoc-0.9.1.tar.gz", "subdirs": [ "linux-32", "linux-64", "linux-ppc64le", "noarch", "osx-64", "win-32", "win-64" ], "summary": "Sphinx extension to support docstrings in Numpy format", "tags": null, "text_prefix": false, "timestamp": 1556032044, "version": "0.9.1" } }, "subdirs": [ "noarch" ] }'
)
channeldata = {
"channeldata_version": 1,
"packages": {
"numpydoc": {
"activate.d": False,
"binary_prefix": False,
"deactivate.d": False,
"description": "Numpy's documentation uses several custom extensions to Sphinx. These are shipped in this numpydoc package, in case you want to make use of them in third-party projects.",
"dev_url": "https://github.com/numpy/numpydoc",
"doc_source_url": "https://github.com/numpy/numpydoc/blob/master/README.rst",
"doc_url": "https://pypi.python.org/pypi/numpydoc",
"home": "https://github.com/numpy/numpydoc",
"icon_hash": None,
"icon_url": None,
"identifiers": None,
"keywords": None,
"license": "BSD 3-Clause",
"post_link": False,
"pre_link": False,
"pre_unlink": False,
"recipe_origin": None,
"run_exports": {},
"source_git_url": None,
"source_url": "https://pypi.io/packages/source/n/numpydoc/numpydoc-0.9.1.tar.gz",
"subdirs": ["linux-32", "linux-64", "linux-ppc64le", "noarch", "osx-64", "win-32", "win-64"],
"summary": "The numpydoc extension provides support for the Numpy docstring format in Sphinx, and adds the code description directives np:function, np-c:function, etc.",
"tags": None,
"text_prefix": False,
"timestamp": 1556032044,
"version": "0.9.1"
}
},
"subdirs": ["noarch"]
}
json.dump(channeldata, d)
local_name = local_channel.strip("/")
channels = {
"channel_alias": {
Expand Down Expand Up @@ -1382,15 +1432,15 @@ async def test_package_list_available_local_channel(conda_fetch, wait_for_task):
"name": "numpydoc",
"platform": None,
"version": ["0.9.1", "0.9.0", "0.8.0"],
"summary": "Sphinx extension to support docstrings in Numpy format",
"summary": "Numpy's documentation uses several custom extensions to Sphinx.",
"home": "https://github.com/numpy/numpydoc",
"keywords": [],
"tags": [],
},
],
"with_description": True,
}
assert body == expected
assert_packages_equal(body, expected)


@pytest.mark.skipif(sys.platform.startswith("win"), reason="not reliable on Windows")
Expand Down Expand Up @@ -1595,7 +1645,7 @@ async def test_package_list_available_no_description(conda_fetch, wait_for_task)
],
"with_description": False,
}
assert body == expected
assert_packages_equal(body, expected)


async def test_package_list_available_caching(conda_fetch, wait_for_task):
Expand Down Expand Up @@ -1798,7 +1848,7 @@ async def test_package_list_available_caching(conda_fetch, wait_for_task):
"name": "numpydoc",
"platform": None,
"version": ["0.9.1", "0.9.0", "0.8.0"],
"summary": "Sphinx extension to support docstrings in Numpy format",
"summary": "Numpy's documentation uses several custom extensions to Sphinx.",
"home": "https://github.com/numpy/numpydoc",
"keywords": [],
"tags": [],
Expand All @@ -1811,13 +1861,13 @@ async def test_package_list_available_caching(conda_fetch, wait_for_task):
assert os.path.exists(cache_file)

with open(cache_file) as cache:
assert json.load(cache) == expected
assert_packages_equal(json.load(cache), expected)

# Retrieve using cache
response = await conda_fetch("packages", method="GET")
assert response.code == 200
body = json.loads(response.body)
assert body == expected
assert_packages_equal(body, expected)


# =============================================================================
Expand Down
13 changes: 8 additions & 5 deletions packages/common/src/components/CondaPkgList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,14 @@ namespace Style {

export const CellSummary = style({
margin: '0px 2px',
alignSelf: 'flex-start',
whiteSpace: 'normal',
height: '100%',
overflow: 'hidden'
});
alignSelf: 'center',
overflow: 'hidden',
display: '-webkit-box',
lineHeight: '1.3',
maxHeight: '2.6em',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical'
Comment thread
RRosio marked this conversation as resolved.
} as NestedCSSProperties);

export const SortButton = style({
transform: 'rotate(180deg)',
Expand Down
Loading