def returns_from_inner_and_outer_function_can_be_distinguished(): program = """ def answer(): def f(): return 42 return float(f()) print(answer()) """ trace = _run_and_trace(program) assert_that(trace, m.has_items( m.has_properties({ "location": m.has_properties({ "lineno": 2, "col_offset": 0 }), "returns": describe(float) }), m.has_properties({ "location": m.has_properties({ "lineno": 3, "col_offset": 4 }), "returns": describe(int) }), ))
def tests_loads_data_from_settings_file_preferences_group(store, driver): driver["preferences/locale"] = "fr" driver["preferences/artwork location"] = "/artwork" preferences = store.load_preferences() assert_that(preferences, has_properties(locale="fr")) assert_that(preferences, has_properties(artwork_location="/artwork"))
def _has_joel_miller(): return has_properties(id="0000000123456789", first_name="Joel", last_name="Miller", date_of_birth="1969", date_of_death="2100", type="individual", works=contains(has_properties(title="Chevere!")))
def test_encrypted(self): with SessionContext(self.graph): with transaction(): encryptable = self.encryptable_store.create( Encryptable( key="private", value="value", ), ) assert_that( encryptable, has_properties( key=is_(equal_to("private")), value=is_(none()), encrypted_id=is_not(none()), ), ) assert_that( encryptable._members(), is_(equal_to(dict( created_at=encryptable.created_at, encrypted_id=encryptable.encrypted_id, id=encryptable.id, key=encryptable.key, updated_at=encryptable.updated_at, ))), ) assert_that( self.encryptable_store.count(), is_(equal_to(1)), ) assert_that( self.encrypted_store.count(), is_(equal_to(1)), ) # NB: ORM events will not trigger if we can reuse the object from the session cache self.encryptable_store.expunge(encryptable) encryptable = self.encryptable_store.retrieve(encryptable.id) assert_that( encryptable, has_properties( key=is_(equal_to("private")), value=is_(equal_to("value")), encrypted_id=is_not(none()), ), ) with transaction(): self.encryptable_store.delete(encryptable.id) assert_that( self.encryptable_store.count(), is_(equal_to(0)), ) assert_that( self.encrypted_store.count(), is_(equal_to(0)), )
def test_given_2_incalls_on_same_user_then_returns_two_items(self): user_line_row = self.add_user_line_with_exten(exten='1000', context='default') extension_row = self.add_extension(exten='1000', context='from-extern') second_extension_row = self.add_extension(exten='1001', context='from-extern') self.create_incall_row_for_user(user_line_row.user_id, extension_row.id) self.create_incall_row_for_user(user_line_row.user_id, second_extension_row.id) result = dao.find_all_line_extensions_by_line_id(user_line_row.line_id) assert_that(result, has_items( has_properties(line_id=user_line_row.line_id, extension_id=extension_row.id), has_properties(line_id=user_line_row.line_id, extension_id=second_extension_row.id)))
def test_two_suite_params(reports_for): reports = reports_for(test_A=""" 'suite_A' def test(): pass """, test_B=""" 'suite_B' def test(): pass""") assert_that(reports, contains_inanyorder( has_properties({'{}name': 'test_A', '{}description': 'suite_A'}), has_properties({'{}name': 'test_B', '{}description': 'suite_B'}), ))
def type_of_return_with_explicit_value_is_traced(): program = """ def answer(): return 42 print(answer()) """ trace = _run_and_trace(program) assert_that(trace, m.has_item(m.has_properties({ "location": m.has_properties({ "lineno": 2, "col_offset": 0 }), "returns": describe(int) })))
def type_of_return_with_implicit_value_is_traced(): program = """ def do_nothing(): return print(do_nothing()) """ trace = _run_and_trace(program) assert_that(trace, m.has_item(m.has_properties({ "location": m.has_properties({ "lineno": 2, "col_offset": 0 }), "returns": describe(type(None)) })))
def test_update_with_key(self): with SessionContext(self.graph): with transaction(): encryptable = self.encryptable_store.create( Encryptable( key="private", value="value", ), ) with SessionContext(self.graph): with transaction(): res = self.encryptable_store.update( encryptable.id, Encryptable( id=encryptable.id, # Pass the key key="private", value="new-value", ), ) assert_that( res, has_properties( key=is_(equal_to("private")), value=is_(equal_to("new-value")), encrypted_id=is_not(none()), ), ) with SessionContext(self.graph): encryptable = self.encryptable_store.retrieve(encryptable.id) assert_that( encryptable, has_properties( key=is_(equal_to("private")), value=is_(equal_to("new-value")), encrypted_id=is_not(none()), ), ) assert_that( self.encryptable_store.count(), is_(equal_to(1)), ) assert_that( self.encrypted_store.count(), is_(equal_to(1)), )
def test_given_sip_account_when_querying_then_same_sip_account_row_is_returned(self): sip = self.add_usersip(category='user') self.add_line(protocol='sip', protocolid=sip.id) results = asterisk_conf_dao.find_sip_user_settings() assert_that(results, contains(has_properties(UserSIP=sip)))
def props_of_company_buyingstatus_value(): lo = LimeObjects(f.lime_client).get_object('company', 1001) assert_that(lo.fields['buyingstatus'].value, has_properties({ 'key': 'prospect', 'id': 108501, 'localname': 'Prospekt' }))
def type_of_raised_exception_is_traced(): program = """ def do_nothing(): assert False print(do_nothing()) """ trace = _run_and_trace(program) assert_that(trace, m.has_item(m.has_properties({ "location": m.has_properties({ "lineno": 2, "col_offset": 0 }), "returns": None, "raises": describe(AssertionError) })))
def location_of_functions_is_stored(): program_source = """ def repeat(x, y): return x * y print(repeat("hello ", 3)) """ with program_with_module(program_source) as program: trace = farthing.trace(trace_paths=[program.directory_path], argv=[program.run_path]) assert_that(trace, m.contains(m.has_properties({ "location": m.has_properties({ "path": program.module_path, "lineno": 2, "col_offset": 0 }), })))
def test_update_dataset(self, api_client, datasets_api, dataset_key): patch_request = {'tags': ['tag1', 'tag2']} api_client.update_dataset(dataset_key, **patch_request) assert_that(datasets_api.patch_dataset, called().times(1).with_args(equal_to('agentid'), equal_to('datasetid'), has_properties(patch_request)))
def step_with(name, start, stop, status): return has_properties(name=name, title=name, attrib=all_of( has_entry('start', has_float(greater_than_or_equal_to(start))), has_entry('stop', has_float(less_than_or_equal_to(stop))), has_entry('status', status)))
def test_object(): """ Can create a class for an object schema. """ registry = Registry() registry.load(schema_for("data/name.json")) Name = registry.create_class(NAME_ID) name = Name( first="George", ) assert_that(calling(name.validate), raises(ValidationError)) name.last = "Washington" name.validate() assert_that( name, has_properties( first=equal_to("George"), last=equal_to("Washington"), ) ) assert_that(name, is_(equal_to(NAME))) assert_that(name, is_(equal_to(Name(**NAME)))) assert_that(Name.loads(name.dumps()), is_(equal_to(name))) del name.first assert_that(calling(name.validate), raises(ValidationError))
def test_creating_deleting_a_bond(self): self.client.add_bond(3) list_of_bonds = self.client.get_bonds() assert_that(list_of_bonds, has_item(has_properties(number=3))) bond = self.client.get_bond(3) assert_that(bond, has_properties(number=3)) self.client.remove_bond(3) new_list_of_bonds = self.client.get_bonds() assert_that(new_list_of_bonds, is_not(has_item(has_properties(number=3)))) with self.assertRaises(UnknownBond): self.client.get_bond(3)
def test_given_one_line_extension_then_returns_one_item(self): user_line_row = self.add_user_line_with_exten() result = dao.find_all_by_line_id(user_line_row.line_id) assert_that(result, contains(has_properties(line_id=user_line_row.line_id, extension_id=user_line_row.extension_id)))
def CppBindings_DefinitionLocation_test(): translation_unit = ToCppStr( PathToTestFile( 'foo.c' ) ) filename = ToCppStr( PathToTestFile( 'foo.c' ) ) line = 9 column = 17 unsaved_file_vector = ycm_core.UnsavedFileVector() flags = ycm_core.StringVector() flags.append( ToCppStr( '-xc++' ) ) reparse = True clang_completer = ycm_core.ClangCompleter() location = clang_completer.GetDefinitionLocation( translation_unit, filename, line, column, unsaved_file_vector, flags, reparse ) del translation_unit del filename del line del column del unsaved_file_vector del flags del clang_completer del reparse assert_that( location, has_properties( { 'line_number_': 2, 'column_number_': 5, 'filename_': PathToTestFile( 'foo.c' ) } ) )
def CppBindings_CompilationDatabase_test(): with TemporaryTestDir() as tmp_dir: compile_commands = [ { 'directory': tmp_dir, 'command': 'clang++ -x c++ -I. -I/absolute/path -Wall', 'file': os.path.join( tmp_dir, 'test.cc' ), }, ] with TemporaryClangProject( tmp_dir, compile_commands ): db = ycm_core.CompilationDatabase( tmp_dir ) db_successful = db.DatabaseSuccessfullyLoaded() db_busy = db.AlreadyGettingFlags() db_dir = db.database_directory compilation_info = db.GetCompilationInfoForFile( compile_commands[ 0 ][ 'file' ] ) del db del compile_commands eq_( db_successful, True ) eq_( db_busy, False ) eq_( db_dir, tmp_dir ) assert_that( compilation_info, has_properties( { 'compiler_working_dir_': tmp_dir, 'compiler_flags_': contains( 'clang++', '-x', 'c++', '-I.', '-I/absolute/path', '-Wall' ) } ) )
def can_be_created(): impfile = create_file() assert_that(impfile, has_properties({ "filename": "emdqnjim-import_person.txt", "original_filename": "import_person.txt", "delimiter": ";" }))
def props_of_company_buyingstatus_defaultvalue(): lime_type = LimeTypes(f.lime_client).get_by_name('company') assert_that( lime_type.fields['buyingstatus'].defaultvalue, has_properties({ 'key': 'none', 'id': 108001, 'localname': '' }))
def test_given_multiple_users_associated_to_same_line_then_returns_one_item(self): main_ule = self.add_user_line_with_exten() self.prepare_secondary_user_associated(main_ule) result = dao.find_all_by_line_id(main_ule.line_id) assert_that(result, contains(has_properties(line_id=main_ule.line_id, extension_id=main_ule.extension_id)))
def has_failure(test_name, message=anything()): return has_property('{}test-cases', has_property('test-case', has_item( has_properties({'name': equal_to(test_name), 'failure': any_of( has_property('stack-trace', equal_to(message)), has_property('message', equal_to(message)))}))))
def test_replace_dataset(self, api_client, datasets_api, dataset_key): replace_request = {'visibility': 'OPEN'} api_client.replace_dataset(dataset_key, **replace_request) assert_that(datasets_api.replace_dataset, called().times(1).with_args(equal_to('agentid'), equal_to('datasetid'), has_properties( replace_request)))
def has_error(message='', trace='', status=Status.FAILED): return has_property('{}test-cases', has_property('test-case', all_of(has_property('attrib', has_entry('status', status)), has_property('failure', has_properties({'message': message, 'stack-trace': has_string(trace) })))))
def has_error(message='', trace=''): return has_property('{}test-cases', has_property('test-case', has_property('failure', has_properties({ 'message': message, 'stack-trace': has_string(trace) }))))
def tests_loads_user_information_from_settings_store_and_logs_user_in(store): store.should_receive("load_user").and_return(make_registered_user(email="*****@*****.**", api_key="token", permissions=("isni.lookup", "isni.assign"))) session = load_session_from(store) assert_that(session.current_user, has_properties(email="*****@*****.**", api_key="token", permissions=contains("isni.lookup", "isni.assign")))
def assert_result(self, *matchers, **kwargs): result = kwargs.get(u'result', self.result) assert_that(result, all_of( has_property(u'exit_code', kwargs.pop(u'exit_code', 0)), has_property(u'output', kwargs.pop(u'output', anything())), has_properties(**kwargs), *matchers ))
def type_of_keyword_only_arguments_is_traced(): program = """ def repeat(x, *, y): return x * y print(repeat("hello ", y=3)) """ trace = _run_and_trace(program) assert_that(trace, m.has_item(m.has_properties({ "location": m.has_properties({ "lineno": 2, "col_offset": 0 }), "args": m.has_entries({ "x": describe(str), "y": describe(int), }) })))
def test_create_minimal_parameters(self): custom = custom_dao.create( Custom( interface='custom/create', tenant_uuid=self.default_tenant.uuid ) ) assert_that(inspect(custom).persistent) assert_that(custom, has_properties( id=not_none(), interface='custom/create', enabled=True, name=none(), commented=0, protocol='custom', category='user', ))
def test_voicemail_copy_greeting_invalid_dest_greeting(self): assert_that( calling(self.calld_client.voicemails.copy_voicemail_greeting ).with_args(self._voicemail_id, "busy", "not-exists"), raises(CalldError).matching( has_properties( status_code=400, message=contains_string("Sent data is invalid"), details=has_entry( "dest_greeting", contains_exactly( has_entries( constraint=has_entry( "choices", equal_to(["unavailable", "busy", "name"])), message= 'Must be one of: unavailable, busy, name.'))))) )
def test_given_invalid_line_when_relocate_then_400(self): user_uuid = SOME_USER_UUID line_id = SOME_LINE_ID token = self.given_user_token(user_uuid) relocated_channel_id, initiator_channel_id = self.given_bridged_call_stasis( callee_uuid=user_uuid) self.confd.set_users(MockUser(uuid=user_uuid)) calld = self.make_calld(token) assert_that( calling(calld.relocates.create_from_user).with_args( initiator_channel_id, 'line', {'line_id': line_id}), raises(CalldError).matching( has_properties({ 'status_code': 400, 'error_id': 'relocate-creation-error', 'details': has_entries({'line_id': line_id}), })))
def test_edit_set_fields_to_null(self): trunk = trunk_dao.create( Trunk( tenant_uuid=self.default_tenant.uuid, context='default', registercommented=1, description='description', )) trunk = trunk_dao.get(trunk.id) trunk.context = None trunk.description = None trunk_dao.edit(trunk) row = self.session.query(Trunk).first() assert_that(trunk, equal_to(row)) assert_that(row, has_properties(context=none(), description=none()))
def test_response(self, api_client, url, data_set): response = api_client.get(url) assert_that( response, has_properties({ 'status_code': status.HTTP_200_OK, 'data': has_entries({ 'data': contains_inanyorder( *[ self.citizen_to_json(citizen) for citizen in data_set.citizens.all() ], ) }) }))
def test_response(self, api_client, url, data_set): response = api_client.get(url) assert_that( response, has_properties({ 'status_code': status.HTTP_200_OK, 'data': has_entries({ 'data': contains_inanyorder({ 'town': 'Москва', 'p50': 28.0, 'p75': 29.0, 'p99': 29.96 }) }), }))
def test_metaqueue_is_created_with_all_fields(self): queue = QueueFeatures( tenant_uuid=self.default_tenant.uuid, name='queuename', enabled=False, displayname='', music_on_hold='music_on_hold', ) self.session.add(queue) self.session.flush() assert_that( queue._queue, has_properties( name='queuename', enabled=False, musicclass='music_on_hold', ))
def test_update_unused_movie(self): response = self.client.put( self.movie_unused_url, data={ 'name': 'Avengers 4', 'duration': 181, }, ) assert_that( response, has_properties( status_code=HTTP_200_OK, data=has_entries( url=self.movie_unused_url_match, name='Avengers 4', duration=181, ), ))
def test_user_remove_participant_user_does_not_own_adhoc_conference(self): user_uuid = make_user_uuid() token = self.make_user_token(user_uuid) self.calld_client.set_token(token) adhoc_conference_id, _ = self.given_adhoc_conference(user_uuid, participant_count=1) _, participant_call_id = self.real_asterisk.given_bridged_call_stasis(caller_uuid=user_uuid) another_user_uuid = make_user_uuid() another_token = self.make_user_token(another_user_uuid) self.calld_client.set_token(another_token) # response should not be different than a non-existing adhoc conference # to avoid malicious adhoc conference discovery assert_that(calling(self.calld_client.adhoc_conferences.remove_participant_from_user) .with_args(adhoc_conference_id, participant_call_id), raises(CalldError).matching(has_properties({ 'status_code': 404, 'error_id': 'adhoc-conference-not-found', })))
def test_user_add_participant_already_in_another_adhoc_conf(self): another_uuid = make_user_uuid() token = self.make_user_token(another_uuid) self.calld_client.set_token(token) _, call_ids = self.given_adhoc_conference(another_uuid, participant_count=2) host_uuid = make_user_uuid() token = self.make_user_token(host_uuid) self.calld_client.set_token(token) adhoc_conference_id, _ = self.given_adhoc_conference(host_uuid, participant_count=2) _, participant1_call_id, __ = call_ids # response should not be different than a non-existing call, to avoid malicious call discovery assert_that(calling(self.calld_client.adhoc_conferences.add_participant_from_user) .with_args(adhoc_conference_id, participant1_call_id), raises(CalldError).matching(has_properties({ 'status_code': 400, 'error_id': 'participant-call-not-found', })))
def test_handle_message_expired(self): """ Messages whose TTL have reached 0 are ignored """ self.message.content = dict(opaque_data={ "X-Request-Ttl": "0", }, ) assert_that( self.dispatcher.handle_message( message=self.message, bound_handlers=self.daemon.bound_handlers, ), has_properties( elapsed_time=greater_than(0.0), result=MessageHandlingResultType.EXPIRED, ), )
def test_edit_null_parameters(self): sccp = self.add_sccpline() line_row = self.add_line(endpoint_sccp_id=sccp.id) line = line_dao.get(line_row.id) line.endpoint_sccp_id = None line_dao.edit(line) edited_line = self.session.query(Line).get(line_row.id) assert_that( edited_line, has_properties( id=line.id, endpoint_sip_uuid=none(), endpoint_sccp_id=none(), endpoint_custom_id=none(), ))
def test_edit_all_parameters(self): meeting = self.add_meeting(name='my meeting') row = self.add_meeting_authorization( meeting.uuid, guest_name='jane doe', status='accepted', ) model = dao.get(meeting.uuid, row.uuid) model.guest_name = 'new' dao.edit(model) self.session.expire_all() assert_that(model, has_properties( uuid=model.uuid, guest_name='new', ))
def test_send_fax_from_user_without_line(self): user_uuid = 'some-user-id' self.confd.set_users(MockUser(uuid=user_uuid, line_ids=[])) calld_client = self.make_user_calld(user_uuid) with open(os.path.join(ASSET_ROOT, 'fax', 'fax.pdf'), 'rb') as fax_file: fax_content = fax_file.read() assert_that( calling(calld_client.faxes.send_from_user).with_args( fax_content, extension='recipient-fax', caller_id='fax wait' ), raises(CalldError).matching(has_properties({ 'status_code': 400, 'error_id': 'user-missing-main-line', })) )
def test_edit_set_fields_to_null(self): skill = self.add_queue_skill( name='MyName', description='MyDescription', category='MyCategory', ) self.session.expire_all() skill.description = None skill.category = None skill_dao.edit(skill) self.session.expire_all() assert_that(skill, has_properties( description=none(), category=none(), ))
def CppBindings_UnsavedFile_test(): unsaved_file = ycm_core.UnsavedFile() filename = ToCppStr('foo') contents = ToCppStr('bar\\n') length = len(contents) unsaved_file.filename_ = filename unsaved_file.contents_ = contents unsaved_file.length_ = length del filename del contents del length assert_that( unsaved_file, has_properties({ 'filename_': 'foo', 'contents_': 'bar\\n', 'length_': len('bar\\n') }))
def test_given_b_has_no_mobile_when_b_relocate_to_mobile_then_400(self): user_uuid = SOME_USER_UUID line_id = 12 self.confd.set_users(MockUser(uuid=user_uuid, line_ids=[line_id], mobile=None)) self.confd.set_lines(MockLine(id=line_id, context='local')) token = self.given_user_token(user_uuid) relocated_channel_id, initiator_channel_id = self.given_bridged_call_stasis(callee_uuid=user_uuid) ctid_ng = self.make_ctid_ng(token) assert_that( calling(ctid_ng.relocates.create_from_user).with_args( initiator_channel_id, 'mobile', ), raises(CtidNGError).matching(has_properties({ 'status_code': 400, 'error_id': 'relocate-creation-error', })))
def test_identifiers_fixed_for_mapping_row(): # Given wrapper = RowWrapper(["column-name", "Another One", "3rd Column"]) # When row = wrapper({ "column-name": "value", "Another One": "another-value", "3rd Column": "3rd value" }) # Then assert_that( row, has_properties(column_name="value", Another_One="another-value", a_3rd_Column="3rd value"), )
def test_from_ari_endpoint_list_iax2_with_calls(self): raw = { "technology": 'IAX2', "resource": s.name, "state": "unknown", "channel_ids": [123455.43, 124453.32] } result = Endpoint.from_ari_endpoint_list(raw) assert_that( result, has_properties( techno='IAX2', name=s.name, registered=None, current_call_count=2, ))
def test_from_ari_endpoint_list_sip_registered(self): raw = { "technology": 'PJSIP', "resource": s.name, "state": "online", "channel_ids": [123455.43] } result = Endpoint.from_ari_endpoint_list(raw) assert_that( result, has_properties( techno='PJSIP', name=s.name, registered=True, current_call_count=1, ))
def test_edit_all_fields(self): access_feature = self.add_accessfeatures( host='1.2.3.0/24', enabled=True, ) self.session.expire_all() access_feature.host = '1.2.4.0/24' access_feature.enabled = False access_feature_dao.edit(access_feature) self.session.expire_all() assert_that(access_feature, has_properties( host='1.2.4.0/24', enabled=False, ))
def test_create_minimal_fields(self): switchboard = Switchboard( name="switchboard", tenant_uuid=self.default_tenant.uuid, ) switchboard = switchboard_dao.create(switchboard) self.session.expire_all() assert_that(inspect(switchboard).persistent) assert_that( switchboard, has_properties( uuid=is_not(none()), tenant_uuid=self.default_tenant.uuid, name="switchboard", ), )
def test_user_list_participants_when_user_is_not_participant(self): token = 'my-token' user_uuid = 'user-uuid' conference_id = CONFERENCE1_ID self.confd.set_conferences( MockConference(id=conference_id, name='conference'), ) self.auth.set_token( MockUserToken(token, tenant_uuid='my-tenant', user_uuid=user_uuid)) calld = self.make_calld(token=token) assert_that( calling(calld.conferences.user_list_participants).with_args( conference_id), raises(CalldError).matching( has_properties({ 'status_code': 403, 'error_id': 'user-not-participant', })))
def test_put_record_stop(self): channel_id = self.given_call_not_stasis() assert_that( calling(self.calld_client.calls.stop_record).with_args(UNKNOWN_UUID), raises(CalldError).matching(has_properties(status_code=404)) ) routing_key = 'calls.*.updated' event_accumulator = self.bus.accumulator(routing_key) self.calld_client.calls.stop_record(channel_id) def event_received(): assert_that( event_accumulator.accumulate(with_headers=True), has_items( has_entries( message=has_entries( name='call_updated', data=has_entries( call_id=channel_id, record_state='inactive' ) ), headers=has_entries( name='call_updated', tenant_uuid=VALID_TENANT, ), ) ) ) until.assert_(event_received, tries=10) assert_that( self.calld_client.calls.list_calls()['items'], has_items(has_entries(call_id=channel_id, record_state='inactive')), ) # Should not raise an error on second record stop assert_that( calling(self.calld_client.calls.stop_record).with_args(channel_id), not_(raises(CalldError)) )
def test_user_creation(self): username = '******' hash_ = 'the_hashed_password' email_address = '*****@*****.**' user_uuid = self._user_dao.create( username=username, email_address=email_address, tenant_uuid=self.top_tenant_uuid, hash_=hash_, salt=self.salt, purpose='user', )['uuid'] assert_that(user_uuid, equal_to(ANY_UUID)) result = self._user_dao.list_(uuid=user_uuid) assert_that( result, contains_exactly( has_entries( username=username, emails=contains_exactly( has_entries(address=email_address, confirmed=False, main=True)), )), ) assert_that( calling(self._user_dao.create).with_args( username='******', uuid=user_uuid, email_address='*****@*****.**', tenant_uuid=self.top_tenant_uuid, hash_='', salt=b'', purpose='user', ), raises( exceptions.ConflictException, has_properties(status_code=409, resource='users', details=has_entries(uuid=ANY)), ), )
def test_bulk_builder_when_violating_foreign_keys(self): dogs = csv( dedent(""" id,name,owner_id 1,Rocco,2 2,Reza,1 3,Rookie,1 4,Stretch,3 """)) more_people = csv( dedent(""" id,first,last 3,John,Doe """)) bulk_input = [ (Person, self.people), (Dog, dogs), (Person, more_people), ] self.builder.csv(Example).bulk().build(bulk_input) with Example.new_context(self.graph): dogs = self.dog_store.search() people = self.person_store.search() assert_that( dogs, contains( has_properties(name="Reza", ), has_properties(name="Rocco", ), has_properties(name="Rookie", ), has_properties(name="Stretch", ), ), ) assert_that( people, contains( has_properties(first="John", ), has_properties(first="Klay", ), has_properties(first="Stephen", ), ), )
def CppBindings_FixIt_test(): translation_unit = ToCppStr( PathToTestFile( 'foo.c' ) ) filename = ToCppStr( PathToTestFile( 'foo.c' ) ) line = 3 column = 5 unsaved_file_vector = ycm_core.UnsavedFileVector() flags = ycm_core.StringVector() flags.append( ToCppStr( '-xc++' ) ) reparse = True clang_completer = ycm_core.ClangCompleter() fixits = clang_completer.GetFixItsForLocationInFile( translation_unit, filename, line, column, unsaved_file_vector, flags, reparse ) del translation_unit del filename del line del column del unsaved_file_vector del flags del clang_completer del reparse assert_that( fixits, contains( has_properties( { 'text': ( PathToTestFile( 'foo.c' ) + ':3:16: error: expected \';\' at end of declaration' ), 'location': has_properties( { 'line_number_': 3, 'column_number_': 16, 'filename_': PathToTestFile( 'foo.c' ) } ), 'chunks': contains( has_properties( { 'replacement_text': ';', 'range': has_properties( { 'start_': has_properties( { 'line_number_': 3, 'column_number_': 16, } ), 'end_': has_properties( { 'line_number_': 3, 'column_number_': 16, } ), } ) } ) ), } ) ) )
def test_multi_tenant(self, sub_source, sub_display, main_source, main_display): main_tenant_client = self.get_client(VALID_TOKEN_MAIN_TENANT) sub_tenant_client = self.get_client(VALID_TOKEN_SUB_TENANT) body = { 'name': 'profile', 'display': main_display, 'services': { 'lookup': { 'sources': [main_source] } }, } with self.profile(main_tenant_client, body) as profile: assert_that( calling(sub_tenant_client.profiles.get).with_args( profile['uuid']), raises(Exception).matching( has_properties(response=has_properties( status_code=404)), ), ) assert_that( calling(main_tenant_client.profiles.get).with_args( profile['uuid'], tenant_uuid=SUB_TENANT), raises(Exception).matching( has_properties(response=has_properties( status_code=404)), ), ) assert_that( calling(sub_tenant_client.profiles.get).with_args( profile['uuid'], tenant_uuid=MAIN_TENANT), raises(Exception).matching( has_properties(response=has_properties( status_code=401)), ), ) body = { 'name': 'profile', 'display': sub_display, 'services': { 'lookup': { 'sources': [sub_source] } }, } with self.profile(sub_tenant_client, body) as profile: result = main_tenant_client.profiles.get(profile['uuid']) assert_that(result, equal_to(profile))
def test_user_sccp(self): user = self.add_user() sccp = self.add_sccpline(name='sccpname') line = self.add_line(endpoint_sccp_id=sccp.id) self.add_user_line(user_id=user.id, line_id=line.id) member = self.add_queue_member(usertype='user', userid=user.id, interface='wrong', channel='wrong') member.fix() self.session.flush() self.session.expire_all() assert_that( member, has_properties( interface='SCCP/sccpname', channel='SCCP', ))
def test_create_minimal_fields(self): schedule_model = Schedule(tenant_uuid=self.default_tenant.uuid) schedule = schedule_dao.create(schedule_model) self.session.expire_all() assert_that(inspect(schedule).persistent) assert_that( schedule, has_properties(id=is_not(none()), tenant_uuid=self.default_tenant.uuid, name=None, timezone=None, fallback_action='none', type='none', fallback_actionid=None, actionarg1=None, fallback_actionargs=None, actionarg2=None, enabled=True))