本文整理匯總了Python中vcr.use_cassette方法的典型用法代碼示例。如果您正苦於以下問題:Python vcr.use_cassette方法的具體用法?Python vcr.use_cassette怎麽用?Python vcr.use_cassette使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vcr
的用法示例。
在下文中一共展示了vcr.use_cassette方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: validator_fail_with_warning
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def validator_fail_with_warning(
self, record_mode, validator
) -> Iterable[Tuple[SqlValidator, Dict]]:
with vcr.use_cassette(
"tests/cassettes/test_sql_validator/fixture_validator_fail_with_warning.yaml",
match_on=["uri", "method", "raw_body"],
filter_headers=["Authorization"],
record_mode=record_mode,
):
# Move to dev mode to test conditional logic warning
validator.client.update_workspace("eye_exam", "dev")
validator.client.checkout_branch("eye_exam", "pytest")
validator.build_project(selectors=["eye_exam/users__fail_and_warn"])
results = validator.validate(mode="hybrid")
yield validator, results
示例2: test_update_api_key_with_new_environment
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def test_update_api_key_with_new_environment(self):
api_key = CLIENT.api_keys(PLAYGROUND_SPACE).find('5mxNhKOZYOp1wzafOR9qPw')
with vcr.use_cassette('fixtures/api_key/update_key.yaml'):
self.assertEqual(len(api_key.environments), 1)
self.assertEqual(api_key.environments[0].id, 'testing')
api_key.environments.append(
Link({
'sys': {
'id': 'master',
'type': 'Link',
'linkType': 'Environment'
}
})
)
api_key.save()
self.assertEqual(len(api_key.environments), 2)
示例3: test_update_entry_field_that_was_undefined_in_the_webapp
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def test_update_entry_field_that_was_undefined_in_the_webapp(self):
entry = None
with vcr.use_cassette('fixtures/entry/undefined_fields.yaml'):
entry = CLIENT.entries(PLAYGROUND_SPACE, 'master').find('33uj74Wln2Oc02CAyEY8CK')
self.assertEqual(entry.fields(), {})
with vcr.use_cassette('fixtures/entry/undefined_fields_write.yaml'):
entry.name = 'foo'
self.assertEqual(entry.fields()['name'], 'foo')
entry.save()
updated_entry = CLIENT.entries(PLAYGROUND_SPACE, 'master').find('33uj74Wln2Oc02CAyEY8CK')
self.assertEqual(updated_entry.fields(), {'name': 'foo'})
示例4: test_update_entry_field_with_field_that_was_not_present
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def test_update_entry_field_with_field_that_was_not_present(self):
entry = None
with vcr.use_cassette('fixtures/entry/added_fields_1.yaml'):
entry = CLIENT.entries(PLAYGROUND_SPACE, 'master').find('3fTNzlQsDmge6YQEikEuME')
self.assertEqual(entry.fields(), {'name': 'A Name', 'other': 'Other Stuff'})
with vcr.use_cassette('fixtures/entry/added_fields_2.yaml'):
entry.different = 'A Different Field'
self.assertEqual(entry.different, 'A Different Field')
self.assertEqual(entry.fields(), {'name': 'A Name', 'other': 'Other Stuff', 'different': 'A Different Field'})
self.assertEqual(entry.to_json()['fields']['different']['en-US'], 'A Different Field')
entry.save()
with vcr.use_cassette('fixtures/entry/added_fields_3.yaml'):
entry = CLIENT.entries(PLAYGROUND_SPACE, 'master').find('3fTNzlQsDmge6YQEikEuME')
self.assertEqual(entry.different, 'A Different Field')
示例5: test_s3_delete_delimiter
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def test_s3_delete_delimiter(self):
"""
See the pre_load_s3_data functions for details on the bucket
contents. structure is as follows:
readme.txt
images/myimages{0-499}.tif
scripts/myscripts{0-399}.py
scripts/subdir/otherscripts{0-109}.sh
"""
# Test delete multiple files
assert len(self.s3.list_contents("scripts/", delimiter="/")) == 400
self.s3.delete("scripts/", delimiter="/")
assert len(self.s3.list_contents("scripts/", delimiter="/")) == 0
#@vcr.use_cassette(cassette_name, filter_headers=['authorization'])
#def test_download(self):
# location = 'gbdxtools/ski_areas.geojson'
# s = S3()
# s.download(location, local_dir=self._temp_path)
# assert os.path.isfile(os.path.join(self._temp_path, 'ski_areas.geojson'))
示例6: validator
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def validator(looker_client, record_mode) -> Iterable[DataTestValidator]:
with vcr.use_cassette(
"tests/cassettes/test_data_test_validator/fixture_validator_init.yaml",
match_on=["uri", "method", "raw_body"],
filter_headers=["Authorization"],
record_mode=record_mode,
):
validator = DataTestValidator(looker_client, project="eye_exam")
yield validator
示例7: validator_pass
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def validator_pass(
self, record_mode, validator
) -> Iterable[Tuple[DataTestValidator, Dict]]:
with vcr.use_cassette(
"tests/cassettes/test_data_test_validator/fixture_validator_pass.yaml",
match_on=["uri", "method", "raw_body", "query"],
filter_headers=["Authorization"],
record_mode=record_mode,
):
validator.build_project(selectors=["eye_exam/users"])
results = validator.validate()
yield validator, results
示例8: validator_fail
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def validator_fail(
self, record_mode, validator
) -> Iterable[Tuple[DataTestValidator, Dict]]:
with vcr.use_cassette(
"tests/cassettes/test_data_test_validator/fixture_validator_fail.yaml",
match_on=["uri", "method", "raw_body", "query"],
filter_headers=["Authorization"],
record_mode=record_mode,
):
validator.build_project(selectors=["eye_exam/users__fail"])
results = validator.validate()
yield validator, results
示例9: looker_client
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def looker_client(record_mode) -> Iterable[LookerClient]:
with vcr.use_cassette(
"tests/cassettes/init_client.yaml",
filter_post_data_parameters=["client_id", "client_secret"],
filter_headers=["Authorization"],
record_mode=record_mode,
):
client = LookerClient(
base_url="https://spectacles.looker.com",
client_id=os.environ.get("LOOKER_CLIENT_ID", ""),
client_secret=os.environ.get("LOOKER_CLIENT_SECRET", ""),
)
client.update_workspace(project="eye_exam", workspace="production")
yield client
示例10: validator
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def validator(looker_client, record_mode) -> Iterable[ContentValidator]:
with vcr.use_cassette(
"tests/cassettes/test_content_validator/fixture_validator_init.yaml",
match_on=["uri", "method", "raw_body"],
filter_headers=["Authorization"],
record_mode=record_mode,
):
validator = ContentValidator(
looker_client, project="eye_exam", exclude_personal=True
)
yield validator
示例11: validator_fail
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def validator_fail(
self, record_mode, validator
) -> Iterable[Tuple[ContentValidator, Dict]]:
with vcr.use_cassette(
"tests/cassettes/test_content_validator/fixture_validator_fail.yaml",
match_on=["uri", "method", "raw_body"],
filter_headers=["Authorization"],
record_mode=record_mode,
):
validator.build_project(selectors=["eye_exam/users__fail"])
results = validator.validate()
yield validator, results
示例12: validator
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def validator(looker_client, record_mode) -> Iterable[SqlValidator]:
with vcr.use_cassette(
"tests/cassettes/test_sql_validator/fixture_validator_init.yaml",
match_on=["uri", "method", "raw_body"],
filter_headers=["Authorization"],
record_mode=record_mode,
):
validator = SqlValidator(looker_client, project="eye_exam")
yield validator
示例13: validator_pass
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def validator_pass(
self, request, record_mode, validator
) -> Iterable[Tuple[SqlValidator, Dict]]:
mode = request.param
with vcr.use_cassette(
f"tests/cassettes/test_sql_validator/fixture_validator_pass[{mode}].yaml",
match_on=["uri", "method", "raw_body"],
filter_headers=["Authorization"],
record_mode=record_mode,
):
validator.build_project(selectors=["eye_exam/users"])
results = validator.validate(mode)
yield validator, results
示例14: validator_fail
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def validator_fail(
self, record_mode, validator
) -> Iterable[Tuple[SqlValidator, Dict]]:
with vcr.use_cassette(
"tests/cassettes/test_sql_validator/fixture_validator_fail.yaml",
match_on=["uri", "method", "raw_body"],
filter_headers=["Authorization"],
record_mode=record_mode,
):
validator.build_project(selectors=["eye_exam/users__fail"])
results = validator.validate(mode="hybrid")
yield validator, results
示例15: test_update_api_key
# 需要導入模塊: import vcr [as 別名]
# 或者: from vcr import use_cassette [as 別名]
def test_update_api_key(self):
api_key = CLIENT.api_keys(PLAYGROUND_SPACE).find('42sVZNadpFAje7EFwHOfVY')
with vcr.use_cassette('fixtures/api_key/update.yaml'):
api_key.name = 'Not Test Key'
api_key.save()
self.assertEqual(api_key.name, 'Not Test Key')