def test_checkout_command_inverted_origin_upstream(self): """Test checkout cmd sees correct args when origin is inverted.""" args = self.parser.parse_args([ 'checkout', '--moz_remote_name', 'origin', '--fork_remote_name', 'upstream' ]) directory = self.locations()['tree'] with mock.patch('mkt.cmds.subprocess') as subprocess: cmds.checkout(args, self.parser, 'gh-user') self.assertEqual(subprocess.call.call_args_list, [ mock.call([ 'git', 'clone', '-o', 'origin', '[email protected]:mozilla/foo.git', '{0}/foo'.format(directory) ]), mock.call([ 'git', 'remote', 'add', 'upstream', '[email protected]:gh-user/foo.git' ], cwd='{0}/foo'.format(directory)), mock.call( ['git', 'config', 'branch.master.remote', 'upstream']) ])
def test_checkout_command_inverted_origin_upstream(self): """Test checkout cmd sees correct args when origin is inverted.""" args = self.parser.parse_args([ 'checkout', '--moz_remote_name', 'origin', '--fork_remote_name', 'upstream' ]) directory = self.locations()['tree'] with mock.patch('mkt.cmds.subprocess') as subprocess: cmds.checkout(args, self.parser, 'gh-user') self.assertEqual(subprocess.call.call_args_list, [ mock.call([ 'git', 'clone', '-o', 'origin', 'https://github.com/mozilla/foo.git', '{0}/foo'.format(directory) ]), mock.call([ 'git', 'remote', 'add', 'upstream', 'https://github.com/gh-user/foo.git' ], cwd='{0}/foo'.format(directory)), mock.call([ 'git', 'config', 'branch.master.remote', 'origin' ]) ])
def test_checkout_no_root(self): self.locations.return_value['tree'] = None cmds.locations = self.locations args = self.parser.parse_args(['checkout']) with self.assertRaises(SystemExit): cmds.checkout(args, self.parser, 'gh-user')