Python hamcrest.not_none() Examples

The following are 30 code examples of hamcrest.not_none(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module hamcrest , or try the search function .
Example #1
Source File: get_utterance.py    From selene-backend with GNU Affero General Public License v3.0 6 votes vote down vote up
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)) 
Example #2
Source File: user_api_steps.py    From core with GNU General Public License v3.0 6 votes vote down vote up
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)) 
Example #3
Source File: user_api_steps.py    From core with GNU General Public License v3.0 5 votes vote down vote up
def step_impl(context):
    assert_that(context.response, not_none)

    analyzer_job_id = context.response['pod_id']
    assert_that(analyzer_job_id, not_none)

    context.analyzer_job_id = analyzer_job_id 
Example #4
Source File: test_inflation.py    From cifrum with GNU General Public License v3.0 5 votes vote down vote up
def test__gmean_inflation_for_less_than_year(pcf: PortfolioCurrencyFactory):
    pc = pcf.new(currency=Currency.USD)

    assert_that(pc.inflation(kind='g_mean',
                             start_period=pd.Period('2017-1', freq='M'),
                             end_period=pd.Period('2018-1', freq='M')),
                not_none())
    assert_that(pc.inflation(kind='g_mean',
                             start_period=pd.Period('2017-5', freq='M'),
                             end_period=pd.Period('2018-1', freq='M')),
                none()) 
Example #5
Source File: test_portfolio_statistics.py    From cifrum with GNU General Public License v3.0 5 votes vote down vote up
def test__get_return(self, portfolio, kind, real):
        assert_that(portfolio.get_return(kind=kind, real=real), not_none()) 
Example #6
Source File: test_portfolio_statistics.py    From cifrum with GNU General Public License v3.0 5 votes vote down vote up
def test__risk(self, portfolio, period):
        assert_that(portfolio.risk(period=period), not_none()) 
Example #7
Source File: test_portfolio_statistics.py    From cifrum with GNU General Public License v3.0 5 votes vote down vote up
def test__handle_portfolio_with_asset_with_dash_in_name(currency: Currency):
    p = lib.portfolio(assets={'us/BRK-B': 1}, currency=currency.name)
    assert_that(p, not_none())
    assert_that(p.assets, has_length(1))
    assert_that(p.get_return(), is_not(empty())) 
Example #8
Source File: test_portfolio_statistics.py    From cifrum with GNU General Public License v3.0 5 votes vote down vote up
def test__handle_assets_with_monthly_data_gaps(currency: Currency):
    p = lib.portfolio(assets={'micex/KUBE': 1}, currency=currency.name)
    assert_that(p, not_none())
    assert_that(p.assets, has_length(1))
    assert_that(p.get_return(), is_not(empty())) 
Example #9
Source File: result.py    From allure-python with Apache License 2.0 5 votes vote down vote up
def with_id():
    return has_entry('uuid', not_none()) 
Example #10
Source File: naming_service_steps.py    From core with GNU General Public License v3.0 5 votes vote down vote up
def step_impl(context):
    context.naming_service_endpoint_url = 'http://naming-service-thoth-test-core.cloud.upshift.engineering.redhat.com/api/v0alpha0'

    r = requests.get(f'{context.naming_service_endpoint_url}/solvers')

    assert_that(r.status_code, equal_to(HTTPStatus.OK))
    assert_that(r.headers['content-type'], equal_to('application/json'))

    solvers = r.json()
    assert_that(solvers['items'], not_none)
    context.solvers = solvers['items'] 
Example #11
Source File: user_api_steps.py    From core with GNU General Public License v3.0 5 votes vote down vote up
def step_impl(context, a_container_image, analyzer_image):
    payload = {
        'image': a_container_image,
        'analyzer': analyzer_image
    }

    r = requests.post(f'{context.endpoint_url}/analyze', params=payload)

    assert_that(r.status_code, equal_to(HTTPStatus.ACCEPTED))
    assert_that(r.headers['content-type'], equal_to('application/json'))

    response = r.json()
    assert_that(response, not_none)
    context.response = response 
Example #12
Source File: test_portfolio_assets.py    From cifrum with GNU General Public License v3.0 5 votes vote down vote up
def test__create_portfolio_with_default_values():
    assets = {
        'micex/FXRU': 1.,
        'mut_ru/0890-94127385': 1.
    }
    period_start = pd.Period('2014-1', freq='M')
    period_now = pd.Period.now(freq='M')
    assert period_now == pd.Period('2019-2', freq='M')

    p1 = lib.portfolio(assets=assets, currency='rub')
    assert_that(p1, not_none())
    assert_that(p1.assets, has_length(2))
    assert p1.get_return().start_period == period_start
    assert p1.get_return().end_period == period_now - 1

    sp2 = pd.Period('2017-1', freq='M')
    p2 = lib.portfolio(assets=assets, start_period=str(sp2), currency='rub')
    assert_that(p2, not_none())
    assert_that(p2.assets, has_length(2))
    assert p2.get_return().start_period == sp2 + 1
    assert p2.get_return().end_period == period_now - 1

    ep3 = pd.Period('2018-3', freq='M')
    p3 = lib.portfolio(assets=assets, end_period=str(ep3), currency='rub')
    assert_that(p3, not_none())
    assert_that(p3.assets, has_length(2))
    assert p3.get_return().start_period == period_start
    assert p3.get_return().end_period == ep3 
