def test_config_invalid_host(self): # Our URL handling is very forgiving, since we might receive a host # defined in local DNS, like 'foo' instead of 'foo.com' -- and on top # of that, we automatically add 'https://' to the name if no schema is # present. ..but, a bad port causes an error.. with pytest.raises(util.QuiltException, match='Port must be a number'): he.config('https://fliff:fluff')
def setUp(self): # Verify that CONFIG_PATH is in the test dir (patched by conftest.py). assert 'pytest' in str(CONFIG_PATH) quilt3.config( navigator_url='https://example.com', apiGatewayEndpoint='https://xyz.execute-api.us-east-1.amazonaws.com/prod', binaryApiGatewayEndpoint='https://xyz.execute-api.us-east-1.amazonaws.com/prod', default_local_registry=pathlib.Path('.').resolve().as_uri() + '/local_registry', default_remote_registry='s3://example/', default_install_location=None, defaultBucket='test-bucket', registryUrl='https://registry.example.com', s3Proxy='open-s3-proxy.quiltdata.com' ) self.requests_mock = responses.RequestsMock(assert_all_requests_are_fired=False) self.requests_mock.start() # Create a dummy S3 client that (hopefully) can't do anything. self.s3_client = boto3.client('s3', config=Config(signature_version=UNSIGNED)) self.s3_client_patcher = mock.patch('quilt3.data_transfer.create_s3_client', return_value=self.s3_client) self.s3_client_patcher.start() self.s3_stubber = Stubber(self.s3_client) self.s3_stubber.activate()
def test_config(self): content = { 'navigator_url': 'https://foo.bar', 'telemetry_disabled': False, 's3Proxy': None, 'apiGatewayEndpoint': None, 'binaryApiGatewayEndpoint': None } self.requests_mock.add(responses.GET, 'https://foo.bar/config.json', json=content, status=200) he.config('https://foo.bar') with open(util.CONFIG_PATH, 'r') as stream: config = yaml.safe_load(stream) # These come from CONFIG_TEMPLATE, not the mocked config file. content['default_local_registry'] = util.BASE_PATH.as_uri( ) + '/packages' content['default_remote_registry'] = None content['default_install_location'] = None content['registryUrl'] = None assert config == content
def test_config(self): content = { 'navigator_url': 'https://foo.bar', 'elastic_search_url': 'https://es.foo', 'accept_invalid_config_keys': 'yup', 'telemetry_disabled': False } self.requests_mock.add(responses.GET, 'https://foo.bar/config.json', json=content, status=200) he.config('https://foo.bar') yaml = YAML() config = yaml.load(util.CONFIG_PATH) # These come from CONFIG_TEMPLATE, not the mocked config file. content['default_local_registry'] = util.BASE_PATH.as_uri( ) + '/packages' content['default_remote_registry'] = None content['default_install_location'] = None content['registryUrl'] = None assert config == content
def test_remote_install(self): """Verify that installing from a local package works as expected.""" remote_registry = Path('.').resolve().as_uri() quilt3.config(default_local_registry=remote_registry, default_remote_registry=remote_registry) with patch('quilt3.Package.push') as push_mock: pkg = Package() pkg.build('Quilt/nice-name') with patch('quilt3.Package._materialize') as materialize_mock, \ patch('quilt3.Package.build') as build_mock: materialize_mock.return_value = pkg dest_registry = quilt3.util.get_from_config( 'default_local_registry') quilt3.Package.install('Quilt/nice-name', dest='./') materialize_mock.assert_called_once_with(fix_url('./')) build_mock.assert_called_once_with('Quilt/nice-name', message=None, registry=dest_registry)
def setUp(self): # Verify that CONFIG_PATH is in the test dir (patched by conftest.py). assert 'pytest' in str(CONFIG_PATH) quilt3.config( navigator_url='https://example.com', elastic_search_url='https://es.example.com/', default_local_registry=pathlib.Path('.').resolve().as_uri() + '/local_registry', default_remote_registry='s3://example/', default_install_location=None, registryUrl='https://registry.example.com' ) self.requests_mock = responses.RequestsMock(assert_all_requests_are_fired=False) self.requests_mock.start() # Create a dummy S3 client that (hopefully) can't do anything. self.s3_client = boto3.client('s3', config=Config(signature_version=UNSIGNED)) self.s3_client_patcher = mock.patch('quilt3.data_transfer.create_s3_client', return_value=self.s3_client) self.s3_client_patcher.start() self.s3_stubber = Stubber(self.s3_client) self.s3_stubber.activate()
def set_up_quilt() -> str: """ Set up default values in the quilt config Assures that QUILT_DATA_DIR folder exists and set it in quilt3 config as the default install location. Returns ------- default install location: str Local path where packages will be downloaded """ quilt3.config(QUILT_URL) quilt3.config(default_remote_registry=S3_BUCKET) default_install_location = os.path.expanduser(QUILT_DATA_DIR) os.makedirs(default_install_location, exist_ok=True) quilt3.config(default_install_location='file://' + default_install_location) return default_install_location
def config(self): """ Configure the Quilt client to the desired AWS S3 bucket ("remote Quilt registry") """ quilt3.config(self.registry) quilt3.config(default_remote_registry=self.get_aws_bucket_uri())