function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def test_add_exists(self, isfile_mock, deploy_mock, validate_mock): isfile_mock.return_value = True catalog.add('tpch') filenames = ['tpch.properties'] deploy_mock.assert_called_with(filenames, get_catalog_directory(), ...
prestodb/presto-admin
[ 170, 102, 170, 63, 1432266042 ]
def test_add_all(self, mock_validate, listdir_mock, isdir_mock, deploy_mock): catalogs = ['tpch.properties', 'another.properties'] listdir_mock.return_value = catalogs catalog.add() deploy_mock.assert_called_with(catalogs, get_c...
prestodb/presto-admin
[ 170, 102, 170, 63, 1432266042 ]
def test_add_all_fails_if_dir_not_there(self, isdir_mock, deploy_mock): isdir_mock.return_value = False self.assertRaisesRegexp(ConfigFileNotFoundError, r'Cannot add catalogs because directory .+' r' does not exist', ...
prestodb/presto-admin
[ 170, 102, 170, 63, 1432266042 ]
def test_remove(self, local_rm_mock, exists_mock, sudo_mock): script = ('if [ -f /etc/presto/catalog/tpch.properties ] ; ' 'then rm /etc/presto/catalog/tpch.properties ; ' 'else echo "Could not remove catalog \'tpch\'. ' 'No such file \'/etc/presto/catalog/t...
prestodb/presto-admin
[ 170, 102, 170, 63, 1432266042 ]
def test_remove_failure(self, exists_mock, sudo_mock): exists_mock.return_value = False fabric.api.env.host = 'localhost' out = _AttributeString() out.succeeded = False sudo_mock.return_value = out self.assertRaisesRegexp(SystemExit, '\\[lo...
prestodb/presto-admin
[ 170, 102, 170, 63, 1432266042 ]
def test_remove_no_such_file(self, exists_mock, sudo_mock): exists_mock.return_value = False fabric.api.env.host = 'localhost' error_msg = ('Could not remove catalog tpch: No such file ' + os.path.join(get_catalog_directory(), 'tpch.properties')) out = _AttributeStri...
prestodb/presto-admin
[ 170, 102, 170, 63, 1432266042 ]
def test_warning_if_connector_dir_empty(self, isdir_mock, listdir_mock): isdir_mock.return_value = True listdir_mock.return_value = [] catalog.add() self.assertEqual('\nWarning: Directory %s is empty. No catalogs will' ' be deployed\n\n' % get_catalog_directory()...
prestodb/presto-admin
[ 170, 102, 170, 63, 1432266042 ]
def test_add_permission_denied(self, isdir_mock, listdir_mock): isdir_mock.return_value = True error_msg = ('Permission denied') listdir_mock.side_effect = OSError(13, error_msg) fabric.api.env.host = 'localhost' self.assertRaisesRegexp(SystemExit, '\[localhost\] %s' % error_msg,...
prestodb/presto-admin
[ 170, 102, 170, 63, 1432266042 ]
def test_remove_os_error(self, remove_file_mock, remove_mock): fabric.api.env.host = 'localhost' error = OSError(13, 'Permission denied') remove_mock.side_effect = error self.assertRaisesRegexp(OSError, 'Permission denied', catalog.remove, 'tpch')
prestodb/presto-admin
[ 170, 102, 170, 63, 1432266042 ]
def test_deploy_files(self, put_mock, create_dir_mock): local_dir = '/my/local/dir' remote_dir = '/my/remote/dir' catalog.deploy_files(['a', 'b'], local_dir, remote_dir, PRESTO_STANDALONE_USER_GROUP) create_dir_mock.assert_called_with(remote_dir, PRESTO_STAND...
prestodb/presto-admin
[ 170, 102, 170, 63, 1432266042 ]
def test_validate(self, open_mock, is_file_mock): is_file_mock.return_value = True file_obj = open_mock.return_value.__enter__.return_value file_obj.read.return_value = 'connector.noname=example' self.assertRaisesRegexp(ConfigurationError, 'Catalog config...
prestodb/presto-admin
[ 170, 102, 170, 63, 1432266042 ]
def test_validate_fail(self, is_file_mock): is_file_mock.return_value = True self.assertRaisesRegexp( SystemExit, 'Error validating ' + os.path.join(get_catalog_directory(), 'example.properties') + '\n\n' 'Underlying exception:\n No such file or directory', ...
prestodb/presto-admin
[ 170, 102, 170, 63, 1432266042 ]
def __init__(self, region, name, retention_in_days=7): super(LogGroup, self).__init__() self.region = region self.name = name self.retention_in_days = retention_in_days
GoogleCloudPlatform/PerfKitBenchmarker
[ 1785, 474, 1785, 248, 1405617806 ]
def _Delete(self): """Delete the log group.""" delete_cmd = util.AWS_PREFIX + [ '--region', self.region, 'logs', 'delete-log-group', '--log-group-name', self.name ] vm_util.IssueCommand(delete_cmd, raise_on_failure=False)
GoogleCloudPlatform/PerfKitBenchmarker
[ 1785, 474, 1785, 248, 1405617806 ]
def _PostCreate(self): """Set the retention policy.""" put_cmd = util.AWS_PREFIX + [ '--region', self.region, 'logs', 'put-retention-policy', '--log-group-name', self.name, '--retention-in-days', str(self.retention_in_days) ] vm_util.IssueCommand(put_cmd)
GoogleCloudPlatform/PerfKitBenchmarker
[ 1785, 474, 1785, 248, 1405617806 ]
def JOB_STATES(state): if state == 'failed': return BOLD() + RED() + state + ENDC() elif state == 'done': return BOLD() + GREEN() + state + ENDC() elif state in ['running', 'in_progress']: return GREEN() + state + ENDC() elif state == 'partially_failed': return RED() + st...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def get_size_str(size): """ Formats a byte size as a string. The returned string is no more than 9 characters long. """ if size is None: return "0 " + SIZE_LEVEL[0] if size == 0: magnitude = 0 level = 0 else: magnitude = math.floor(math.log(size, 10)) ...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def get_io_desc(parameter, include_class=True, show_opt=True, app_help_version=False): # For interactive help, format array:CLASS inputs as: # -iNAME=CLASS [-iNAME=... [...]] # If input is required (needs >=1 inputs) # [-iNAME=CLASS [...]] # If input is optional (needs >=0 inputs if a...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def is_job_ref(thing, reftype=dict): ''' :param thing: something that might be a job-based object reference hash :param reftype: type that a job-based object reference would be (default is dict) ''' return isinstance(thing, reftype) and \ ((len(thing) == 2 and \ isinstance(thin...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def get_field_from_jbor(thing): ''' :returns: Output field name from a JBOR Assumes :func:`is_job_ref` evaluates to True ''' if '$dnanexus_link' in thing: return thing['$dnanexus_link']['field'] else: return thing['field']
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def is_metadata_ref(thing, reftype=dict): return isinstance(thing, reftype) and \ len(thing) == 1 and \ isinstance(thing.get('$dnanexus_link'), reftype) and \ isinstance(thing['$dnanexus_link'].get('metadata'), basestring)
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def io_val_to_str(val): if is_job_ref(val): # Job-based object references return jbor_to_str(val) elif isinstance(val, dict) and '$dnanexus_link' in val: # DNAnexus link if isinstance(val['$dnanexus_link'], basestring): # simple link return val['$dnanexus_...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def get_io_field(io_hash, defaults=None, delim='=', highlight_fields=()): def highlight_value(key, value): if key in highlight_fields: return YELLOW() + value + ENDC() else: return value if defaults is None: defaults = {} if io_hash is None: return '...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def render_bundleddepends(thing): from ..bindings.search import find_one_data_object from ..exceptions import DXError bundles = [] for item in thing: bundle_asset_record = dxpy.DXFile(item["id"]["$dnanexus_link"]).get_properties().get("AssetBundle") asset = None if bundle_asset_...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def render_stage(title, stage, as_stage_of=None): lines_to_print = [] if stage['name'] is not None: lines_to_print.append((title, "{name} ({id})".format(name=stage['name'], id=stage['id']))) else: lines_to_print.append((title, stage['id'])) lines_to_print.append((' Executable', stage[...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def render_timestamp(timestamp): return datetime.datetime.fromtimestamp(timestamp//1000).ctime()
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def print_field(label, value): if get_delimiter() is not None: sys.stdout.write(label + get_delimiter() + value + '\n') else: sys.stdout.write( label + " " * (FIELD_NAME_WIDTH-len(label)) + fill(value, subsequent_indent='...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def print_list_field(label, values): print_field(label, ('-' if len(values) == 0 else DELIMITER(', ').join(values)))
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def print_project_desc(desc, verbose=False): recognized_fields = [ 'id', 'class', 'name', 'summary', 'description', 'protected', 'restricted', 'created', 'modified', 'dataUsage', 'sponsoredDataUsage', 'tags', 'level', 'folders', 'objects', 'permissions', 'properties', 'appCaches', 'billTo', ...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def print_app_desc(desc, verbose=False): recognized_fields = ['id', 'class', 'name', 'version', 'aliases', 'createdBy', 'created', 'modified', 'deleted', 'published', 'title', 'subtitle', 'description', 'categories', 'access', 'dxapi', 'inputSpec', 'outputSpec', 'runSpec', 'resources', 'billTo', 'installed', 'openS...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def get_col_str(col_desc): return col_desc['name'] + DELIMITER(" (") + col_desc['type'] + DELIMITER(")")
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def printable_ssh_host_key(ssh_host_key): try: keygen = subprocess.Popen(["ssh-keygen", "-lf", "/dev/stdin"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) if USING_PYTHON2: (stdout, stderr) = keygen.communicate(ssh_host_key) else: (stdout, stderr) = keygen.communica...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def locale_from_currency_code(dx_code): """ This is a (temporary) hardcoded mapping between currency_list.json in nucleus and standard locale string useful for further formatting :param dx_code: An id of nucleus/commons/pricing_models/currency_list.json collection :return: standardised locale, eg '...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def format_currency(value, meta, currency_locale=None): """ Formats currency value into properly decorated currency string based on either locale (preferred) or if that is not available then currency metadata. Until locale is provided from the server a crude mapping between `currency.dxCode` and a local...
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def print_generic_desc(desc): for field in desc: print_json_field(field, desc[field])
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def get_ls_desc(desc, print_id=False): addendum = ' : ' + desc['id'] if print_id is True else '' if desc['class'] in ['applet', 'workflow']: return BOLD() + GREEN() + desc['name'] + ENDC() + addendum else: return desc['name'] + addendum
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def get_ls_l_header(): return (BOLD() + 'State' + DELIMITER(' ') + 'Last modified' + DELIMITER(' ') + 'Size' + DELIMITER(' ') + 'Name' + DELIMITER(' (') + 'ID' + DELIMITER(')') + ENDC())
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def get_ls_l_desc_fields(): return { 'id': True, 'class': True, 'folder': True, 'length': True, 'modified': True, 'name': True, 'project': True, 'size': True, 'state': True }
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def print_ls_l_desc(desc, **kwargs): print(get_ls_l_desc(desc, **kwargs))
dnanexus/dx-toolkit
[ 74, 76, 74, 71, 1340756627 ]
def each(f): if f.body: f.hashes = [] for hash_type, h in HashFile.extract_hashes(f.body.contents): hash_object = Hash.get_or_create(value=h.hexdigest()) hash_object.add_source("analytics") hash_object.save() f.active_link_t...
yeti-platform/yeti
[ 1360, 268, 1360, 132, 1450025666 ]
def setUp(self): self.fd, self.path = tempfile.mkstemp()
rbuffat/pyidf
[ 20, 7, 20, 2, 1417292720 ]
def __init__( self, client, name, offset, read_rows_kwargs, retry_delay_callback=None
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def __iter__(self): """An iterable of messages. Returns: Iterable[ \ ~google.cloud.bigquery_storage_v1.types.ReadRowsResponse \ ]: A sequence of row messages. """ # Infinite loop to reconnect on reconnectable errors while processin...
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def _resource_exhausted_exception_is_retryable(self, exc): if isinstance(exc, google.api_core.exceptions.ResourceExhausted): # ResourceExhausted errors are only retried if a valid # RetryInfo is provided with the error. # # TODO: Remove hasattr logic when we requi...
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def to_arrow(self, read_session=None): """Create a :class:`pyarrow.Table` of all rows in the stream. This method requires the pyarrow library and a stream using the Arrow format. Args: read_session ( \ ~google.cloud.bigquery_storage_v1.types.ReadSession \ ...
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def __init__(self, reader, read_session=None): self._reader = reader if read_session is not None: self._stream_parser = _StreamParser.from_read_session(read_session) else: self._stream_parser = None
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def pages(self): """A generator of all pages in the stream. Returns: types.GeneratorType[google.cloud.bigquery_storage_v1.ReadRowsPage]: A generator of pages. """ # Each page is an iterator of rows. But also has num_items, remaining, # and to_datafram...
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def to_arrow(self): """Create a :class:`pyarrow.Table` of all rows in the stream. This method requires the pyarrow library and a stream using the Arrow format. Returns: pyarrow.Table: A table of all rows in the stream. """ record_batches = []...
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def _dtypes_from_avro(self, avro_fields): """Determine Pandas dtypes for columns in Avro schema. Args: avro_fields (Iterable[Mapping[str, Any]]): Avro fields' metadata. Returns: colelctions.OrderedDict[str, str]: Column names with their c...
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def __init__(self, stream_parser, message): self._stream_parser = stream_parser self._message = message self._iter_rows = None self._num_items = self._message.row_count self._remaining = self._message.row_count
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def num_items(self): """int: Total items in the page.""" return self._num_items
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def remaining(self): """int: Remaining items in the page.""" return self._remaining
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def next(self): """Get the next row in the page.""" self._parse_rows() if self._remaining > 0: self._remaining -= 1 return next(self._iter_rows)
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def to_arrow(self): """Create an :class:`pyarrow.RecordBatch` of rows in the page. Returns: pyarrow.RecordBatch: Rows from the message, as an Arrow record batch. """ return self._stream_parser.to_arrow(self._message)
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def to_arrow(self, message): raise NotImplementedError("Not implemented.")
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def to_rows(self, message): raise NotImplementedError("Not implemented.")
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def _parse_arrow_schema(self): raise NotImplementedError("Not implemented.")
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def from_read_session(read_session): schema_type = read_session._pb.WhichOneof("schema") if schema_type == "avro_schema": return _AvroStreamParser(read_session) elif schema_type == "arrow_schema": return _ArrowStreamParser(read_session) else: raise Typ...
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def from_read_rows_response(message): schema_type = message._pb.WhichOneof("schema") if schema_type == "avro_schema": return _AvroStreamParser(message) elif schema_type == "arrow_schema": return _ArrowStreamParser(message) else: raise TypeError( ...
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def __init__(self, message): """Construct an _AvroStreamParser. Args: message (Union[ google.cloud.bigquery_storage_v1.types.ReadSession, \ google.cloud.bigquery_storage_v1.types.ReadRowsResponse, \ ]): Either the first message of ...
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def to_dataframe(self, message, dtypes=None): """Create a :class:`pandas.DataFrame` of rows in the page. This method requires the pandas libary to create a data frame and the fastavro library to parse row messages. .. warning:: DATETIME columns are not supported. They are c...
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def _parse_fastavro(self): """Convert parsed Avro schema to fastavro format.""" self._parse_avro_schema() self._fastavro_schema = fastavro.parse_schema(self._avro_schema_json)
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def __init__(self, message): """Construct an _ArrowStreamParser. Args: message (Union[ google.cloud.bigquery_storage_v1.types.ReadSession, \ google.cloud.bigquery_storage_v1.types.ReadRowsResponse, \ ]): Either the first message of...
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def to_rows(self, message): record_batch = self._parse_arrow_message(message) # Iterate through each column simultaneously, and make a dict from the # row values for row in zip(*record_batch.columns): yield dict(zip(self._column_names, row))
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def _parse_arrow_message(self, message): self._parse_arrow_schema() return pyarrow.ipc.read_record_batch( pyarrow.py_buffer(message.arrow_record_batch.serialized_record_batch), self._schema, )
googleapis/python-bigquery-storage
[ 73, 35, 73, 15, 1575936548 ]
def setUp(self): with mock.patch( 'airflow.providers.google.cloud.hooks.vision.CloudVisionHook.__init__', new=mock_base_gcp_hook_default_project_id, ): self.hook = CloudVisionHook(gcp_conn_id='test')
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_product_search_client_creation(self, mock_client, mock_get_creds, mock_client_info): result = self.hook.get_conn() mock_client.assert_called_once_with( credentials=mock_get_creds.return_value, client_info=mock_client_info.return_value ) assert mock_client.return_valu...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_create_productset_explicit_id(self, get_conn): # Given create_product_set_method = get_conn.return_value.create_product_set create_product_set_method.return_value = None parent = ProductSearchClient.location_path(PROJECT_ID_TEST, LOC_ID_TEST) product_set = ProductSet() ...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_create_productset_autogenerated_id(self, get_conn): # Given autogenerated_id = 'autogen-id' response_product_set = ProductSet( name=ProductSearchClient.product_set_path(PROJECT_ID_TEST, LOC_ID_TEST, autogenerated_id) ) create_product_set_method = get_conn.ret...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_create_productset_autogenerated_id_wrong_api_response(self, get_conn): # Given response_product_set = None create_product_set_method = get_conn.return_value.create_product_set create_product_set_method.return_value = response_product_set parent = ProductSearchClient.loca...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_get_productset(self, get_conn): # Given name = ProductSearchClient.product_set_path(PROJECT_ID_TEST, LOC_ID_TEST, PRODUCTSET_ID_TEST) response_product_set = ProductSet(name=name) get_product_set_method = get_conn.return_value.get_product_set get_product_set_method.return...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_update_productset_no_explicit_name(self, get_conn): # Given product_set = ProductSet() update_product_set_method = get_conn.return_value.update_product_set update_product_set_method.return_value = product_set productset_name = ProductSearchClient.product_set_path( ...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_update_productset_no_explicit_name_and_missing_params_for_constructed_name( self, location, product_set_id, get_conn
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_update_productset_explicit_name_missing_params_for_constructed_name( self, location, product_set_id, get_conn
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_update_productset_explicit_name_different_from_constructed(self, get_conn): # Given update_product_set_method = get_conn.return_value.update_product_set update_product_set_method.return_value = None explicit_ps_name = ProductSearchClient.product_set_path( PROJECT_ID_...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_delete_productset(self, get_conn): # Given delete_product_set_method = get_conn.return_value.delete_product_set delete_product_set_method.return_value = None name = ProductSearchClient.product_set_path(PROJECT_ID_TEST, LOC_ID_TEST, PRODUCTSET_ID_TEST) # When resp...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_create_reference_image_explicit_id(self, get_conn): # Given create_reference_image_method = get_conn.return_value.create_reference_image # When result = self.hook.create_reference_image( project_id=PROJECT_ID_TEST, location=LOC_ID_TEST, produ...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_create_reference_image_autogenerated_id(self, get_conn): # Given create_reference_image_method = get_conn.return_value.create_reference_image # When result = self.hook.create_reference_image( project_id=PROJECT_ID_TEST, location=LOC_ID_TEST, ...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_add_product_to_product_set(self, get_conn): # Given add_product_to_product_set_method = get_conn.return_value.add_product_to_product_set # When self.hook.add_product_to_product_set( product_set_id=PRODUCTSET_ID_TEST, product_id=PRODUCT_ID_TEST, ...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_remove_product_from_product_set(self, get_conn): # Given remove_product_from_product_set_method = get_conn.return_value.remove_product_from_product_set # When self.hook.remove_product_from_product_set( product_set_id=PRODUCTSET_ID_TEST, product_id=PRODUC...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_annotate_image(self, annotator_client_mock): # Given annotate_image_method = annotator_client_mock.annotate_image # When self.hook.annotate_image(request=ANNOTATE_IMAGE_REQUEST) # Then # Product ID was provided explicitly in the method call above, should be retu...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_batch_annotate_images(self, annotator_client_mock): # Given batch_annotate_images_method = annotator_client_mock.batch_annotate_images # When self.hook.batch_annotate_images(requests=BATCH_ANNOTATE_IMAGE_REQUEST) # Then # Product ID was provided explicitly in th...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_create_product_explicit_id(self, get_conn): # Given create_product_method = get_conn.return_value.create_product create_product_method.return_value = None parent = ProductSearchClient.location_path(PROJECT_ID_TEST, LOC_ID_TEST) product = Product() # When ...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_create_product_autogenerated_id(self, get_conn): # Given autogenerated_id = 'autogen-p-id' response_product = Product( name=ProductSearchClient.product_path(PROJECT_ID_TEST, LOC_ID_TEST, autogenerated_id) ) create_product_method = get_conn.return_value.create...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_create_product_autogenerated_id_wrong_name_in_response(self, get_conn): # Given wrong_name = 'wrong_name_not_a_correct_path' response_product = Product(name=wrong_name) create_product_method = get_conn.return_value.create_product create_product_method.return_value = resp...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_create_product_autogenerated_id_wrong_api_response(self, get_conn): # Given response_product = None create_product_method = get_conn.return_value.create_product create_product_method.return_value = response_product parent = ProductSearchClient.location_path(PROJECT_ID_TE...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_update_product_no_explicit_name(self, get_conn): # Given product = Product() update_product_method = get_conn.return_value.update_product update_product_method.return_value = product product_name = ProductSearchClient.product_path(PROJECT_ID_TEST, LOC_ID_TEST, PRODUCT_ID...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_update_product_no_explicit_name_and_missing_params_for_constructed_name( self, location, product_id, get_conn
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_update_product_explicit_name_missing_params_for_constructed_name( self, location, product_id, get_conn
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_update_product_explicit_name_different_from_constructed(self, get_conn): # Given update_product_method = get_conn.return_value.update_product update_product_method.return_value = None explicit_p_name = ProductSearchClient.product_path( PROJECT_ID_TEST_2, LOC_ID_TEST_...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_delete_product(self, get_conn): # Given delete_product_method = get_conn.return_value.delete_product delete_product_method.return_value = None name = ProductSearchClient.product_path(PROJECT_ID_TEST, LOC_ID_TEST, PRODUCT_ID_TEST) # When response = self.hook.delet...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_detect_text(self, annotator_client_mock): # Given detect_text_method = annotator_client_mock.text_detection detect_text_method.return_value = AnnotateImageResponse( text_annotations=[EntityAnnotation(description="test", score=0.5)] ) # When self.hook...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_detect_text_with_additional_properties(self, annotator_client_mock): # Given detect_text_method = annotator_client_mock.text_detection detect_text_method.return_value = AnnotateImageResponse( text_annotations=[EntityAnnotation(description="test", score=0.5)] ) ...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_detect_text_with_error_response(self, annotator_client_mock): # Given detect_text_method = annotator_client_mock.text_detection detect_text_method.return_value = AnnotateImageResponse( error={"code": 3, "message": "test error message"} ) # When with ...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_document_text_detection(self, annotator_client_mock): # Given document_text_detection_method = annotator_client_mock.document_text_detection document_text_detection_method.return_value = AnnotateImageResponse( text_annotations=[EntityAnnotation(description="test", score=0.5)...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_document_text_detection_with_additional_properties(self, annotator_client_mock): # Given document_text_detection_method = annotator_client_mock.document_text_detection document_text_detection_method.return_value = AnnotateImageResponse( text_annotations=[EntityAnnotation(des...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_detect_document_text_with_error_response(self, annotator_client_mock): # Given detect_text_method = annotator_client_mock.document_text_detection detect_text_method.return_value = AnnotateImageResponse( error={"code": 3, "message": "test error message"} ) # ...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_label_detection(self, annotator_client_mock): # Given label_detection_method = annotator_client_mock.label_detection label_detection_method.return_value = AnnotateImageResponse( label_annotations=[EntityAnnotation(description="test", score=0.5)] ) # When ...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_label_detection_with_additional_properties(self, annotator_client_mock): # Given label_detection_method = annotator_client_mock.label_detection label_detection_method.return_value = AnnotateImageResponse( label_annotations=[EntityAnnotation(description="test", score=0.5)] ...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]
def test_label_detection_with_error_response(self, annotator_client_mock): # Given detect_text_method = annotator_client_mock.label_detection detect_text_method.return_value = AnnotateImageResponse( error={"code": 3, "message": "test error message"} ) # When ...
apache/incubator-airflow
[ 29418, 12032, 29418, 869, 1428948298 ]