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'))
def test_main_uri_method(self): main(["-X", HTTP_PUT, GOOGLE_URL]) assert_that(self.request_handler_mock.parameters, is_(not_none())) assert_that(str(self.request_handler_mock.parameters[0]), is_(GOOGLE_URL)) assert_that(str(self.request_handler_mock.parameters[1]), is_(HTTP_PUT)) main(["--request", HTTP_DELETE, GOOGLE_URL]) assert_that(self.request_handler_mock.parameters, is_(not_none())) assert_that(str(self.request_handler_mock.parameters[0]), is_(GOOGLE_URL)) assert_that(str(self.request_handler_mock.parameters[1]), is_(HTTP_DELETE))
def test_parse(self): output = MockCli.read_file('snap_-group_-list_-detail.txt') parser = get_vnx_parser('VNXConsistencyGroup') cgs = parser.parse_all(output) cg = next(c for c in cgs if c.name == 'test cg name') assert_that(cg, not_none()) assert_that(cg.state, equal_to('Ready')) cg = next(c for c in cgs if c.name == 'another cg') assert_that(cg, not_none()) assert_that(cg.state, equal_to('Offline'))
def test_parse(self): output = MockCli.read_file('snap_-group_-list_-detail.txt') parser = get_parser_config('VNXConsistencyGroup') cgs = parser.parse_all(output) cg = six.next((c for c in cgs if c.name == 'test cg name'), None) assert_that(cg, not_none()) self.assertEqual([1, 3], cg.lun_list) self.assertEqual('Ready', cg.state) cg = six.next((c for c in cgs if c.name == 'another cg'), None) assert_that(cg, not_none()) self.assertEqual([23, 24], cg.lun_list) self.assertEqual('Offline', cg.state)
def test_create_on_disk_image(self): fitsimage = DownloadedFitsImage(self.strdata, self.coord_converter, self.apcor_str, in_memory=False) # Breaking interface for testing purposes assert_that(fitsimage._hdulist, none()) assert_that(fitsimage._tempfile, not_none())
def test_new_interface_becomes_visible(): """ mdts.tests.functional_tests.test_midolman_and_interfaces.test_new_interface_becomes_visible Scenario: When: On start up, a Midolman sees no interface, Then: adds a new interface, And: Midolman detects a new interface. """ # FIXME: pick the midonet-agent from binding manager (when parallel) midonet_api = get_midonet_api() agent = service.get_container_by_hostname('midolman1') iface_name = 'interface%d' % random.randint(1, 100) new_interface = get_interface( midonet_api, agent.get_midonet_host_id(), iface_name) # Test that no interface with name 'interface_01' exists. assert_that(new_interface, none(), iface_name) # Create a new interface 'interface_01'. iface = agent.create_vmguest(ifname=iface_name) time.sleep(5) new_interface = get_interface( midonet_api, agent.get_midonet_host_id(), iface_name) # Test that the created interface is visible. assert_that(new_interface, not_none(), iface_name) agent.destroy_vmguest(iface)
def test_get_nfc_ticket_with_ds_id(self): datastores = self.vim_client.get_all_datastores() image_datastore = [ds for ds in datastores if ds.name == self.get_image_datastore()][0] request = ServiceTicketRequest(service_type=ServiceType.NFC, datastore_name=image_datastore.id) response = self.host_client.get_service_ticket(request) assert_that(response.result, is_(ServiceTicketResultCode.OK)) ticket = response.ticket assert_that(ticket, not_none()) assert_that(ticket.port, is_(902)) assert_that(ticket.service_type, is_("nfc")) assert_that(ticket.session_id, not_none()) assert_that(ticket.ssl_thumbprint, not_none())
def test_grid_query(self): grid = Grid(11.0, 12.0, 51.0, 52.0, 0.1, 0.2, self.srid) query = self.query_builder.grid_query("<table_name>", grid, count_threshold=0, time_interval=TimeInterval(self.start_time, self.end_time)) assert_that(str(query), is_( "SELECT TRUNC((ST_X(ST_Transform(geog::geometry, %(srid)s)) - %(xmin)s) / %(xdiv)s)::integer AS rx, " "TRUNC((ST_Y(ST_Transform(geog::geometry, %(srid)s)) - %(ymin)s) / %(ydiv)s)::integer AS ry, " "count(*) AS strike_count, max(\"timestamp\") as \"timestamp\" FROM <table_name> " "WHERE ST_GeomFromWKB(%(envelope)s, %(envelope_srid)s) && geog AND " "\"timestamp\" >= %(start_time)s AND \"timestamp\" < %(end_time)s GROUP BY rx, ry")) parameters = query.get_parameters() assert_that(parameters.keys(), contains_inanyorder('xmin', 'ymin', 'xdiv', 'ydiv', 'envelope', 'envelope_srid', 'srid', 'start_time', 'end_time')) assert_that(parameters.keys(), not contains_inanyorder('count_threshold')) assert_that(parameters['xmin'], is_(11.0)) assert_that(parameters['ymin'], is_(51.0)) assert_that(parameters['xdiv'], is_(0.1)) assert_that(parameters['ydiv'], is_(0.2)) assert_that(parameters['envelope'], is_(not_none())) assert_that(parameters['envelope_srid'], is_(self.srid)) assert_that(parameters['start_time'], is_(self.start_time)) assert_that(parameters['end_time'], is_(self.end_time)) assert_that(parameters['srid'], is_(self.srid))
def test_on_disk_as_hdulist(self): fitsimage = DownloadedFitsImage(self.strdata, self.coord_converter, self.apcor_str, in_memory=False) assert_that(fitsimage._hdulist, none()) assert_that(fitsimage.as_hdulist()[0].header["FILENAME"], equal_to("u5780205r_cvt.c0h")) assert_that(fitsimage._hdulist, not_none())
def test_creating_creature_with_ai(self): """ Test that creature can have AI created """ creature = self.creatures(name='rat') assert_that(creature.artificial_intelligence, is_(not_none()))
def test_resolve_entry_point(): """ Resolving an entry point function works without binding. """ registry = Registry() factory = registry.resolve("hello_world") assert_that(factory, is_(not_none()))
def test_property_instance_cache(self): m1 = VNXLun(name='m1', cli=t_cli()) s1 = m1.attached_snapshot s2 = m1.attached_snapshot assert_that(hash(s1), equal_to(hash(s2))) m1.update() s3 = m1.attached_snapshot assert_that(hash(s3), is_not(equal_to(hash(s1)))) assert_that(s1._cli, not_none())
def test_generate_item_with_effect(self): """ Test that item with effect can be generated """ item = self.generator.generate_item(name = 'healing potion') assert_that(item, is_(not_none())) assert_that(item, has_effect_handle())
def test_credentials_have_to_be_JSON(self): data_source = DataSourceFactory() data_source.credentials = 'not-json' assert_that(data_source.validate(), not_none()) data_source.credentials = '{"foo": "bar"}' assert_that(data_source.validate(), none())
def test_inventory_factory_has_been_initialised(self): """ Test that inventory action factory has been initialised """ factory = self.config.action_factory.get_sub_factory( InventoryParameters(character = None, item = None, sub_action = 'pick up')) assert_that(factory, is_(not_none()))
def test_clone(self): with transaction(): company = Company( name="name", type=CompanyType.private, ).create() copy = clone(company, dict(name="newname")) assert_that(copy.id, is_not(equal_to(company.id))) assert_that(self.company_store.retrieve(copy.id), is_(not_none()))
def test_create_sequence_values(self): """ Creating new values should trigger auto increments. """ with SessionContext(self.graph), transaction(): for index in range(10): example = self.store.create(WithSerial()) assert_that(example.id, is_(not_none())) assert_that(example.value, is_(equal_to(index + 1)))
def assert_input_has_correct_label_and_value(self, element_id, label, response, value): assert_that(response.normal_body, contains_string(label)) workbench_input = re.search('<input[^>]* id="{}"[^>]*>'.format(element_id), response.normal_body) assert_that(workbench_input, not_none(), "input file exists with id of {}".format(element_id)) if value is None or value is "": assert_that(workbench_input.group(0), any_of( contains_string('value=""'.format(value)), is_not(contains_string('value="')) )) else: assert_that(workbench_input.group(0), contains_string('value="{}"'.format(value)))
def test_getting_iterator(self): """ Test that iterator can be produced """ item = mock() self.character.inventory.append(item) iterator = self.character.inventory.__iter__() assert_that(iterator, is_(not_none()))
def test_initialisation(self): """ Test that main configuration can be read and initialised properly Note: This test reads configuration from resources directory """ config = self.config assert_that(config.surface_manager, is_(not_none())) assert_that(config.action_factory, is_(not_none())) assert_that(config.item_generator, is_(not_none())) assert_that(config.creature_generator, is_(not_none())) assert_that(config.level_generator_factory, is_(not_none())) assert_that(config.level_size, is_(not_none())) assert_that(config.model, is_(not_none())) assert_that(config.rng, is_(not_none()))
def test_logs_user_in_and_reports_success_when_authentication_succeeds(session, listener): login = Login(session) listener.should_receive("login_successful").with_args("*****@*****.**").once() login.on_success.subscribe(listener.login_successful) user_details = dict(email="*****@*****.**", token="api-token", permissions=("isni.lookup", "isni.assign")) login.authentication_succeeded(user_details) current_user = session.current_user assert_that(current_user, not_none(), "current user") assert_that(current_user.email, equal_to("*****@*****.**"), "user email") assert_that(current_user.api_key, equal_to("api-token"), "user key") assert_that(current_user.permissions, contains_inanyorder("isni.lookup", "isni.assign"), "user permissions")
def test_vector_math(self): result = calculate_relative_vector(1, 1, 0, 1) assert_that(result, not_none()) assert_that(result['x'], close_to(1 / sqrt(3), 0.0001)) assert_that(result['y'], close_to(1 / sqrt(3), 0.0001)) assert_that(result['l'], close_to(1.7, 0.1)) result = calculate_relative_vector(23, 23, 0, 0) assert_that(result, not_none()) assert_that(result['x'], close_to(1 / sqrt(2), 0.0001)) assert_that(result['y'], close_to(1 / sqrt(2), 0.0001)) assert_that(result['l'], close_to(32.5, 0.1)) result = calculate_relative_vector(0, 0, 0, 12) assert_that(result, not_none()) assert_that(result['x'], equal_to(0)) assert_that(result['y'], equal_to(0)) assert_that(result['l'], equal_to(12)) result = calculate_relative_vector(0, 20, 0, 0) assert_that(result, not_none()) assert_that(result['x'], equal_to(0)) assert_that(result['y'], equal_to(1)) assert_that(result['l'], equal_to(20))
def _assert_load_and_dump(data): # load the data as a Swagger object swagger = loads(data) assert_that(swagger, is_(instance_of(Swagger))) # attribute access produces model objects assert_that(swagger.info, is_(instance_of(Info))) assert_that(swagger.info.license, is_(instance_of(License))) assert_that(swagger.consumes, is_(instance_of(MediaTypeList))) assert_that(swagger.paths, is_(instance_of(Paths))) # key access produces model objects path_key = next(iter(swagger.paths.keys())) assert_that(swagger.paths[path_key], is_(instance_of(PathItem))) # index access produces model objects assert_that(swagger.consumes[0], is_(instance_of(MimeType))) # attribute access handles Pythonic syntax assert_that(swagger.base_path, is_(not_none())), assert_that(swagger.basePath, is_(not_none())), # dumping the data back as a raw data returns equivalent input assert_that(dumps(swagger), is_(equal_to_json(data)))
def test_credentials_are_validated_against_provider(self): provider = ProviderFactory( credentials_schema={ "$schema": "http://json-schema.org/schema#", "type": "object", "properties": { "password": {"type": "string"}, }, "required": ["password"], "additionalProperties": False, }) credentials = '{"name": "something"}' data_source = DataSourceFactory(provider=provider, credentials=credentials) assert_that(data_source.credentials, credentials) assert_that(data_source.validate(), not_none()) data_source.credentials = '{"password": "******"}' assert_that(data_source.validate(), none())
def test_add_virtual_nic(self): network_id = "logical_switch_id" vm_location_id = "location_id" nsx_logical_switch = "nsx.LogicalSwitch" backing = vim.vm.device.VirtualEthernetCard.OpaqueNetworkBackingInfo cfg_info = FakeConfigInfo() cfg_info.locationId = vm_location_id cspec = self._update_spec() assert_that(len(cspec.get_spec().deviceChange), equal_to(0)) cspec.add_virtual_nic(cfg_info, network_id) assert_that(len(cspec.get_spec().deviceChange), equal_to(1)) assert_that(cspec.get_spec().deviceChange[0].device, not_none()) device = cspec.get_spec().deviceChange[0].device assert_that(device.externalId, equal_to(vm_location_id)) assert_that(device.backing.__class__, equal_to(backing)) assert_that(device.backing.opaqueNetworkId, equal_to(network_id)) assert_that(device.backing.opaqueNetworkType, equal_to(nsx_logical_switch)) assert_that(device.connectable.connected, equal_to(True)) assert_that(device.connectable.startConnected, equal_to(True))
def test_country_vocabulary(self): from zope.schema import Choice class IA(Interface): choice = Choice(title=u"Choice", vocabulary=u"Countries") o = object() choice = IA['choice'].bind(o) assert_that(choice.vocabulary, is_(not_none())) assert_that('us', is_in(choice.vocabulary)) term = choice.vocabulary.getTermByToken('us') assert_that(term, has_property('value', "United States")) ext = term.toExternalObject() assert_that(ext, has_entry('flag', u'/++resource++country-flags/us.gif')) assert_that(ext, has_entry('title', 'United States')) schema = JsonSchemafier(IA).make_schema() assert_that(schema, has_entry('choice', has_entry('choices', has_item(ext))))
def test_new_interface_becomes_visible(): """ Title: Test new interface becomes visible Scenario: When: On start up, a Midolman sees no interface, Then: adds a new interface, And: Midolman detects a new interface. """ midonet_api = get_midonet_api() new_interface = get_interface( midonet_api, '00000000-0000-0000-0000-000000000001', 'interface_01') # Test that no interface with name 'interface_01' exists. assert_that(new_interface, none(), 'interface interface_01') # Create a new interface 'interface_01'. PTM.build() time.sleep(5) new_interface = get_interface( midonet_api, '00000000-0000-0000-0000-000000000001', 'interface_01') # Test that the created interface is visible. assert_that(new_interface, not_none(), 'interface interface_01.')
def test_doesnt_render_templates_with_modules_without_data_type( self, mock_get_dashboard, mock_render_template): mock_render_template.return_value = '' mock_get_dashboard.return_value = dashboard_data( {'modules': [ {'slug': 'slug'}, {'data_type': 'user-satisfaction-score'}]}) self.client.get('/dashboards/dashboard-uuid') mock_render_template.assert_called_once_with( match_equality('builder/dashboard-hub.html'), dashboard_title=match_equality(not_none()), uuid=match_equality(not_none()), form=match_equality(not_none()), modules=match_equality(['user-satisfaction-score']), preview_url=match_equality(not_none()), environment=match_equality(not_none()), user=match_equality(not_none()), )
def test_sets_info_to_unknown_when_no_organisation( self, transform_mock, dataset_module_mock, get_dashboard_mock, client ): get_dashboard_mock.return_value = { 'organisation': None, 'slug': 'apply-uk-visa' } dataset_module_mock.return_value = {}, {}, {} with self.client.session_transaction() as session: session['upload_choice'] = 'week' client.post( '/dashboard/dashboard-uuid/digital-take-up/channel-options', data=self.params()) # match_equality(not_none()) is used because we dont care what any # arguments are except for the 3rd argument dataset_module_mock.assert_called_with( match_equality(not_none()), match_equality(not_none()), match_equality(not_none()), match_equality(not_none()), match_equality(not_none()), match_equality(has_entries( {'info': has_item(contains_string('Unknown'))} )), match_equality(not_none()), match_equality(not_none()) )
def test_collect(self): phpfpm_pool_metrics_collector = PHPFPMPoolMetricsCollector( object=self.phpfpm_pool_obj, interval=self.phpfpm_pool_obj.intervals['metrics'] ) assert_that(phpfpm_pool_metrics_collector, not_none()) assert_that(self.phpfpm_pool_obj.statsd.current, equal_to({})) # check that current is empty for obj.statsd # run collect phpfpm_pool_metrics_collector.collect() time.sleep(0.1) # run collect a second time for counters phpfpm_pool_metrics_collector.collect() # check that current is not empty assert_that(self.phpfpm_pool_obj.statsd.current, not_(equal_to({}))) """ statsd.current:: { 'counter': { 'php.fpm.queue.req': [[1481301159.456794, 0]], 'php.fpm.slow_req': [[1481301159.456794, 0]], 'php.fpm.conn.accepted': [[1481301159.456794, 1]] }, 'gauge': { 'php.fpm.proc.max_active': [(1481301159.355574, '1'), (1481301159.456794, '1')], 'php.fpm.proc.max_child': [(1481301159.355574, '0'), (1481301159.456794, '0')], 'php.fpm.queue.len': [(1481301159.355574, '0'), (1481301159.456794, '0')], 'php.fpm.queue.max': [(1481301159.355574, '0'), (1481301159.456794, '0')], 'php.fpm.proc.idle': [(1481301159.355574, '1'), (1481301159.456794, '1')], 'php.fpm.proc.total': [(1481301159.355574, '2'), (1481301159.456794, '2')], 'php.fpm.proc.active': [(1481301159.355574, '1'), (1481301159.456794, '1')], } } """ counters = self.phpfpm_pool_obj.statsd.current['counter'] assert_that(counters, has_length(3)) gauges = self.phpfpm_pool_obj.statsd.current['gauge'] assert_that(gauges, has_length(7)) # run parent collect and check that child inserted metrics appropriately self.phpfpm_obj.collectors[1].collect() time.sleep(0.1) # need to run a second collect cycle for counters to populate in parent phpfpm_pool_metrics_collector.collect() time.sleep(0.1) self.phpfpm_obj.collectors[1].collect() time.sleep(0.1) # check parent to see also not empty assert_that(self.phpfpm_obj.statsd.current, not_(equal_to({}))) counters = self.phpfpm_obj.statsd.current['counter'] assert_that(counters, has_length(3)) gauges = self.phpfpm_obj.statsd.current['gauge'] assert_that(gauges, has_length(7))
def step_impl(context): assert_that(context.payload, not_none())
def step_impl(context): """ :type context: behave.runner.Context """ assert_that(context.handler.message, not_none())
def test_should_return_next_unprocessed_claim(self): add_claim({}, {}) claim = get_next_claim_not_processed_by_chomp() assert_that(claim, is_(not_none()))
def test_column_declarations(self): assert_that(TaskEvent.clock, is_(not_none())) assert_that(TaskEvent.event_type, is_(not_none())) assert_that(TaskEvent.task_id, is_(not_none())) assert_that(TaskEvent.parent_id, is_(not_none())) assert_that(TaskEvent.version, is_(not_none()))
def step_impl(context): """ :type context: behave.runner.Context """ assert_that(context.handler.data, not_none()) assert_that(context.response, not_none())
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()))
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))
def test_signup(pet_store_client): response = pet_store_client.signup_user(user1) assert_that(response.status_code, is_(200)) new_user = response.json() assert_that(new_user['id'], not_none())
def has_media_type(match=None): # NB: if no matcher is provider, just check that *some* media type exists if match is None: match = not_none() return PublishedMessageMatcher("media_type", wrap_matcher(match))
def with_id(): return has_entry('uuid', not_none())
def test__handle_portfolio_with_asset_with_dot_in_name(currency: Currency): p = y.portfolio(assets={'ny/BRK.B': 1}, currency=currency.name) assert_that(p, not_none()) assert_that(p.assets, has_length(1)) assert_that(p.rate_of_return(), is_not(empty()))
def test_signup(skyeng_client): response = skyeng_client.signup_user(user_admin) assert_that(response.status_code, is_(200)) new_user = response.json() assert_that(new_user['id'], not_none())
def has_uri(match=None): # NB: if no matcher is provider, just check that *some* uri exists if match is None: match = not_none() return PublishedMessageMatcher("uri", wrap_matcher(match))
def validate_account_last_activity(context): account_repo = AccountRepository(context.db) account = account_repo.get_account_by_device_id(context.device_login["uuid"]) assert_that(account.last_activity, not_none()) assert_that(account.last_activity.date(), equal_to(datetime.utcnow().date()))
def assert_has_child_with_label(self, parent, label): assert_that(self.get_child_by_label(parent, label), not_none())
def add_default_matchers(compiler: MatcherFactoryCompiler) -> None: """ Add default matchers to a compiler. Args: compiler: A compiler to be modified. """ compiler.add_recursive(("be", ), hamcrest.is_, multiple=False) # For objects. compiler.add_static(("be_null", ), hamcrest.none()) compiler.add_static(("not_be_null", ), hamcrest.not_none()) compiler.add_static(("be_monday", ), day_of_week(0)) compiler.add_static(("be_tuesday", ), day_of_week(1)) compiler.add_static(("be_wednesday", ), day_of_week(2)) compiler.add_static(("be_thursday", ), day_of_week(3)) compiler.add_static(("be_friday", ), day_of_week(4)) compiler.add_static(("be_saturday", ), day_of_week(5)) compiler.add_static(("be_sunday", ), day_of_week(6)) compiler.add_taking_value(("equal", ), hamcrest.equal_to) compiler.add_recursive(("have_length", ), hamcrest.has_length, multiple=False) # For comparable values. compiler.add_taking_value(("be_greater_than", ), hamcrest.greater_than) compiler.add_taking_value(("be_greater_than_or_equal_to", ), hamcrest.greater_than_or_equal_to) compiler.add_taking_value(("be_less_than", ), hamcrest.less_than) compiler.add_taking_value(("be_less_than_or_equal_to", ), hamcrest.less_than_or_equal_to) # For strings. compiler.add_taking_value(("contain_string", ), require_type(str, hamcrest.contains_string)) compiler.add_taking_value(("start_with", ), require_type(str, hamcrest.starts_with)) compiler.add_taking_value(("end_with", ), require_type(str, hamcrest.ends_with)) compiler.add_taking_value(("match_regexp", ), require_type(str, hamcrest.matches_regexp)) # For collections. compiler.add_recursive(("have_item", ), hamcrest.has_item, multiple=False) compiler.add_recursive(("have_items", ), hamcrest.has_items) compiler.add_recursive(("contain_exactly", ), hamcrest.contains_exactly) compiler.add_recursive(("contain_in_any_order", ), hamcrest.contains_inanyorder) # For datetime. compiler.add_taking_value(("be_before", ), before, parse_datetime_value_with_format) compiler.add_taking_value(("be_after", ), after, parse_datetime_value_with_format) # For collections. compiler.add_static(("be_empty", ), StaticMatcherFactory(hamcrest.empty())) # Logical. compiler.add_static("anything", StaticMatcherFactory(hamcrest.anything())) compiler.add_recursive(("not", ), hamcrest.not_, multiple=False) compiler.add_recursive(("all_of", ), hamcrest.all_of) compiler.add_recursive(("any_of", ), hamcrest.any_of)
def test_client_is_instantiable(self): assert_that(self.client, not_none())
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())
def check_error_message_exists(context): """Check that an error message was returned.""" assert_that(context.response.data, not_none())
def test__risk(self, portfolio, period): assert_that(portfolio.risk(period=period), not_none())
def test_try_import_normal(self): mod = try_import('os') assert_that(mod, not_none())
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()))
def test_site_sync(self): for site in _SITES: assert_that(_find_site_components((site.__name__,)), is_(not_none())) with mock_db_trans() as conn: for site in _SITES: assert_that(_find_site_components((site.__name__,)), is_(not_none())) ds = conn.root()['nti.dataserver'] assert ds is not None sites = ds['++etc++hostsites'] for site in _SITES: assert_that(sites, does_not(has_key(site.__name__))) synchronize_host_policies() synchronize_host_policies() assert_that(self._events, has_length(len(_SITES))) # These were put in in order # assert_that( self._events[0][0].__parent__, # has_property('__name__', EVAL.__name__)) # XXX These two lines are cover only. get_host_site(DEMO.__name__) get_host_site('DNE', True) assert_that(calling(get_host_site).with_args('dne'), raises(LookupError)) with mock_db_trans() as conn: for site in _SITES: assert_that(_find_site_components((site.__name__,)), is_(not_none())) ds = conn.root()['nti.dataserver'] assert ds is not None sites = ds['++etc++hostsites'] assert_that(sites, has_key(EVAL.__name__)) assert_that(sites[EVAL.__name__], verifiably_provides(ISite)) # If we ask the demoalpha persistent site for an ITestSyteSync, # it will find us, because it goes to the demo global site assert_that(sites[DEMOALPHA.__name__].getSiteManager().queryUtility(ITestSiteSync), is_(ASync)) # However, if we put something in the demo *persistent* site, it # will find that sites[DEMO.__name__].getSiteManager().registerUtility(OtherSync()) assert_that(sites[DEMOALPHA.__name__].getSiteManager().queryUtility(ITestSiteSync), is_(OtherSync)) # Verify the resolution order too def _name(x): if x.__name__ == '++etc++site': return 'P' + str(x.__parent__.__name__) return x.__name__ assert_that([_name(x) for x in ro.ro(sites[DEMOALPHA.__name__].getSiteManager())], is_([u'Pdemo-alpha.nextthoughttest.com', u'demo-alpha.nextthoughttest.com', u'Pdemo.nextthoughttest.com', u'demo.nextthoughttest.com', u'Peval.nextthoughttest.com', u'eval.nextthoughttest.com', u'Pdataserver2', u'PNone', 'base'])) # including if we ask to travers from top to bottom names = list() def func(): names.append(_name(component.getSiteManager())) run_job_in_all_host_sites(func) # Note that PDemo and Peval-alpha are arbitrary, they both # descend from eval; # TODO: why aren't we maintaining alphabetical order? # we should be, but sometimes we don't assert_that(names, is_(any_of( [u'Peval.nextthoughttest.com', u'Pdemo.nextthoughttest.com', u'Peval-alpha.nextthoughttest.com', u'Pdemo-alpha.nextthoughttest.com'], [u'Peval.nextthoughttest.com', u'Peval-alpha.nextthoughttest.com', u'Pdemo.nextthoughttest.com', u'Pdemo-alpha.nextthoughttest.com']))) # And that it's what we get back if we ask for it assert_that(get_site_for_site_names((DEMOALPHA.__name__,)), is_(same_instance(sites[DEMOALPHA.__name__]))) # No new sites created assert_that(self._events, has_length(len(_SITES)))
def test_it(self): import py_elastic_int_testing assert_that(py_elastic_int_testing, hamcrest.not_none())
def test__all_data_should_be_available(): assert_that(y.information(name='us/MSFT'), not_none()) assert_that(y.information(name='micex/FXRU'), not_none()) assert_that(y.information(name='micex/FXMM'), not_none()) assert_that(y.information(name='index/MCFTR'), not_none()) assert_that(y.information(name='index/IMOEX'), not_none()) assert_that(y.information(name='index/OKID10'), not_none()) assert_that(y.information(name='index/^STOXX50E'), not_none()) assert_that(y.information(name='mut_ru/0890-94127385'), not_none()) assert_that(y.information(name='cbr/USD'), not_none()) assert_that(y.information(name='cbr/EUR'), not_none()) assert_that(y.information(name='infl/RUB'), not_none()) assert_that(y.information(name='infl/USD'), not_none()) assert_that(y.information(name='infl/EUR'), not_none()) assert_that(y.information(name='cbr/TOP_rates'), not_none())
def test__get_cagr(self, portfolio, years_ago, real): assert_that(portfolio.cagr(years_ago=years_ago, real=real), not_none())
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()))
def test_init(self): phpfpm_meta_collector = PHPFPMMetaCollector( object=self.phpfpm_obj, interval=self.phpfpm_obj.intervals['meta']) assert_that(phpfpm_meta_collector, not_none()) assert_that(phpfpm_meta_collector, is_(PHPFPMMetaCollector))
def test__get_return(self, portfolio, kind, real): assert_that(portfolio.get_return(kind=kind, real=real), not_none())
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())