def Diagnostics_NoLimitToNumberOfDiagnostics_test( app ): filepath = PathToTestFile( 'max_diagnostics.cc' ) contents = ReadFile( filepath ) request = { 'contents': contents, 'filepath': filepath, 'filetype': 'cpp' } test = { 'request': request, 'route': '/receive_messages' } response = RunAfterInitialized( app, test ) pprint( response ) assert_that( response, contains( has_entries( { 'diagnostics': has_items( has_entries( { 'kind': equal_to( 'ERROR' ), 'location': LocationMatcher( filepath, 3, 9 ), 'location_extent': RangeMatcher( filepath, ( 3, 9 ), ( 3, 13 ) ), 'ranges': contains( RangeMatcher( filepath, ( 3, 9 ), ( 3, 13 ) ) ), 'text': contains_string( "Redefinition of 'test'" ), 'fixit_available': False } ), has_entries( { 'kind': equal_to( 'ERROR' ), 'location': LocationMatcher( filepath, 4, 9 ), 'location_extent': RangeMatcher( filepath, ( 4, 9 ), ( 4, 13 ) ), 'ranges': contains( RangeMatcher( filepath, ( 4, 9 ), ( 4, 13 ) ) ), 'text': contains_string( "Redefinition of 'test'" ), 'fixit_available': False } ) ) } ) ) )
def test_capture_stdout(allured_testdir, capture): """ >>> import pytest >>> import allure >>> @pytest.fixture ... def fixture(request): ... print ("Start fixture") ... def finalizer(): ... print ("Stop fixture") ... request.addfinalizer(finalizer) >>> def test_capture_stdout_example(fixture): ... print ("Start test") ... with allure.step("Step"): ... print ("Start step") """ allured_testdir.parse_docstring_source() allured_testdir.run_with_allure("--capture={capture}".format(capture=capture)) if_pytest_capture_ = is_not if capture == "no" else is_ assert_that(allured_testdir.allure_report, has_property("attachments", all_of( if_pytest_capture_(has_value(contains_string("Start fixture"))), if_pytest_capture_(has_value(contains_string("Stop fixture"))), if_pytest_capture_(has_value(contains_string("Start test"))), if_pytest_capture_(has_value(contains_string("Start step"))) ) ) )
def test_multiple_invalid_properties_raise_multiple_errors(self): invalid_record = { "_id": "dbl_boff_0000000000000001", "name": "big_boff", "downtime": "def", "uptime": "abc" } errors = validate_record_schema( invalid_record, self.schema_with_two_requirements ) assert_that( errors[0], contains_string( "'abc' is not of type 'integer'") ) assert_that( errors[1], contains_string( "'def' is not of type 'integer'") ) assert_that( len(errors), 2 )
def FixIt_Check_cpp11_Note( results ): assert_that( results, has_entries( { 'fixits': contains( # First note: put parens around it has_entries( { 'text': contains_string( 'parentheses around the assignment' ), 'chunks': contains( ChunkMatcher( '(', LineColMatcher( 59, 8 ), LineColMatcher( 59, 8 ) ), ChunkMatcher( ')', LineColMatcher( 61, 12 ), LineColMatcher( 61, 12 ) ) ), 'location': LineColMatcher( 60, 8 ), } ), # Second note: change to == has_entries( { 'text': contains_string( '==' ), 'chunks': contains( ChunkMatcher( '==', LineColMatcher( 60, 8 ), LineColMatcher( 60, 9 ) ) ), 'location': LineColMatcher( 60, 8 ), } ) ) } ) )
def login(context, email, password): context.driver.delete_all_cookies() context.driver.get('javascipr:localStorage.clear;') context.driver.get(context.sigmaURL) #wait_for_css(context.driver, '#emailInput') #email_field = context.driver.find_element_by_id('emailInput'); #email_field.clear(); #email_field.send_keys(email); #context.driver.find_element_by_css_selector('.submit').click() wait_for_css(context.driver, '#passwordInput') #second emailpage login if context.driver.name=='chrome': user_name = context.driver.find_element_by_id('userNameInput'); user_name.clear() user_name.send_keys(email) password_field = context.driver.find_element_by_id('passwordInput'); password_field.clear() password_field.send_keys(password) submit_button = context.driver.find_element_by_id('submitButton') submit_button.click() wait_for_css(context.driver, '#DeltaPlaceHolderCustomSiteName') assert_that(context.driver.current_url, contains_string('https://sigma.appsextern')) assert_that(context.driver.current_url, contains_string('prvgld.nl/Paginas/Welkom.aspx'))
def _check_cram_description(description): assert_that(description.split('\n'), has_length(5)) assert_that(description, contains_string('QC')) assert_that(description, contains_string('Filtering and trimming')) assert_that(description, contains_string('htseq')) assert_that(description, contains_string('tophat2')) assert_that(description, contains_string('iRAP'))
def FixIt_Check_cpp11_Note(results): assert_that( results, has_entries( { "fixits": contains( # First note: put parens around it has_entries( { "text": contains_string("parentheses around the assignment"), "chunks": contains( ChunkMatcher("(", LineColMatcher(59, 8), LineColMatcher(59, 8)), ChunkMatcher(")", LineColMatcher(61, 12), LineColMatcher(61, 12)), ), "location": LineColMatcher(60, 8), } ), # Second note: change to == has_entries( { "text": contains_string("=="), "chunks": contains(ChunkMatcher("==", LineColMatcher(60, 8), LineColMatcher(60, 9))), "location": LineColMatcher(60, 8), } ), ) } ), )
def test_get_lun_doc(self): lun = UnityLun(_id='sv_2', cli=t_rest()) doc = lun.doc assert_that(doc, contains_string('Represents Volume, LUN, Virtual Disk.')) assert_that(doc, contains_string('current_node')) assert_that(doc, contains_string('Current SP'))
def test_GIVEN_driving_dataset_selected_for_model_WHEN_page_get_THEN_driving_data_spatial_extents_rendered(self): response = self.app.get( url(controller='model_run', action='extents')) assert_that(response.normal_body, contains_string(str(self.driving_data.boundary_lat_north))) assert_that(response.normal_body, contains_string(str(self.driving_data.boundary_lat_south))) assert_that(response.normal_body, contains_string(str(self.driving_data.boundary_lon_east))) assert_that(response.normal_body, contains_string(str(self.driving_data.boundary_lon_west)))
def test_get_presence_with_correct_values(self): result = self.ctid_ng.get_user_presence_result(token=self.token_id) assert_that(result.status_code, equal_to(200)) assert_that(result.json(), has_entries({'user_uuid': contains_string(self.token_user_uuid), 'xivo_uuid': contains_string(XIVO_UUID), 'presence': contains_string('available')}))
def test_shows_selected_track_title_in_context_menu(driver): _ = show_track_list_tab(make_album(tracks=[make_track(track_title="Partways"), make_track(track_title="Rebop")])) driver.select_track("Partways") driver.has_context_menu_item(with_text(contains_string("Partways"))) driver.select_track("Rebop") driver.has_context_menu_item(with_text(contains_string("Rebop")))
def test_GIVEN_two_driving_datasets_WHEN_get_THEN_driving_datasets_rendered(self): self._add_model_run_being_created(self.user) self.create_two_driving_datasets() response = self.app.get( url(controller='model_run', action='driving_data')) assert_that(response.normal_body, contains_string("driving1")) assert_that(response.normal_body, contains_string("driving2"))
def test_it_should_answer_message_with_unusable_stations(self): self.process(MSG_LOCATION) self.assert_answer(contains_string( 'Estación no disponible a 100m en C/ Dirección W (200)')) self.assert_answer(contains_string( 'Estación no disponible a 100m en C/ Dirección X (201)'))
def test_csv_file_download( self, mock_get_dashboard): response = self.client.get( '/dashboard/dashboard-uuid/cost-per-transaction/' 'spreadsheet-template') assert_that(response.headers[2][1], contains_string('attachment')) assert_that(response.headers[2][1], contains_string('filename=cost_per_transaction.csv'))
def test_it_should_create_an_index_using_station_data(self): result = self.filter(index('nombre', 'address'), (NAME_AND_ADDRESS_STATION,)) assert_that(result, contains(has_property('index', all_of( contains_string('matadero'), contains_string('chopera')) )))
def test_nino_is_not_case_sensitive(self, employee_via_nino): employee_via_nino.return_value = {"first_name": "John"} test_app = routes.app.test_client() response = test_app.get('/claim-redundancy-payment/employee-records/?nino=ab111111c') assert_that(response.status_code, is_(200)) page = BeautifulSoup(response.data) assert_that(page.find('h1').text, contains_string('Your Employee Record')) assert_that(page.find('pre').text, contains_string('John'))
def step(context): claim_id = context.claim_id response_for_acceptdoc = chomp_app.test_client().get( "/chomp/{claim_id}/acceptdoc".format(**locals())) assert_that(response_for_acceptdoc.status_code, is_(200)) assert_that(response_for_acceptdoc.content_type, contains_string("text/xml")) assert_that(response_for_acceptdoc.data, contains_string("CHAMP Acceptdoc Payload"))
def test_GIVEN_single_cell_spatial_extents_already_chosen_WHEN_page_get_THEN_existing_extents_rendered(self): self.model_run_service.save_parameter(JULES_PARAM_USE_SUBGRID, True, self.user) self.model_run_service.save_parameter(JULES_PARAM_LATLON_REGION, False, self.user) self.model_run_service.save_parameter(JULES_PARAM_NPOINTS, 1, self.user) self.model_run_service.save_parameter(JULES_PARAM_POINTS_FILE, [55, 12.3], self.user) response = self.app.get( url(controller='model_run', action='extents')) assert_that(response.normal_body, contains_string("55")) assert_that(response.normal_body, contains_string("12.3"))
def step(context): claim_id = context.claim_id response_for_rp14a = chomp_app.test_client().get( "/chomp/{claim_id}/rp14a".format(**locals())) assert_that(response_for_rp14a.status_code, is_(200)) assert_that(response_for_rp14a.content_type, contains_string("text/xml")) assert_that(response_for_rp14a.data, contains_string("CHAMP RP14A Payload"))
def test_it_should_search_stations_by_name(self): query = 'callEaVapiés' stations = list(self.stations.by_search(query)) assert_that(stations, only_contains(any_of( has_property('nombre', contains_string('Lavapies')), has_property('address', contains_string('Lavapies')), ))) assert_that(stations, has_length(greater_than(0)))
def test_GIVEN_output_parameters_already_chosen_WHEN_page_get_THEN_parameters_rendered(self): self.app.post( url(controller='model_run', action='output'), params=self.valid_params) response = self.app.get(url(controller='model_run', action='output')) doc = html.fromstring(response.normal_body) # Check that the first output variable is displayed, selected and the yearly and monthly period boxes selected: output_row_1 = doc.xpath('//div[@id="output_row_1"]/@style') assert_that(output_row_1, is_not(contains_string('display:none'))) ov_select_1 = doc.xpath('//input[@name="ov_select_1"]/@checked') ov_yearly_1 = doc.xpath('//input[@name="ov_yearly_1"]/@checked') ov_monthly_1 = doc.xpath('//input[@name="ov_monthly_1"]/@checked') ov_daily_1 = doc.xpath('//input[@name="ov_daily_1"]/@checked') ov_hourly_1 = doc.xpath('//input[@name="ov_hourly_1"]/@checked') assert_that(len(ov_select_1), is_(1)) assert_that(len(ov_yearly_1), is_(1)) assert_that(len(ov_monthly_1), is_(1)) assert_that(len(ov_daily_1), is_(0)) assert_that(len(ov_hourly_1), is_(0)) # For the second we expect the same but with the hourly period box selected output_row_2 = doc.xpath('//div[@id="output_row_2"]/@style') assert_that(output_row_2, is_not(contains_string('display:none'))) ov_select_2 = doc.xpath('//input[@name="ov_select_2"]/@checked') ov_yearly_2 = doc.xpath('//input[@name="ov_yearly_2"]/@checked') ov_monthly_2 = doc.xpath('//input[@name="ov_monthly_2"]/@checked') ov_daily_2 = doc.xpath('//input[@name="ov_daily_2"]/@checked') ov_hourly_2 = doc.xpath('//input[@name="ov_hourly_2"]/@checked') assert_that(len(ov_select_2), is_(1)) assert_that(len(ov_yearly_2), is_(0)) assert_that(len(ov_monthly_2), is_(0)) assert_that(len(ov_daily_2), is_(1)) assert_that(len(ov_hourly_2), is_(1)) # For the third we expect the monthly box selected output_row_3 = doc.xpath('//div[@id="output_row_3"]/@style') assert_that(output_row_3, is_not(contains_string('display:none'))) ov_select_3 = doc.xpath('//input[@name="ov_select_3"]/@checked') ov_yearly_3 = doc.xpath('//input[@name="ov_yearly_3"]/@checked') ov_monthly_3 = doc.xpath('//input[@name="ov_monthly_3"]/@checked') ov_daily_3 = doc.xpath('//input[@name="ov_daily_3"]/@checked') ov_hourly_3 = doc.xpath('//input[@name="ov_hourly_3"]/@checked') assert_that(len(ov_select_3), is_(1)) assert_that(len(ov_yearly_3), is_(0)) assert_that(len(ov_monthly_3), is_(1)) assert_that(len(ov_daily_3), is_(0)) assert_that(len(ov_hourly_3), is_(0)) # Finally we check that no other output parameters are selected or visible ov_selects = doc.xpath('//input[contains(@name, "ov_select_") and not(@checked)]') n_output_params = len(self.model_run_service.get_output_variables(include_depends_on_nsmax=False)) assert_that(len(ov_selects), is_(n_output_params - 3)) invisible_rows = doc.xpath('//div[contains(@id, "output_row_") and contains(@style, "display:none")]') assert_that(len(invisible_rows), is_(n_output_params - 3))
def the_client_should_display_to_console(context): assert_that( context.stdout_capture.getvalue(), contains_string(context.table.headings[0]) ) for row in context.table: assert_that( context.stdout_capture.getvalue(), contains_string(row[0]) )
def test_it_should_answer_only_with_bad_results(self): self.set_result(BAD_STATIONS, []) self.process_with_args('wwwwww') self.assert_answer(all_of( contains_string('Estas me salen pero no creo que te sirvan'), contains_string(BAD_STATIONS[0].address), contains_string(BAD_STATIONS[1].address) ))
def test_GIVEN_user_driving_data_previously_selected_WHEN_get_THEN_user_driving_data_rendered(self): self._add_model_run_being_created(self.user) self.upload_valid_user_driving_data() response = self.app.get( url(controller='model_run', action='driving_data')) assert_that(response.normal_body, contains_string('55')) assert_that(response.normal_body, contains_string('45')) assert_that(response.normal_body, contains_string('2000-01-01 00:00')) assert_that(response.normal_body, contains_string('2000-01-01 02:00')) assert_that(response.normal_body, contains_string('3 rows of driving data currently uploaded'))
def test_spreadsheet_template_slug_responds_with_a_csv_file( self, mock_get_dashboard): with self.client.session_transaction() as session: session['upload_choice'] = 'week' session['channel_choices'] = ['api', 'face_to_face'] response = self.client.get( '/dashboard/dashboard-uuid/digital-take-up/spreadsheet-template') assert_that(response.headers[2][1], contains_string('attachment')) assert_that(response.headers[2][1], contains_string('filename=digital_take_up.csv'))
def test_render_download_template_page_contains_any_errors( self, mock_get_dashboard): with self.client.session_transaction() as session: session['upload_data'] = { 'payload': ['Message 1', 'Message 2'] } response = self.client.get( '/dashboard/dashboard-uuid/cost-per-transaction/upload') assert_that(response.status, equal_to('200 OK')) assert_that(response.data, contains_string('Message 1')) assert_that(response.data, contains_string('Message 2'))
def test_check_authors_file_missing_gitpython(repository_with_author_commits): """Test checking missing authors, with GitPython.""" pytest.importorskip("git") options = dict(authors=["AUTHORS.md", ], path=repository_with_author_commits) errors = check_author('John Doe <*****@*****.**>', **options) assert_that(errors, has_length(1)) assert_that(errors[0], contains_string('A101')) errors = check_author('Jimmy Doe <*****@*****.**>', **options) assert_that(errors, has_length(1)) assert_that(errors[0], contains_string('A101'))
def test_it_should_answer_only_with_good_results(self): self.set_result(STATIONS, STATIONS) self.process_with_args('wwwwww') self.assert_answer(all_of( contains_string('puede que sea alguna de estas'), contains_string(self.object_name), contains_string(STATIONS[0].address), contains_string(STATIONS[1].address) ))
def test_client_server(self): context.cwd = '$testdir' servertask = Task('server', detach=True) server = servertask.command('%s Server --Ice.Config=Server.config' % java, signal=2, expected=130) servertask.assert_that(server.stdout.content, contains_string('Hello World!')) clientside = Task('client') clientside.wait_that(server, running()) clientside.wait_that(server.stdout.content, contains_string('printer1')) clientside.command('%s Client "$(head -1 %s)"' % (java, server.stdout.path))
def make_client_server(self, client, server): servertask = Task('server', detach=True) server = servertask.command('{} --Ice.Config=Server.config'.format(server), cwd='$testdir', signal=2) servertask.assert_that(server.stdout.content, contains_string('Hello World!')) clientside = Task('client') clientside.wait_that(server, running()) clientside.wait_that(server.stdout.content, contains_string('printer1')) clientside.command('{} "$(head -1 {})"'.format(client, server.stdout.path), cwd='$testdir')
def step_command_output_should_not_contain_text(context, text): ''' EXAMPLE: ... then the command output should not contain "TEXT" ''' text = text.format(__WORKDIR__=command_util.posixpath_normpath( context.workdir), __CWD__=command_util.posixpath_normpath(os.getcwd())) command_output = context.command_result.output expected_output = command_util.text_normalize(text) actual_output = command_util.text_normalize(command_output.strip()) if DEBUG: print("expected:\n{0}".format(expected_output)) print("actual:\n{0}".format(actual_output)) assert_that(actual_output, is_not(contains_string(expected_output)))
def test_plugin_command_on_unix_nonzero_return(caplog, reactor): # noqa: no-cover stream = StringIO(''' - name: test1 command: "false" ''') document = loader.ordered_load(stream) nodes = TopLevel.build(document) context = Context() for node in nodes: node.execute(context) assert_that(caplog.text, contains_string("'failure'"))
def GetCompletions_JediCompleter_UnicodeDescription_test(): app = TestApp(handlers.app) filepath = PathToTestFile('unicode.py') completion_data = BuildRequest(filepath=filepath, filetype='python', contents=open(filepath).read(), force_semantic=True, line_num=5, column_num=3) results = app.post_json('/completions', completion_data).json['completions'] print results assert_that( results, has_item(has_entry('detailed_info', contains_string(u'aafäö'))))
def test_FormatDebugInfoResponse_Completer_ServerRunningWithHost( self ): response = deepcopy( GENERIC_RESPONSE ) assert_that( FormatDebugInfoResponse( response ), contains_string( 'Completer name completer debug information:\n' ' Server name running at: http://127.0.0.1:1234\n' ' Server name process ID: 12345\n' ' Server name executable: /path/to/executable\n' ' Server name logfiles:\n' ' /path/to/stdout/logfile\n' ' /path/to/stderr/logfile\n' ' Server name key: value\n' ' Key: value\n' ) )
def FixIt_Check_cpp11_SpellCheck( results ): assert_that( results, has_entries( { 'fixits': contains_exactly( # Change to SpellingIsNotMyStrongPoint has_entries( { 'kind': 'quickfix', 'text': contains_string( "change 'SpellingIsNotMyStringPiont' to " "'SpellingIsNotMyStrongPoint'" ), 'chunks': contains_exactly( ChunkMatcher( 'SpellingIsNotMyStrongPoint', LineColMatcher( 72, 9 ), LineColMatcher( 72, 35 ) ) ), 'location': LineColMatcher( 72, 9 ), } ) ) } ) )
def test_schema_validation(self): transform_type = TransformType() transform_type.schema = { "$schema": False, } err = transform_type.validate() assert_that(err, contains_string('schema is invalid')) transform_type.schema = { "$schema": "a schema", } err = transform_type.validate() assert_that(err, is_(None))
def test_creation_rejected_setting_raises(): registry = get_registry() # Verify 'encode serial' setting to be falsy. setting_list = [ Setting(name="encode serial", type=bool, required=True, verify_function=lambda i: not i) ] with assert_raises(BadSettings) as caught: UUTClass(registry, "example", setting_list) assert_that(caught.exception.message, contains_string("failed verification function"))
def Diagnostics_MultipleSolution_test(app): filepaths = [ PathToTestFile('testy', 'Program.cs'), PathToTestFile('testy-multiple-solutions', 'solution-named-like-folder', 'testy', 'Program.cs') ] lines = [11, 10] for filepath, line in zip(filepaths, lines): with WrapOmniSharpServer(app, filepath): contents = ReadFile(filepath) for _ in (0, 1): # First call always returns blank for some reason event_data = BuildRequest(filepath=filepath, event_name='FileReadyToParse', filetype='cs', contents=contents) results = app.post_json('/event_notification', event_data).json assert_that( results, contains( has_entries({ 'kind': equal_to('ERROR'), 'text': contains_string("Unexpected symbol `}'', " "expecting identifier"), 'location': has_entries({ 'line_num': line, 'column_num': 2 }), 'location_extent': has_entries({ 'start': has_entries({ 'line_num': line, 'column_num': 2, }), 'end': has_entries({ 'line_num': line, 'column_num': 2, }), }) })))
def Diagnostics_MaximumDiagnosticsNumberExceeded_test(app): filepath = PathToTestFile('max_diagnostics.cc') contents = ReadFile(filepath) request = {'contents': contents, 'filepath': filepath, 'filetype': 'cpp'} test = {'request': request, 'route': '/receive_messages'} response = RunAfterInitialized(app, test) pprint(response) assert_that( response, contains_exactly( has_entries({ 'diagnostics': has_items( has_entries({ 'kind': equal_to('ERROR'), 'location': LocationMatcher(filepath, 3, 9), 'location_extent': RangeMatcher(filepath, (3, 9), (3, 13)), 'ranges': contains_exactly( RangeMatcher(filepath, (3, 9), (3, 13))), 'text': contains_string("Redefinition of 'test'"), 'fixit_available': False }), has_entries({ 'kind': equal_to('ERROR'), 'location': LocationMatcher(filepath, 1, 1), 'location_extent': RangeMatcher(filepath, (1, 1), (1, 1)), 'ranges': contains_exactly(RangeMatcher(filepath, (1, 1), (1, 1))), 'text': equal_to('Maximum number of diagnostics exceeded.'), 'fixit_available': False })) })))
def Diagnostics_CsCompleter_ZeroBasedLineAndColumn_test(): app = TestApp(handlers.app) filepath = PathToTestFile('testy/Program.cs') contents = open(filepath).read() event_data = BuildRequest(filepath=filepath, filetype='cs', contents=contents, event_name='FileReadyToParse') results = app.post_json('/event_notification', event_data) WaitUntilOmniSharpServerReady(app) event_data = BuildRequest(filepath=filepath, event_name='FileReadyToParse', filetype='cs', contents=contents) results = app.post_json('/event_notification', event_data).json assert_that( results, contains( has_entries({ 'text': contains_string( "Unexpected symbol `}'', expecting identifier"), 'location': has_entries({ 'line_num': 10, 'column_num': 2 }), 'location_extent': has_entries({ 'start': has_entries({ 'line_num': 10, 'column_num': 2, }), 'end': has_entries({ 'line_num': 10, 'column_num': 2, }), }) }))) StopOmniSharpServer(app)
def warning_message_images_with_same_name_assertion(glancesync_result, image_name): """ This method checks if output messages in glancesync_result are according to: - contains GLANCESYNC_OUTPUT_WARNING_IMAGES_SAME_NAME :param glancesync_result: String with the output data returned by the GlanceSync command. :param image_name: Name of the image. :return: None """ assert_that( glancesync_result, is_( contains_string( GLANCESYNC_OUTPUT_WARNING_IMAGES_SAME_NAME.format( image_name=image_name))), "WARNING message for '{}' is not shown in results".format(image_name))
def warning_message_duplicated_assertion(glancesync_result, region_name, image_name): """ This method checks if output messages in glancesync_result are according to: - contains GLANCESYNC_OUTPUT_DUPLICATED :param glancesync_result: String with the output data returned by the GlanceSync command. :param region_name: Name of the region. :param image_name: Name of the image. :return: None """ assert_that( glancesync_result, is_( contains_string( GLANCESYNC_OUTPUT_DUPLICATED.format(region_name=region_name, image_name=image_name))), "WARNING message for '{}' is not shown in results".format(image_name))
def FixIt_Check_cuda(results): assert_that( results, has_entries({ 'fixits': contains( has_entries({ 'text': contains_string("change 'int' to 'void'"), 'chunks': contains( ChunkMatcher('void', LineColMatcher(3, 12), LineColMatcher(3, 15))), 'location': LineColMatcher(3, 12), })) }))
def open_reset_password_link(self, step): """I open my reset password link and submit new password""" browser = step.context.browser browser.get(step.context.reset_link) find_by_id = Chrome.find_element_by_id.__name__ find_by_tag = Chrome.find_element_by_tag_name.__name__ password1_input = wait_for_element(browser, find_by_id, 'id_password1') password2_input = wait_for_element(browser, find_by_id, 'id_password2') button = wait_for_element(browser, find_by_tag, 'button') password1_input.send_keys(step.table[0]['new_password']) password2_input.send_keys(step.table[0]['new_password']) button.submit() body = wait_for_element(browser, find_by_tag, 'body') assert_that(body.text, contains_string('Your password is now changed.')) step.context.user_data['password'] = step.table[0]['new_password']
def warning_message_images_with_different_owner(context, image_name): assert_that(context.glancesync_result, is_not(None), "Problem when executing Sync command") for target_credential in context.target_credentials: assert_that( context.glancesync_result, is_( contains_string( GLANCESYNC_OUTPUT_OWNER.format( region_name=target_credential['region_name'], image_name=image_name, uuid_image=target_credential['image_id'], other_tenant=target_credential['image_owner']))), "WARNING message for '{}' is not shown in results".format( image_name))
def test_transform_name_mapping_without_update(self): options = [ '--project=example:example', '--staging_location=gs://foo/bar', '--temp_location=gs://foo/bar', '--transform_name_mapping={\"fromPardo\":\"toPardo\"}' ] pipeline_options = PipelineOptions(options) runner = MockRunners.DataflowRunner() validator = PipelineOptionsValidator(pipeline_options, runner) errors = validator.validate() assert_that( errors, only_contains( contains_string( 'Transform name mapping option is only useful when ' '--update and --streaming is specified')))
def test_given_no_ssl_certificate_when_ctid_ng_starts_then_ctid_ng_stops( self): def ctid_ng_is_stopped(): status = self.service_status() return not status['State']['Running'] until.true( ctid_ng_is_stopped, tries=10, message='xivo-ctid-ng did not stop while missing SSL certificate') log = self.service_logs() assert_that( log, contains_string( "No such file or directory: '/usr/local/share/ssl/ctid-ng/invalid.crt'" ))
def test_plugin_shell_on_win_bad(caplog, reactor): # noqa: no-cover stream = StringIO(''' - name: test1 shell: script: sdfsdfdsf329909092 executable: cmd ''') document = loader.ordered_load(stream) nodes = TopLevel.build(document) context = Context() for node in nodes: node.execute(context) assert_that(caplog.text, contains_string("'failure'"))
def test_response_matcher_invalid_json(): # Given stub_response = mock.MagicMock(status_code=200, text="body", content=b"content", headers={"key": "value"}) type(stub_response).json = mock.PropertyMock(side_effect=ValueError) # When # Then assert_that(stub_response, not_(is_response().with_json([1, 2, 4]))) assert_that( is_response().with_json([1, 2, 4]), mismatches_with(stub_response, contains_string("was response with json: was <None>")), )
def test_complete_a_quiz_perfectly(self): self.reset_session() self.get_page(CATS_QUIZ) for answer in ["Gray", "Jack", "Fluffybutt", "Gray", "Phydeaux"]: self.select_value(answer) self.submit_answer() self.wait_for_confirmation('confirm_correct') link_text = 'Next Question' next_tags = self.browser.find_elements(By.LINK_TEXT, link_text) if next_tags: next_tags[0].click() self.wait_for_page_titled("Cats") # Don't jump the gun. text = self.browser.find_element(By.ID, 'quiz_performance').text assert_that(text, contains_string("perfectly"))
def test_it_throws_if_request_goes_wrong( mock_requests: mock.Mock, create_adapter: SupportsPerformingTranslations, ): # arrange uid = Uid('ac1a53a264') mock_requests.get.return_value = mock.Mock( status_code=500, text='error message', ) # act with pytest.raises(TranslationFailedException) as e: create_adapter.get_translation(uid=uid) # assert assert_that(str(e), contains_string('error message'))
def test_label_detection_with_video_context(self): with TestPipeline(is_integration_test=True) as p: output = ( p | beam.Create([( self.VIDEO_PATH, types.VideoContext( label_detection_config=types.LabelDetectionConfig( label_detection_mode=enums.LabelDetectionMode.SHOT_MODE, model='builtin/latest')))]) | AnnotateVideoWithContext(features=[enums.Feature.LABEL_DETECTION]) | beam.ParDo(extract_entities_descriptions) | beam.combiners.ToList()) # Search for at least one entity that contains 'bicycle'. assert_that( output, matches_all([hc.has_item(hc.contains_string('bicycle'))]))
def test_given_no_ssl_private_key_when_ctid_ng_starts_then_ctid_ng_stops( self): def ctid_ng_is_stopped(): status = self.service_status() return not status['State']['Running'] until.true( ctid_ng_is_stopped, tries=10, message='xivo-ctid-ng did not stop while missing SSL private key') log = self.service_logs() assert_that( log, contains_string( "No such file or directory: '/usr/share/xivo-certs/server.key'" ))
def step_command_output_should_contain_exactly_text(context, text): """ Verifies that the command output of the last command contains the expected text. .. code-block:: gherkin When I run "echo Hello" Then the command output should contain "Hello" """ expected_text = text if "{__WORKDIR__}" in text or "{__CWD__}" in text: expected_text = text.format(__WORKDIR__=posixpath_normpath( context.workdir), __CWD__=posixpath_normpath(os.getcwd())) actual_output = context.command_result.output assert_that(actual_output, contains_string(expected_text))
def Diagnostics_ClangCompleter_ZeroBasedLineAndColumn_test(): app = TestApp( handlers.app ) contents = """ void foo() { double baz = "foo"; } // Padding to 5 lines // Padding to 5 lines """ event_data = BuildRequest( compilation_flags = ['-x', 'c++'], event_name = 'FileReadyToParse', contents = contents, filetype = 'cpp' ) results = app.post_json( '/event_notification', event_data ).json assert_that( results, contains( has_entries( { 'kind': equal_to( 'ERROR' ), 'text': contains_string( 'cannot initialize' ), 'ranges': contains( has_entries( { 'start': has_entries( { 'line_num': 3, 'column_num': 16, } ), 'end': has_entries( { 'line_num': 3, 'column_num': 21, } ), } ) ), 'location': has_entries( { 'line_num': 3, 'column_num': 10 } ), 'location_extent': has_entries( { 'start': has_entries( { 'line_num': 3, 'column_num': 10, } ), 'end': has_entries( { 'line_num': 3, 'column_num': 13, } ), } ) } ) ) )
def image_is_not_sync_assertion(glancesync_result, region_name, image_name): """ This method checks if output messages in glancesync_result are according to: - not contain GLANCESYNC_OUTPUT_UPLOADING :param glancesync_result: String with the output data returned by the GlanceSync command. :param region_name: Name of the region. :param image_name: Name of the image. :return: None """ assert_that( glancesync_result, is_not( contains_string( GLANCESYNC_OUTPUT_UPLOADING.format(region_name=region_name, image_name=image_name))), "Image '{}' is 'uploading' to region '{}' and it shouldn't".format( image_name, region_name))
def test_has_class(): should_match = has_class("bacon") should_not_match = has_class("bananas") assert_that(HTML, has_named_tag("h1", should_match)) assert_that(HTML, not_(has_named_tag("h1", should_not_match))) assert_that(HTML, has_named_tag("h1", has_class(contains_string("aco")))) assert_that(should_match, has_string("tag with class matching 'bacon'")) assert_that( has_named_tag("h1", should_not_match), mismatches_with( HTML, matches_regexp( r"got HTML with tag name=['<]h1['>] values \['<h1 class=\"bacon egg\">chips</h1>'\]" ), ), )
def image_is_renamed_replaced_assertion(glancesync_result, region_name, image_name): """ This method checks if output messages in glancesync_result are according to: - contains GLANCESYNC_OUTPUT_RENAMING :param glancesync_result: String with the output data returned by the GlanceSync command. :param region_name: Name of the region. :param image_name: Name of the image. :return: None """ assert_that( glancesync_result, contains_string( GLANCESYNC_OUTPUT_RENAMING.format(region_name=region_name, image_name=image_name)), "Image '{}' is not 'Renaming and Replacing' another one in region '{}'" .format(image_name, region_name))
def test_plugin_shell_on_win(caplog, reactor): # noqa: no-cover stream = StringIO(''' - name: test1 shell: script: \'echo Hello world\' executable: cmd ''') document = loader.ordered_load(stream) nodes = TopLevel.build(document) context = Context() for node in nodes: node.execute(context) assert_that(caplog.text, contains_string('| Hello world'))
def test_get_not_existed_bear(self, test_api): """Get bear with not existed id.""" with allure.step("Get all bears"): all_bears = test_api.get_bears() with allure.step("Get not existed bear by id"): if len(all_bears) > 0: not_exist_id = max([bear.bear_id for bear in all_bears]) + 1 else: not_exist_id = 1 try: test_api.get_bear(bear_id=not_exist_id) raise AssertionError( 'Api returns bear with id that not exists') except AssertionError as error: assert_that(str(error), contains_string(ResultMsgs.EMPTY))