Example #13
Source File: user_api_steps.py    From core with GNU General Public License v3.0 5 votes vote down vote up
def step_impl(context):
    analyzer_job_id = context.response['pod_id']
    r = requests.get(
        f'{context.endpoint_url}/log/{analyzer_job_id}')

    assert_that(r.status_code, equal_to(HTTPStatus.OK))
    assert_that(r.headers['content-type'], equal_to('application/json'))

    analyzer_job_log = r.json()
    assert_that(analyzer_job_log, not_none) 
Example #14
Source File: result_api_steps.py    From core with GNU General Public License v3.0 5 votes vote down vote up
def step_impl(context):
    r = requests.get(f'{context.endpoint_url}/solve')

    assert_that(r.status_code, equal_to(HTTPStatus.OK))
    assert_that(r.headers['content-type'], equal_to('application/json'))

    result_list = r.json()
    assert_that(result_list, not_none)
    context.result_list = result_list['results'] 
Example #15
Source File: result_api_steps.py    From core with GNU General Public License v3.0 5 votes vote down vote up
def step_impl(context):
    assert_that(len(context.result_list), not equal_to(0))

    # TODO this could be a little bit more random choice
    context.chosen_result = context.result_list[0]

    r = requests.get(f'{context.endpoint_url}/analyze/{context.chosen_result}')
    assert_that(r.status_code, equal_to(HTTPStatus.OK))
    assert_that(r.headers['content-type'], equal_to('application/json'))

    chosen_result_json = r.json()
    assert_that(chosen_result_json, not_none)
    context.chosen_result_json = chosen_result_json 
Example #16
Source File: result_api_steps.py    From core with GNU General Public License v3.0 5 votes vote down vote up
def step_impl(context):
    assert_that(len(context.result_list), not equal_to(0))

    # TODO this could be a little bit more random choice
    context.chosen_result = context.result_list[len(context.result_list)-1]

    r = requests.get(f'{context.endpoint_url}/solve/{context.chosen_result}')
    assert_that(r.status_code, equal_to(HTTPStatus.OK))
    assert_that(r.headers['content-type'], equal_to('application/json'))

    chosen_result_json = r.json()
    assert_that(chosen_result_json, not_none)
    context.chosen_result_json = chosen_result_json 
Example #17
Source File: result_api_steps.py    From core with GNU General Public License v3.0 5 votes vote down vote up
def step_impl(context):
    analyzer_job_id = context.response['pod_id']
    r = requests.get(
        f'{context.endpoint_url}/analyze/{context.analyzer_job_id}')

    assert_that(r.status_code, equal_to(HTTPStatus.OK))
    assert_that(r.headers['content-type'], equal_to('application/json'))
    analyzer_result_json = r.json()
    assert_that(analyzer_result_json, not_none)
    context.latest_analyzer_result = analyzer_result_json 
Example #18
Source File: test_inflation.py    From cifrum with GNU General Public License v3.0 5 votes vote down vote up
def test__exists_for_all_currencies(pcf: PortfolioCurrencyFactory, currency: Currency, inflation_kind: str):
    pc = pcf.new(currency=currency)
    infl = pc.inflation(kind=inflation_kind, end_period=__end_period, years_ago=4)
    assert_that(infl, not_none()) 
Example #19
Source File: add_account.py    From selene-backend with GNU Affero General Public License v3.0 5 votes vote down vote up
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()))) 
Example #20
Source File: test_portfolio_assets.py    From cifrum with GNU General Public License v3.0 5 votes vote down vote up
def test__handle_asset_with_dash_in_name():
    asset = lib.portfolio_asset(name='us/BRK-B')
    assert_that(asset, not_none())
    assert_that(asset.close(), is_not(empty())) 
Example #21
Source File: test_system.py    From storops with Apache License 2.0 5 votes vote down vote up
def test_domain():
    assert_that(vnx.spa_ip, not_none())
    assert_that(vnx.spb_ip, not_none())
    assert_that(vnx.control_station_ip, not_none()) 
Example #22
Source File: test_parsers.py    From storops with Apache License 2.0 5 votes vote down vote up
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')) 
Example #23
Source File: __init__.py    From storops with Apache License 2.0 5 votes vote down vote up
def test_unity_enum_availability(self):
        raid5 = storops.RaidTypeEnum.RAID5
        assert_that(raid5, not_none()) 
Example #24
Source File: __init__.py    From storops with Apache License 2.0 5 votes vote down vote up
def test_vnx_enum_availability(self):
        spa = storops.VNXSPEnum.SP_A
        assert_that(spa, not_none()) 
Example #25
Source File: __init__.py    From storops with Apache License 2.0 5 votes vote down vote up
def test_unity_availability(self):
        unity = storops.UnitySystem('1.1.1.1', 'admin', 'password')
        assert_that(unity, not_none()) 
Example #26
Source File: __init__.py    From storops with Apache License 2.0 5 votes vote down vote up
def test_vnx_availability(self):
        vnx = storops.VNXSystem('10.244.211.30', heartbeat_interval=0)
        assert_that(vnx, not_none()) 
Example #27
Source File: test_dataset.py    From data.world-py with Apache License 2.0 5 votes vote down vote up
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()) 
Example #28
Source File: test_dataset.py    From data.world-py with Apache License 2.0 5 votes vote down vote up
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()) 
Example #29
Source File: get_device.py    From selene-backend with GNU Affero General Public License v3.0 5 votes vote down vote up
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
    ) 
Example #30
Source File: common.py    From selene-backend with GNU Affero General Public License v3.0 5 votes vote down vote up
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()))