def test_authenticated_from_configuration_wo_auth(self): # Given url = "http://acme.com" responses.add(responses.GET, url) responses.add(responses.GET, url + "/accounts/user/info/", body=json.dumps(R_JSON_AUTH_RESP)) config = Configuration() config.update(store_url=url) # When/Then with self.assertRaises(EnstallerException): with Session.authenticated_from_configuration(config): pass
def test_from_repository_info_empty(self): # Given repository_info = BroodRepositoryInfo("https://api.enthought.com", "enthought/free") config = Configuration(use_webservice=False, auth=("nono", "password")) config._store_kind = STORE_KIND_BROOD session = Session.authenticated_from_configuration(config) # When repository = Repository.from_repository_info(session, repository_info) # Then self.assertEqual(len(repository), 0)
def test_authenticated_from_configuration(self): # Given url = "http://acme.com" responses.add(responses.GET, url) responses.add(responses.GET, url + "/accounts/user/info/", body=json.dumps(R_JSON_AUTH_RESP)) config = Configuration() config.update(store_url=url, auth=("yoyo", "yeye")) # When with Session.authenticated_from_configuration(config) as session: resp = session._raw_get(url) # Then self.assertTrue(resp.status_code, 200)
def test_from_repository_infos_nonempty(self): # Given repository_infos = ( BroodRepositoryInfo("https://api.enthought.com", "enthought/free"), BroodRepositoryInfo( "https://api.enthought.com", "enthought/commercial" ), ) config = Configuration(use_webservice=False, auth=("nono", "password")) config._store_kind = STORE_KIND_BROOD session = Session.authenticated_from_configuration(config) # When repository = Repository.from_repository_infos(session, repository_infos) # Then self.assertEqual(len(repository), 2) self.assertEqual(len(repository.find_packages("nose")), 2)