本文整理汇总了Python中hamcrest.not_none方法的典型用法代码示例。如果您正苦于以下问题:Python hamcrest.not_none方法的具体用法?Python hamcrest.not_none怎么用?Python hamcrest.not_none使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hamcrest
的用法示例。
在下文中一共展示了hamcrest.not_none方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validate_response
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def validate_response(context):
assert_that(context.response.status_code, equal_to(HTTPStatus.OK))
response_data = json.loads(context.response.data)
expected_response = ['tell me a joke']
assert_that(response_data, equal_to(expected_response))
resources_dir = os.path.join(os.path.dirname(__file__), 'resources')
with open(os.path.join(resources_dir, 'test_stt.flac'), 'rb') as input_file:
input_file_content = input_file.read()
flac_file_path = _get_stt_result_file(context.account.id, '.flac')
assert_that(flac_file_path, not_none())
with open(flac_file_path, 'rb') as output_file:
output_file_content = output_file.read()
assert_that(input_file_content, equal_to(output_file_content))
stt_file_path = _get_stt_result_file(context.account.id, '.stt')
assert_that(stt_file_path, not_none())
with open(stt_file_path, 'rb') as output_file:
output_file_content = output_file.read()
assert_that(b'tell me a joke', equal_to(output_file_content))
示例2: step_impl
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def step_impl(context):
time.sleep(15)
analyzer_job_terminated = False
analyzer_job_termination_retries = 0
while not analyzer_job_terminated:
time.sleep(10)
analyzer_job_id = context.response['pod_id']
r = requests.get(f'{context.endpoint_url}/status/{analyzer_job_id}')
assert_that(r.status_code, equal_to(HTTPStatus.OK))
assert_that(r.headers['content-type'], equal_to('application/json'))
response = r.json()
assert_that(response, not_none)
if 'terminated' in response['status'].keys():
if response['status']['terminated']['reason'].startswith('Completed'):
analyzer_job_terminated = True
analyzer_job_termination_retries += 1
assert_that(analyzer_job_termination_retries, less_than(10))
示例3: check_db_for_account
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def check_db_for_account(context):
acct_repository = AccountRepository(context.db)
account = acct_repository.get_account_by_email('bar@mycroft.ai')
# add account to context so it will deleted by cleanup step
context.accounts['bar'] = account
assert_that(account, not_none())
assert_that(
account.email_address, equal_to('bar@mycroft.ai')
)
assert_that(len(account.agreements), equal_to(2))
for agreement in account.agreements:
assert_that(agreement.type, is_in((PRIVACY_POLICY, TERMS_OF_USE)))
assert_that(agreement.accept_date, equal_to(str(date.today())))
示例4: validate_response
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def validate_response(context):
device_id = context.response.data.decode()
account = context.accounts['foo']
db = connect_to_db(context.client_config['DB_CONNECTION_CONFIG'])
device_repository = DeviceRepository(db)
device = device_repository.get_device_by_id(device_id)
assert_that(device, not_none())
assert_that(device.name, equal_to('Selene Test Device'))
assert_that(device.placement, equal_to('Mycroft Offices'))
assert_that(device.account_id, equal_to(account.id))
示例5: validate_etag
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def validate_etag(context):
response = context.get_location_response
new_location_etag = response.headers.get('ETag')
assert_that(new_location_etag, not_none())
assert_that(new_location_etag, is_not(context.expired_location_etag))
示例6: get_new_skill
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def get_new_skill(context):
skill_repo = SkillRepository(context.db)
skill = skill_repo.get_skill_by_global_id(
context.new_skill.skill_gid
)
assert_that(skill, is_(not_none()))
示例7: check_device_last_contact
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def check_device_last_contact(context):
key = DEVICE_LAST_CONTACT_KEY.format(device_id=context.device_id)
value = context.cache.get(key).decode()
assert_that(value, not_none())
last_contact_ts = datetime.strptime(value, '%Y-%m-%d %H:%M:%S.%f')
assert_that(last_contact_ts.date(), equal_to(datetime.utcnow().date()))
示例8: fetch_device_expired_etag
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def fetch_device_expired_etag(context):
etag = context.device_etag
assert_that(etag, not_none())
access_token = context.device_login['accessToken']
device_uuid = context.device_login['uuid']
headers = {
'Authorization': 'Bearer {token}'.format(token=access_token),
'If-None-Match': etag
}
context.response_using_invalid_etag = context.client.get(
'/v1/device/{uuid}'.format(uuid=device_uuid),
headers=headers
)
示例9: test_tables_broken_schema
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def test_tables_broken_schema(self, simpsons_broken_dataset):
assert_that(calling(simpsons_broken_dataset.tables.get).with_args(
'simpsons_episodes'), not_(raises(Exception)))
assert_that(simpsons_broken_dataset.tables.get('simpsons_episodes'),
not_none())
示例10: test_dataframe_broken_schema
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def test_dataframe_broken_schema(self, simpsons_broken_dataset):
assert_that(calling(simpsons_broken_dataset.dataframes.get).with_args(
'simpsons_episodes'), not_(raises(Exception)))
assert_that(simpsons_broken_dataset.dataframes.get(
'simpsons_episodes'), not_none())
示例11: test_vnx_availability
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def test_vnx_availability(self):
vnx = storops.VNXSystem('10.244.211.30', heartbeat_interval=0)
assert_that(vnx, not_none())
示例12: test_unity_availability
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def test_unity_availability(self):
unity = storops.UnitySystem('1.1.1.1', 'admin', 'password')
assert_that(unity, not_none())
示例13: test_vnx_enum_availability
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def test_vnx_enum_availability(self):
spa = storops.VNXSPEnum.SP_A
assert_that(spa, not_none())
示例14: test_unity_enum_availability
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def test_unity_enum_availability(self):
raid5 = storops.RaidTypeEnum.RAID5
assert_that(raid5, not_none())
示例15: test_parse_multi_index
# 需要导入模块: import hamcrest [as 别名]
# 或者: from hamcrest import not_none [as 别名]
def test_parse_multi_index(self):
output = """
A: a0
B: b0
C: c0
A: a0
B: b0
D: d0
A: a0
B: b1
C: c1
"""
parsed = DemoParserMultiIndices().parse_all(output)
assert_that(len(parsed), equal_to(2))
a0b0 = next(i for i in parsed if i.b == 'b0')
assert_that(a0b0, not_none())
assert_that(a0b0.a, equal_to('a0'))
assert_that(a0b0.b, equal_to('b0'))
assert_that(a0b0.c, equal_to('c0'))
assert_that(a0b0.d, equal_to('d0'))
a0b1 = next(i for i in parsed if i.b == 'b1')
assert_that(a0b1, not_none())
assert_that(a0b1.a, equal_to('a0'))
assert_that(a0b1.b, equal_to('b1'))
assert_that(a0b1.c, equal_to('c1'))