def test_anaconda_token_with_private_package(self): # TODO: should also write a test to use binstar_client to set the token, # then let conda load the token # Step 0. xfail if a token is set, for example when testing locally tokens = read_binstar_tokens() if tokens: pytest.xfail("binstar token found in global configuration") # Step 1. Make sure without the token we don't see the anyjson package try: prefix = make_temp_prefix(str(uuid4())[:7]) channel_url = "https://conda.anaconda.org/kalefranz" run_command(Commands.CONFIG, prefix, "--add channels %s" % channel_url) run_command(Commands.CONFIG, prefix, "--remove channels defaults") stdout, stderr = run_command(Commands.CONFIG, prefix, "--show") yml_obj = yaml_load(stdout) assert yml_obj['channels'] == [channel_url] stdout, stderr = run_command(Commands.SEARCH, prefix, "anyjson", "--platform", "linux-64", "--json") json_obj = json_loads(stdout) assert len(json_obj) == 0 finally: rmtree(prefix, ignore_errors=True) # Step 2. Now with the token make sure we can see the anyjson package try: prefix = make_temp_prefix(str(uuid4())[:7]) channel_url = "https://conda.anaconda.org/t/zlZvSlMGN7CB/kalefranz" run_command(Commands.CONFIG, prefix, "--add channels %s" % channel_url) run_command(Commands.CONFIG, prefix, "--remove channels defaults") stdout, stderr = run_command(Commands.CONFIG, prefix, "--show") yml_obj = yaml_load(stdout) assert yml_obj['channels'] == [channel_url] stdout, stderr = run_command(Commands.SEARCH, prefix, "anyjson", "--platform", "linux-64", "--json") json_obj = json_loads(stdout) assert 'anyjson' in json_obj finally: rmtree(prefix, ignore_errors=True)