Best Python code snippet using tox_python
test_release_pull_request_generator.py
Source:test_release_pull_request_generator.py
1import unittest2from unittest.mock import patch3import release_pull_request_generator4class TestReleasePullRequestGeneratorModule(unittest.TestCase):5 @patch("release_pull_request_generator.parse_command_line_arguments")6 @patch("release_pull_request_generator.create_release_branch")7 @patch("release_pull_request_generator.Github")8 def test_creates_pull_request(self, github_mock, create_release_mock, parse_mock):9 release_pull_request_generator.main()10 github_mock.return_value.get_repo.return_value.create_pull.assert_called_once()11 @patch("release_pull_request_generator.parse_command_line_arguments")12 @patch("release_pull_request_generator.create_release_branch")13 @patch("release_pull_request_generator.Github")14 def test_adds_reviewers_to_pull_request(15 self, github_mock, create_release_mock, parse_mock16 ):17 release_pull_request_generator.main()18 repo_mock = github_mock.return_value.get_repo.return_value19 repo_mock.create_pull.return_value.create_review_request.assert_called_once()20 @patch("release_pull_request_generator.parse_command_line_arguments")21 @patch("release_pull_request_generator.create_release_branch")22 @patch("release_pull_request_generator.Github")23 def test_adds_creator_to_assignees(24 self, github_mock, create_release_mock, parse_mock25 ):26 release_pull_request_generator.main()27 repo_mock = github_mock.return_value.get_repo.return_value28 repo_mock.create_pull.return_value.add_to_assignees.assert_called_once()29if __name__ == "__main__":...
test_create_release_branch.py
Source:test_create_release_branch.py
...9 date_mock.today.return_value = date(2019, 6, 13)10 date_mock.side_effect = lambda *args, **kw: date(*args, **kw)11 token_hex_mock.return_value = "1a2b3c4d"12 repository_mock = MagicMock()13 result = create_release_branch.create_release_branch(14 repository_mock, "develop", "release"15 )16 self.assertEqual(result, "release/2019-06-13-1a2b3c4d")17 @patch("create_release_branch.token_hex")18 @patch("create_release_branch.date")19 def test_creates_new_branch(self, date_mock, token_hex_mock):20 date_mock.today.return_value = date(2019, 6, 13)21 date_mock.side_effect = lambda *args, **kw: date(*args, **kw)22 token_hex_mock.return_value = "1a2b3c4d"23 commit_mock = MagicMock(sha="11111111")24 develop_branch_mock = MagicMock(commit=commit_mock)25 repository_mock = MagicMock()26 repository_mock.get_branch.return_value = develop_branch_mock27 create_release_branch.create_release_branch(28 repository_mock, "develop", "release"29 )30 repository_mock.create_git_ref.assert_called_once_with(31 ref="refs/heads/release/2019-06-13-1a2b3c4d", sha="11111111"32 )33if __name__ == "__main__":...
release_pull_request_generator.py
Source:release_pull_request_generator.py
...12 master_branch = args.master_branch13 release_branch_prefix = args.release_branch_prefix14 github = Github(github_token)15 repository = github.get_repo(repository_name)16 release_branch = create_release_branch(17 repository, develop_branch, release_branch_prefix18 )19 fields = pull_request_fields(20 repository, master_branch, release_branch, pull_request_creator21 )22 pull_request = repository.create_pull(23 title=fields["title"],24 body=fields["body"],25 base=master_branch,26 head=release_branch,27 )28 pull_request.create_review_request(fields["reviewers"])29 pull_request.add_to_assignees(pull_request_creator)30if __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!!