Best Python code snippet using lemoncheesecake
test_behave.py
Source:test_behave.py
...78 assert steps[1].get_logs()[0].message == "b = 2"79 assert steps[2].description == "Then a + b is equal to 4"80 assert steps[2].get_logs()[0].description == "Expect 2 + 2 to be equal to 4"81 assert steps[2].get_logs()[0].is_successful is True82 def test_scenario_failed(tmpdir):83 feature = u"""Feature: do some computations84 85Scenario: do a simple addition86 Given a is 287 And b is 288 Then a + b is equal to 589"""90 report = run_behave_tests(tmpdir, feature, STEPS)91 test = get_last_test(report)92 assert test.parent_suite.name == "do_some_computations"93 assert test.parent_suite.description == "Feature: do some computations"94 assert test.status == "failed"95 assert test.name == "do_a_simple_addition"96 assert test.description == "Scenario: do a simple addition"...
check_branch_in_redmine.py
Source:check_branch_in_redmine.py
1import argparse2from check_pullrequest import check_pullrequest_in_mdbci, \3 get_url_for_check_pullrequest4from redmine_api import get_redmine_server, get_redmine_issue, \5 get_test_scenario_value, is_issue_resolved, \6 transition_issue, add_comment, assigned_issue_to_user_id7from issue_statistics import getContributorsList, \8 getIssueJournal9ARG_BRANCH = '--branch'10SUCCESS_PRINT = 'This issue {} is successfully completed'11SUCCESS_COMMENT = 'Test success'12SUCCESS = "SUCCESS"13UNSUCCESS_PRINT = 'The issue {} is unsuccessfully completed'14TEST_SCENARIO_FAILED = 'Test scenario is missed\n'15TEST_SCENARIO_SUCCESS = 'Test scenario exists'16PULLREQUEST_FAILED = 'Pullrequest is missed\n'17PULLREQUEST_SUCCESS = 'Pullrequest exists'18FAIL_REASON = "FAIL_REASON"19# for env variable20PROPSFILE = 'propsfile'21MODE_AW = 'aw'22# values for status id23NEW = 124GITHUB_URL = 'https://github.com/{}/{}/pull'25MAXSCALE_OWNER = 'mariadb-corporation'26MAXSCALE_REPO = 'maxscale-jenkins-jobs'27REDMINE_OSLL_HOST = 'https://dev.osll.ru'28ID = 'id'29def write_env_var(variable, value):30 f = open(PROPSFILE, MODE_AW)31 f.write(variable + '=' + value + '\n')32 f.close()33def get_comment(test_scenario_field=True, pullrequest=True):34 result = 'Test failed. \n'35 if not test_scenario_field:36 result += TEST_SCENARIO_FAILED37 if not pullrequest:38 result += PULLREQUEST_FAILED39 return result40def get_branch_number():41 parser = argparse.ArgumentParser()42 parser.add_argument(43 ARG_BRANCH,44 required=True)45 args = parser.parse_args()46 return args.branch47def check_test_scenario_field(test_scenario_value):48 if test_scenario_value is None or test_scenario_value == u'':49 print TEST_SCENARIO_FAILED50 return False51 print TEST_SCENARIO_SUCCESS52 return True53def check_text_in_test_scenario_field(test_scenario_value):54 if test_scenario_value.find(55 get_url_for_check_pullrequest(56 GITHUB_URL,57 MAXSCALE_OWNER,58 MAXSCALE_REPO)) != -1:59 print PULLREQUEST_SUCCESS60 return True61 print PULLREQUEST_FAILED62 return False63def check_issue(branch):64 redmine = get_redmine_server()65 issue = get_redmine_issue(redmine, branch)66 if is_issue_resolved(issue):67 test_scenario_value = get_test_scenario_value(issue)68 test_scenario = check_test_scenario_field(test_scenario_value)69 pullrequest = check_pullrequest_in_mdbci(branch)70 if not pullrequest: # while maxscale repo private71 pullrequest = check_text_in_test_scenario_field(72 test_scenario_value)73 if pullrequest and test_scenario:74 print SUCCESS_PRINT.format(branch)75 write_env_var(FAIL_REASON, SUCCESS)76 else:77 print UNSUCCESS_PRINT.format(branch)78 comment = get_comment(79 test_scenario, pullrequest)80 transition_issue(issue, NEW)81 journal = getIssueJournal(REDMINE_OSLL_HOST, issue[ID])82 last_user_id = getContributorsList(journal, return_value=ID)[-1]83 assigned_issue_to_user_id(issue[ID], last_user_id)84 add_comment(issue, comment)85 write_env_var(FAIL_REASON, comment)86 else:87 write_env_var(FAIL_REASON, SUCCESS)88if __name__ == '__main__':...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!