Skip to content

Commit

Permalink
dont assume subdir and move test
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmartian committed Apr 15, 2020
1 parent 3cad66a commit b517b67
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion conda/models/match_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def from_dist_str(cls, dist_str):
channel_str, subdir = channel_subdir_str.rsplit('/', 1)
if subdir not in context.known_subdirs:
channel_str = channel_subdir_str
subdir = context.subdir
subdir = None
parts.update({
'channel': channel_str,
'subdir': subdir,
Expand Down
47 changes: 29 additions & 18 deletions tests/models/test_match_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,35 @@ def test_parse_build_number_brackets(self):
# "build_number": '>=3',
# }

def test_dist_str(self):
m1 = MatchSpec.from_dist_str("anaconda/{0}::python-3.6.6-0.tar.bz2".format(context.subdir))
m2 = MatchSpec.from_dist_str("anaconda/{0}::python-3.6.6-0".format(context.subdir))
m3 = MatchSpec.from_dist_str("https://someurl.org/anaconda/{0}::python-3.6.6-0.tar.bz2".format(context.subdir))
m4 = MatchSpec.from_dist_str("python-3.6.6-0.tar.bz2")
m5 = MatchSpec.from_dist_str("https://someurl.org/anaconda::python-3.6.6-0.tar.bz2")

pref = DPkg("anaconda::python-3.6.6-0.tar.bz2")
pref.url = "https://someurl.org/anaconda/{}".format(context.subdir)

assert m1.match(pref)
assert m2.match(pref)
assert m3.match(pref)
assert m4.match(pref)
pref.url = "https://someurl.org/anaconda"

pref_dict = {
'name': 'python',
'version': '3.6.6',
'build': '0',
'build_number': 0,
'channel': Channel("anaconda"),
'fn': 'python-3.6.6-0.tar.bz2',
'md5': '012345789',
'url': 'https://someurl.org/anaconda'
}

assert m5.match(pref_dict)


class MatchSpecMergeTests(TestCase):

Expand Down Expand Up @@ -964,21 +993,3 @@ def test_md5_merge_wo_name(self):
assert str(merged[0]) in str_specs
assert str(merged[1]) in str_specs
assert str(merged[0]) != str(merged[1])


def test_dist_str(self):
m1 = MatchSpec.from_dist_str("anaconda/{0}::python-3.6.6-0.tar.bz2".format(context.subdir))
m2 = MatchSpec.from_dist_str("anaconda/{0}::python-3.6.6-0".format(context.subdir))
m3 = MatchSpec.from_dist_str("https://someurl.org/anaconda/{0}::python-3.6.6-0.tar.bz2".format(context.subdir))
m4 = MatchSpec.from_dist_str("python-3.6.6-0.tar.bz2")
m5 = MatchSpec.from_dist_str("https://someurl.org/anaconda::python-3.6.6-0.tar.bz2")

pref = DPkg("anaconda::python-3.6.6-0.tar.bz2")
pref.url = "https://someurl.org/anaconda/{}".format(context.subdir)

assert m1.match(pref)
assert m2.match(pref)
assert m3.match(pref)
assert m4.match(pref)
pref.url = "https://someurl.org/anaconda"
assert m5.match(pref)

0 comments on commit b517b67

Please sign in to comment.