示例#1
0
文件: test_use.py 项目: vartec/devpi
 def test_switch_to_temporary(self, makehub, mock_http_api):
     hub = makehub(['use'])
     mock_http_api.set("http://foo/+api",
                       200,
                       result=dict(pypisubmit="/post",
                                   simpleindex="/index/",
                                   index="root/some",
                                   bases="root/dev",
                                   login="******",
                                   authstatus=["noauth", ""]))
     current = Current()
     d = {
         "index": "http://l/some/index",
         "login": "******",
     }
     current.reconfigure(data=d)
     current.set_auth("user", "password")
     assert current.get_auth() == ("user", "password")
     temp = current.switch_to_temporary(hub, "http://foo")
     temp.set_auth("user1", "password1")
     assert temp.get_auth() == ("user1", "password1")
     # original is unaffected
     assert current.get_auth() == ("user", "password")
     assert temp._currentdict is not current._currentdict
     assert temp._currentdict['auth'] is not current._currentdict['auth']