def test_list_previously_deployed_shas_no_deploy_groups(): fake_refs = { "refs/tags/paasta-test.deploy.group-00000000T000000-deploy": "SHA_IN_OUTPUT", "refs/tags/paasta-other.deploy.group-00000000T000000-deploy": "SHA_IN_OUTPUT_2", "refs/tags/paasta-nonexistant.deploy.group-00000000T000000-deploy": "SHA_NOT_IN_OUTPUT", } fake_deploy_groups = ["test.deploy.group", "other.deploy.group"] with patch( "paasta_tools.cli.cmds.rollback.list_remote_refs", autospec=True, return_value=fake_refs, ), patch( "paasta_tools.cli.cmds.rollback.list_deploy_groups", autospec=True, return_value=fake_deploy_groups, ): fake_args = Mock( service="fake_service", deploy_groups="", soa_dir="/fake/soa/dir", force=None, ) assert set(list_previously_deployed_shas(fake_args)) == { "SHA_IN_OUTPUT", "SHA_IN_OUTPUT_2", }
def test_list_previously_deployed_shas_no_deploy_groups(): fake_refs = { 'refs/tags/paasta-test.deploy.group-00000000T000000-deploy': 'SHA_IN_OUTPUT', 'refs/tags/paasta-other.deploy.group-00000000T000000-deploy': 'SHA_IN_OUTPUT_2', 'refs/tags/paasta-nonexistant.deploy.group-00000000T000000-deploy': 'SHA_NOT_IN_OUTPUT', } fake_deploy_groups = ['test.deploy.group', 'other.deploy.group'] with contextlib.nested( patch('paasta_tools.cli.cmds.rollback.list_remote_refs', autospec=True, return_value=fake_refs), patch('paasta_tools.cli.cmds.rollback.list_deploy_groups', autospec=True, return_value=fake_deploy_groups), ) as ( _, _, ): fake_args = Mock( service='fake_service', deploy_groups='', soa_dir='/fake/soa/dir', ) assert set(list_previously_deployed_shas(fake_args)) == { 'SHA_IN_OUTPUT', 'SHA_IN_OUTPUT_2' }
def test_list_previously_deployed_shas(): fake_refs = { 'refs/tags/paasta-test.deploy.group-00000000T000000-deploy': 'SHA_IN_OUTPUT', 'refs/tags/paasta-other.deploy.group-00000000T000000-deploy': 'NOT_IN_OUTPUT', } fake_configs = [ MarathonServiceConfig( service='fake_service', instance='fake_instance', cluster='fake_cluster', config_dict={'deploy_group': 'test.deploy.group'}, branch_dict={}, ) ] with contextlib.nested( patch('paasta_tools.cli.cmds.rollback.list_remote_refs', autospec=True, return_value=fake_refs), patch( 'paasta_tools.cli.cmds.rollback.get_instance_config_for_service', autospec=True, return_value=fake_configs), ) as ( _, _, ): fake_args = Mock( service='fake_service', deploy_groups='test.deploy.group,nonexistant.deploy.group', soa_dir='/fake/soa/dir', ) assert set( list_previously_deployed_shas(fake_args)) == {'SHA_IN_OUTPUT'}
def test_list_previously_deployed_shas_no_deploy_groups(): fake_refs = { 'refs/tags/paasta-test.deploy.group-00000000T000000-deploy': 'SHA_IN_OUTPUT', 'refs/tags/paasta-other.deploy.group-00000000T000000-deploy': 'SHA_IN_OUTPUT_2', 'refs/tags/paasta-nonexistant.deploy.group-00000000T000000-deploy': 'SHA_NOT_IN_OUTPUT', } fake_configs = [ MarathonServiceConfig( service='fake_service', instance='fake_instance', cluster='fake_cluster', config_dict={'deploy_group': 'test.deploy.group'}, branch_dict={}, ), MarathonServiceConfig( service='fake_service', instance='fake_instance', cluster='fake_cluster', config_dict={'deploy_group': 'other.deploy.group'}, branch_dict={}, ), ] with contextlib.nested( patch('paasta_tools.cli.cmds.rollback.list_remote_refs', autospec=True, return_value=fake_refs), patch('paasta_tools.cli.cmds.rollback.get_instance_config_for_service', autospec=True, return_value=fake_configs), ) as ( _, _, ): fake_args = Mock( service='fake_service', deploy_groups='', ) assert set(list_previously_deployed_shas(fake_args)) == {'SHA_IN_OUTPUT', 'SHA_IN_OUTPUT_2'}
def test_list_previously_deployed_shas(): fake_refs = { 'refs/tags/paasta-test.deploy.group-00000000T000000-deploy': 'SHA_IN_OUTPUT', 'refs/tags/paasta-other.deploy.group-00000000T000000-deploy': 'NOT_IN_OUTPUT', } fake_deploy_groups = ['test.deploy.group'] with patch( 'paasta_tools.cli.cmds.rollback.list_remote_refs', autospec=True, return_value=fake_refs, ), patch( 'paasta_tools.cli.cmds.rollback.list_deploy_groups', autospec=True, return_value=fake_deploy_groups, ): fake_args = Mock( service='fake_service', deploy_groups='test.deploy.group,nonexistant.deploy.group', soa_dir='/fake/soa/dir', force=None, ) assert set( list_previously_deployed_shas(fake_args)) == {'SHA_IN_OUTPUT'}
def test_list_previously_deployed_shas(): fake_refs = { 'refs/tags/paasta-test.deploy.group-00000000T000000-deploy': 'SHA_IN_OUTPUT', 'refs/tags/paasta-other.deploy.group-00000000T000000-deploy': 'NOT_IN_OUTPUT', } fake_deploy_groups = ['test.deploy.group'] with contextlib.nested( patch('paasta_tools.cli.cmds.rollback.list_remote_refs', autospec=True, return_value=fake_refs), patch('paasta_tools.cli.cmds.rollback.list_deploy_groups', autospec=True, return_value=fake_deploy_groups), ) as ( _, _, ): fake_args = Mock( service='fake_service', deploy_groups='test.deploy.group,nonexistant.deploy.group', soa_dir='/fake/soa/dir', ) assert set(list_previously_deployed_shas(fake_args)) == {'SHA_IN_OUTPUT'}