-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
88 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,33 @@ | ||
# type: ignore | ||
import os.path | ||
import subprocess | ||
|
||
import pytest | ||
from rattler import ( | ||
solve, | ||
Channel, | ||
ChannelConfig, | ||
fetch_repo_data, | ||
Platform, | ||
solve, | ||
MatchSpec, | ||
RepoDataRecord, | ||
SparseRepoData, | ||
) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def noarch_repo_data() -> None: | ||
port, repo_name = 8812, "test-repo-1" | ||
|
||
test_data_dir = os.path.join( | ||
os.path.dirname(__file__), "../../../test-data/test-server" | ||
) | ||
|
||
with subprocess.Popen( | ||
[ | ||
"python", | ||
os.path.join(test_data_dir, "reposerver.py"), | ||
"-d", | ||
os.path.join(test_data_dir, "repo"), | ||
"-n", | ||
repo_name, | ||
"-p", | ||
str(port), | ||
] | ||
) as proc: | ||
yield port, repo_name | ||
proc.terminate() | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def linux64_repo_data() -> None: | ||
port, repo_name = 8813, "test-repo-2" | ||
|
||
test_data_dir = os.path.join(os.path.dirname(__file__), "../../../test-data/") | ||
|
||
with subprocess.Popen( | ||
[ | ||
"python", | ||
os.path.join(test_data_dir, "test-server/reposerver.py"), | ||
"-d", | ||
os.path.join(test_data_dir, "channels/dummy/"), | ||
"-n", | ||
repo_name, | ||
"-p", | ||
str(port), | ||
] | ||
) as proc: | ||
yield port, repo_name | ||
proc.terminate() | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_solve( | ||
tmp_path, | ||
noarch_repo_data, | ||
linux64_repo_data, | ||
): | ||
noarch_port, noarch_repo = noarch_repo_data | ||
linux64_port, linux64_repo = linux64_repo_data | ||
cache_dir = tmp_path / "test_repo_data_download" | ||
noarch_chan = Channel( | ||
noarch_repo, ChannelConfig(f"http://localhost:{noarch_port}/") | ||
) | ||
plat_noarch = Platform("noarch") | ||
linux64_chan = Channel( | ||
linux64_repo, ChannelConfig(f"http://localhost:{linux64_port}/") | ||
) | ||
plat_linux64 = Platform("linux-64") | ||
|
||
noarch_data = await fetch_repo_data( | ||
channels=[noarch_chan], | ||
platforms=[plat_noarch], | ||
cache_path=cache_dir, | ||
callback=None, | ||
) | ||
|
||
linux64_data = await fetch_repo_data( | ||
channels=[linux64_chan], | ||
platforms=[plat_linux64], | ||
cache_path=cache_dir, | ||
callback=None, | ||
async def test_solve(): | ||
linux64_chan = Channel("conda-forge", ChannelConfig(f"http://localhost:{8813}/")) | ||
data_dir = os.path.join(os.path.dirname(__file__), "../../../test-data/") | ||
linux64_path = os.path.join(data_dir, "channels/conda-forge/linux-64/repodata.json") | ||
linux64_data = SparseRepoData( | ||
channel=linux64_chan, | ||
subdir="linux-64", | ||
path=linux64_path, | ||
) | ||
|
||
available_packages = [(data, noarch_chan) for data in noarch_data] + [ | ||
(data, linux64_chan) for data in linux64_data | ||
] | ||
solved_data = solve( | ||
[MatchSpec("test-package"), MatchSpec("foobar"), MatchSpec("baz")], | ||
available_packages, | ||
[], | ||
[], | ||
[], | ||
[MatchSpec("python"), MatchSpec("sqlite")], | ||
[linux64_data], | ||
) | ||
|
||
assert isinstance(solved_data, list) | ||
assert isinstance(solved_data[0], RepoDataRecord) | ||
assert len(solved_data) == 4 | ||
assert len(solved_data) == 19 |