def test_default_channels(self): channel = Channel('defaults') assert channel.canonical_name == "defaults" assert channel.location is None assert channel.url() is None assert channel.url(True) is None assert channel.urls() == [ "http://192.168.0.15:8080/pkgs/anaconda/%s" % self.platform, "http://192.168.0.15:8080/pkgs/anaconda/noarch", "ftp://new.url:8082/donald/label/main/%s" % self.platform, "ftp://new.url:8082/donald/label/main/noarch", "http://192.168.0.15:8080/pkgs/r/%s" % self.platform, "http://192.168.0.15:8080/pkgs/r/noarch", ] assert channel.urls(True) == [ "http://192.168.0.15:8080/pkgs/anaconda/%s" % self.platform, "http://192.168.0.15:8080/pkgs/anaconda/noarch", "ftp://*****:*****@new.url:8082/t/zyx-wvut/donald/label/main/%s" % self.platform, "ftp://*****:*****@new.url:8082/t/zyx-wvut/donald/label/main/noarch", "http://*****:*****@192.168.0.15:8080/t/tkn-123/pkgs/r/%s" % self.platform, "http://*****:*****@192.168.0.15:8080/t/tkn-123/pkgs/r/noarch", ] channel = Channel("ftp://new.url:8082/donald/label/main") assert channel.canonical_name == "defaults" channel = Channel("donald/label/main") assert channel.canonical_name == "defaults" channel = Channel("ftp://new.url:8081/donald") assert channel.location == "new.url:8081" assert channel.canonical_name == "donald"
def test_named_custom_channel(self): channel = Channel("chuck") assert channel.canonical_name == "chuck" assert channel.location == "another.url:8080/with/path" assert channel.url() == "http://another.url:8080/with/path/chuck/%s" % self.platform assert channel.url(True) == "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/%s" % self.platform assert channel.urls() == [ "http://another.url:8080/with/path/chuck/%s" % self.platform, "http://another.url:8080/with/path/chuck/noarch", ] assert channel.urls(True) == [ "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/%s" % self.platform, "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/noarch", ] channel = Channel("chuck/label/dev") assert channel.canonical_name == "chuck/label/dev" assert channel.location == "another.url:8080/with/path" assert channel.url() == "http://another.url:8080/with/path/chuck/label/dev/%s" % self.platform assert channel.url(True) == "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/label/dev/%s" % self.platform assert channel.urls() == [ "http://another.url:8080/with/path/chuck/label/dev/%s" % self.platform, "http://another.url:8080/with/path/chuck/label/dev/noarch", ] assert channel.urls(True) == [ "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/label/dev/%s" % self.platform, "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/label/dev/noarch", ]
def test_named_custom_channel_w_subchan(self): channel = Channel("chuck/subchan") assert channel.canonical_name == "chuck/subchan" assert channel.location == "another.url:8080/with/path" assert channel.url() == "http://another.url:8080/with/path/chuck/subchan/%s" % self.platform assert channel.url( True) == "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/%s" % self.platform assert channel.urls() == [ "http://another.url:8080/with/path/chuck/subchan/%s" % self.platform, "http://another.url:8080/with/path/chuck/subchan/noarch", ] assert channel.urls(True) == [ "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/%s" % self.platform, "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/noarch", ] channel = Channel("chuck/subchan/label/main") assert channel.canonical_name == "chuck/subchan/label/main" assert channel.location == "another.url:8080/with/path" assert channel.url() == "http://another.url:8080/with/path/chuck/subchan/label/main/%s" % self.platform assert channel.url( True) == "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/label/main/%s" % self.platform assert channel.urls() == [ "http://another.url:8080/with/path/chuck/subchan/label/main/%s" % self.platform, "http://another.url:8080/with/path/chuck/subchan/label/main/noarch", ] assert channel.urls(True) == [ "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/label/main/%s" % self.platform, "http://*****:*****@another.url:8080/with/path/t/tk-1234/chuck/subchan/label/main/noarch", ]
def test_url_custom_channel(self): # scheme and credentials within url should override what's registered in config channel = Channel("https://*****:*****@another.url:8080/with/path/t/new-token/chuck/label/dev") assert channel.canonical_name == "chuck/label/dev" assert channel.location == "another.url:8080/with/path" assert channel.url() == "https://another.url:8080/with/path/chuck/label/dev/%s" % self.platform assert channel.url(True) == "https://*****:*****@another.url:8080/with/path/t/new-token/chuck/label/dev/%s" % self.platform assert channel.urls() == [ "https://another.url:8080/with/path/chuck/label/dev/%s" % self.platform, "https://another.url:8080/with/path/chuck/label/dev/noarch", ] assert channel.urls(True) == [ "https://*****:*****@another.url:8080/with/path/t/new-token/chuck/label/dev/%s" % self.platform, "https://*****:*****@another.url:8080/with/path/t/new-token/chuck/label/dev/noarch", ]
def test_old_channel_alias(self): cf_urls = [ "ftp://new.url:8082/conda-forge/%s" % self.platform, "ftp://new.url:8082/conda-forge/noarch" ] assert Channel('conda-forge').urls() == cf_urls url = "https://conda.anaconda.org/conda-forge/osx-64/some-great-package.tar.bz2" assert Channel(url).canonical_name == 'conda-forge' assert Channel(url).base_url == 'ftp://new.url:8082/conda-forge' assert Channel(url).url( ) == "ftp://new.url:8082/conda-forge/osx-64/some-great-package.tar.bz2" assert Channel(url).urls() == [ "ftp://new.url:8082/conda-forge/osx-64", "ftp://new.url:8082/conda-forge/noarch", ] channel = Channel( "https://conda.anaconda.org/conda-forge/label/dev/linux-64/some-great-package.tar.bz2" ) assert channel.url( ) == "ftp://new.url:8082/conda-forge/label/dev/linux-64/some-great-package.tar.bz2" assert channel.urls() == [ "ftp://new.url:8082/conda-forge/label/dev/linux-64", "ftp://new.url:8082/conda-forge/label/dev/noarch", ]
def test_regression_against_unknown_none(self): defaults = Channel('defaults') channel = Channel(None) assert channel.scheme is None assert channel.location is None assert channel.platform is None assert channel.name == "<unknown>" assert channel.canonical_name == "<unknown>" assert channel.base_url is None assert channel.url() == defaults.url() assert channel.urls() == defaults.urls() channel = Channel('<unknown>') assert channel.scheme is None assert channel.location is None assert channel.platform is None assert channel.name == "<unknown>" assert channel.canonical_name == "<unknown>" assert channel.base_url is None assert channel.url() == defaults.url() assert channel.urls() == defaults.urls() channel = Channel('None:///<unknown>') assert channel.scheme is None assert channel.location is None assert channel.platform is None assert channel.name == "<unknown>" assert channel.canonical_name == "<unknown>" assert channel.base_url is None assert channel.url() == defaults.url() assert channel.urls() == defaults.urls() channel = Channel('None') assert channel.scheme is None assert channel.location is None assert channel.platform is None assert channel.name == "<unknown>" assert channel.canonical_name == "<unknown>" assert channel.base_url is None assert channel.url() == defaults.url() assert channel.urls() == defaults.urls()
def test_migrated_custom_channels(self): channel = Channel('s3://just/cant/darwin/osx-64') assert channel.channel_name == "darwin" assert channel.channel_location == "some.url.somewhere/stuff" assert channel.platform == 'osx-64' assert channel.package_filename is None assert channel.auth is None assert channel.token is None assert channel.scheme == "https" assert channel.canonical_name == "darwin" assert channel.url( ) == "https://some.url.somewhere/stuff/darwin/osx-64" assert channel.urls() == [ "https://some.url.somewhere/stuff/darwin/osx-64", "https://some.url.somewhere/stuff/darwin/noarch", ] assert Channel(channel.canonical_name).urls() == [ "https://some.url.somewhere/stuff/darwin/%s" % self.platform, "https://some.url.somewhere/stuff/darwin/noarch", ] channel = Channel( 'https://some.url.somewhere/stuff/darwin/noarch/a-mighty-fine.tar.bz2' ) assert channel.channel_name == "darwin" assert channel.channel_location == "some.url.somewhere/stuff" assert channel.platform == 'noarch' assert channel.package_filename == 'a-mighty-fine.tar.bz2' assert channel.auth is None assert channel.token is None assert channel.scheme == "https" assert channel.canonical_name == "darwin" assert channel.url( ) == "https://some.url.somewhere/stuff/darwin/noarch/a-mighty-fine.tar.bz2" assert channel.urls() == [ "https://some.url.somewhere/stuff/darwin/noarch", ] assert Channel(channel.canonical_name).urls() == [ "https://some.url.somewhere/stuff/darwin/%s" % self.platform, "https://some.url.somewhere/stuff/darwin/noarch", ]
def test_migrated_custom_channels(self): channel = Channel('s3://just/cant/darwin/osx-64') assert channel.channel_name == "darwin" assert channel.channel_location == "some.url.somewhere/stuff" assert channel.platform == 'osx-64' assert channel.package_filename is None assert channel.auth is None assert channel.token is None assert channel.scheme == "https" assert channel.canonical_name == "darwin" assert channel.url() == "https://some.url.somewhere/stuff/darwin/osx-64" assert channel.urls() == [ "https://some.url.somewhere/stuff/darwin/osx-64", "https://some.url.somewhere/stuff/darwin/noarch", ] assert Channel(channel.canonical_name).urls() == [ "https://some.url.somewhere/stuff/darwin/%s" % self.platform, "https://some.url.somewhere/stuff/darwin/noarch", ] channel = Channel('https://some.url.somewhere/stuff/darwin/noarch/a-mighty-fine.tar.bz2') assert channel.channel_name == "darwin" assert channel.channel_location == "some.url.somewhere/stuff" assert channel.platform == 'noarch' assert channel.package_filename == 'a-mighty-fine.tar.bz2' assert channel.auth is None assert channel.token is None assert channel.scheme == "https" assert channel.canonical_name == "darwin" assert channel.url() == "https://some.url.somewhere/stuff/darwin/noarch/a-mighty-fine.tar.bz2" assert channel.urls() == [ "https://some.url.somewhere/stuff/darwin/noarch", ] assert Channel(channel.canonical_name).urls() == [ "https://some.url.somewhere/stuff/darwin/%s" % self.platform, "https://some.url.somewhere/stuff/darwin/noarch", ]
def test_bare_channel(self): url = "http://conda-01" channel = Channel(url) assert channel.scheme == "http" assert channel.location == "conda-01" assert channel.platform is None assert channel.canonical_name == url assert channel.name is None assert channel.base_url == url assert channel.url() == join_url(url, context.subdir) assert channel.urls() == [ join_url(url, context.subdir), join_url(url, 'noarch'), ]
def test_url_channel_w_platform(self): channel = Channel('https://repo.continuum.io/pkgs/anaconda/osx-64') assert channel.scheme == "https" assert channel.location == "repo.continuum.io" assert channel.platform == 'osx-64' assert channel.name == 'pkgs/anaconda' assert channel.base_url == 'https://repo.continuum.io/pkgs/anaconda' assert channel.canonical_name == 'defaults' assert channel.url() == 'https://repo.continuum.io/pkgs/anaconda/osx-64' assert channel.urls() == [ 'https://repo.continuum.io/pkgs/anaconda/osx-64', 'https://repo.continuum.io/pkgs/anaconda/noarch', ]
def test_file_channel(self): channel = Channel("file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45/osx-64/flask-0.10.1-py35_2.tar.bz2") assert channel.name == '5d9f5e45' assert channel.location == '/var/folders/cp/7r2s_s593j7_cpdtp/T' assert channel.platform == 'osx-64' assert channel.package_filename == "flask-0.10.1-py35_2.tar.bz2" assert channel.auth is None assert channel.token is None assert channel.scheme == "file" assert channel.url() == "file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45/osx-64/flask-0.10.1-py35_2.tar.bz2" assert channel.urls() == [ "file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45/osx-64", "file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45/noarch" ] assert channel.canonical_name == 'file:///var/folders/cp/7r2s_s593j7_cpdtp/T/5d9f5e45'
def test_url_channel_w_platform(self): channel = Channel('https://repo.continuum.io/pkgs/free/osx-64') assert channel.scheme == "https" assert channel.location == "repo.continuum.io" assert channel.platform == 'osx-64' assert channel.name == 'pkgs/free' assert channel.base_url == 'https://repo.continuum.io/pkgs/free' assert channel.canonical_name == 'defaults' assert channel.url() == 'https://repo.continuum.io/pkgs/free/osx-64' assert channel.urls() == [ 'https://repo.continuum.io/pkgs/free/osx-64', 'https://repo.continuum.io/pkgs/free/noarch', ]
def test_channel_alias(self): channel = Channel("charlie") assert channel.canonical_name == "charlie" assert channel.location == "new.url:8082" assert channel.url() == "ftp://new.url:8082/charlie/%s" % self.platform assert channel.url( True ) == "ftp://*****:*****@new.url:8082/t/zyx-wvut/charlie/%s" % self.platform assert channel.urls() == [ "ftp://new.url:8082/charlie/%s" % self.platform, "ftp://new.url:8082/charlie/noarch", ] assert channel.urls(True) == [ "ftp://*****:*****@new.url:8082/t/zyx-wvut/charlie/%s" % self.platform, "ftp://*****:*****@new.url:8082/t/zyx-wvut/charlie/noarch", ] channel = Channel("charlie/label/dev") assert channel.canonical_name == "charlie/label/dev" assert channel.location == "new.url:8082" assert channel.url( ) == "ftp://new.url:8082/charlie/label/dev/%s" % self.platform assert channel.url( True ) == "ftp://*****:*****@new.url:8082/t/zyx-wvut/charlie/label/dev/%s" % self.platform assert channel.urls() == [ "ftp://new.url:8082/charlie/label/dev/%s" % self.platform, "ftp://new.url:8082/charlie/label/dev/noarch", ] assert channel.urls(True) == [ "ftp://*****:*****@new.url:8082/t/zyx-wvut/charlie/label/dev/%s" % self.platform, "ftp://*****:*****@new.url:8082/t/zyx-wvut/charlie/label/dev/noarch", ] channel = Channel( "ftp://*****:*****@new.url:8082/t/new-token/charlie/label/dev") assert channel.canonical_name == "charlie/label/dev" assert channel.location == "new.url:8082" assert channel.url( ) == "ftp://new.url:8082/charlie/label/dev/%s" % self.platform assert channel.url( True ) == "ftp://*****:*****@new.url:8082/t/new-token/charlie/label/dev/%s" % self.platform assert channel.urls() == [ "ftp://new.url:8082/charlie/label/dev/%s" % self.platform, "ftp://new.url:8082/charlie/label/dev/noarch", ] assert channel.urls(True) == [ "ftp://*****:*****@new.url:8082/t/new-token/charlie/label/dev/%s" % self.platform, "ftp://*****:*****@new.url:8082/t/new-token/charlie/label/dev/noarch", ]
def test_old_channel_alias(self): cf_urls = ["ftp://new.url:8082/conda-forge/%s" % self.platform, "ftp://new.url:8082/conda-forge/noarch"] assert Channel('conda-forge').urls() == cf_urls url = "https://conda.anaconda.org/conda-forge/osx-64/some-great-package.tar.bz2" assert Channel(url).canonical_name == 'conda-forge' assert Channel(url).base_url == 'ftp://new.url:8082/conda-forge' assert Channel(url).url() == "ftp://new.url:8082/conda-forge/osx-64/some-great-package.tar.bz2" assert Channel(url).urls() == [ "ftp://new.url:8082/conda-forge/osx-64", "ftp://new.url:8082/conda-forge/noarch", ] channel = Channel("https://conda.anaconda.org/conda-forge/label/dev/linux-64/some-great-package.tar.bz2") assert channel.url() == "ftp://new.url:8082/conda-forge/label/dev/linux-64/some-great-package.tar.bz2" assert channel.urls() == [ "ftp://new.url:8082/conda-forge/label/dev/linux-64", "ftp://new.url:8082/conda-forge/label/dev/noarch", ]
def test_channel_alias(self): channel = Channel("charlie") assert channel.canonical_name == "charlie" assert channel.location == "new.url:8082" assert channel.url() == "ftp://new.url:8082/charlie/%s" % self.platform assert channel.url(True) == "ftp://*****:*****@new.url:8082/t/zyx-wvut/charlie/%s" % self.platform assert channel.urls() == [ "ftp://new.url:8082/charlie/%s" % self.platform, "ftp://new.url:8082/charlie/noarch", ] assert channel.urls(True) == [ "ftp://*****:*****@new.url:8082/t/zyx-wvut/charlie/%s" % self.platform, "ftp://*****:*****@new.url:8082/t/zyx-wvut/charlie/noarch", ] channel = Channel("charlie/label/dev") assert channel.canonical_name == "charlie/label/dev" assert channel.location == "new.url:8082" assert channel.url() == "ftp://new.url:8082/charlie/label/dev/%s" % self.platform assert channel.url(True) == "ftp://*****:*****@new.url:8082/t/zyx-wvut/charlie/label/dev/%s" % self.platform assert channel.urls() == [ "ftp://new.url:8082/charlie/label/dev/%s" % self.platform, "ftp://new.url:8082/charlie/label/dev/noarch", ] assert channel.urls(True) == [ "ftp://*****:*****@new.url:8082/t/zyx-wvut/charlie/label/dev/%s" % self.platform, "ftp://*****:*****@new.url:8082/t/zyx-wvut/charlie/label/dev/noarch", ] channel = Channel("ftp://*****:*****@new.url:8082/t/new-token/charlie/label/dev") assert channel.canonical_name == "charlie/label/dev" assert channel.location == "new.url:8082" assert channel.url() == "ftp://new.url:8082/charlie/label/dev/%s" % self.platform assert channel.url( True) == "ftp://*****:*****@new.url:8082/t/new-token/charlie/label/dev/%s" % self.platform assert channel.urls() == [ "ftp://new.url:8082/charlie/label/dev/%s" % self.platform, "ftp://new.url:8082/charlie/label/dev/noarch", ] assert channel.urls(True) == [ "ftp://*****:*****@new.url:8082/t/new-token/charlie/label/dev/%s" % self.platform, "ftp://*****:*****@new.url:8082/t/new-token/charlie/label/dev/noarch", ]