def _check_common_setup(self, parser, Remote): parser.parse_args.assert_called_once_with([]) args = parser.parse_args.return_value args.quiet = False main.setup_logging(args) Remote.assert_called_once_with(tests.dummy_config())
def test_user_dir_not_there(self, argparse, isdir, build_config): isdir.return_value = False build_config.load.return_value = tests.dummy_config() main.development_build([]) isdir.assert_called_once_with(defaults.SRC_DIR) ok_(not build_config.called)
def _check_dev_setup(self, parser, Manager, Remote, Generate): eq_(parser.add_argument.call_args_list, [ (('-f', '--full'), {'action': 'store_true', 'help': 'Force a complete rebuild on the forge server'}), ] ) Manager.assert_called_once_with(tests.dummy_config()) Generate.assert_called_once_with() self._check_common_setup(parser, Remote)
def test_dev_conf_change(self, argparse, Manager, Remote, Generate, shutil, isdir, build_config): parser = argparse.ArgumentParser.return_value args = parser.parse_args.return_value args.full = False Manager.return_value.need_new_templates_for_config.return_value = True Remote.return_value.server_says_should_rebuild.return_value = dict( should_rebuild = False, reason = 'testing', stable_platform = 'v1.2', platform_state = 'active', ) Remote.return_value.build.return_value = {"id": -1} Remote.return_value._api_post.return_value = { "config": '{"dummy_config": true}', "config_hash": "dummy config hash", } isdir.return_value = True build_config.load.return_value = tests.dummy_config() build_config.load_app.return_value = tests.dummy_app_config() main.development_build([]) Manager.return_value.need_new_templates_for_config.assert_called_once_with() Remote.return_value.build.assert_called_once_with(development=True, template_only=True, config={'dummy_config': True}) Manager.return_value.fetch_template_apps_and_instructions.assert_called_once_with(Remote.return_value.build.return_value) eq_(shutil.rmtree.call_args_list, [ ( ('development',), {'ignore_errors': True} ), ( (path.join('development', 'generate_dynamic'),), {'ignore_errors': True} ) ]) shutil.copytree.assert_called_once_with(".template", 'development') Generate.return_value.all.assert_called_once_with('development', defaults.SRC_DIR, extra_args=[], config={'config_hash': 'dummy config hash', 'dummy_config': True} )
def test_normal(self, current_call, argparse, Remote, mock_os, build_config, development_build): mock_os.sep = real_os.sep parser = argparse.ArgumentParser.return_value parser.parse_args.return_value.name = None mock_os.path.exists.return_value = False call = current_call.return_value input = 'user input' call.wait_for_response.return_value = {'data': {'name': input}} remote = Remote.return_value build_config.load.return_value = tests.dummy_config() main.create([]) mock_os.path.exists.assert_called_once_with(defaults.SRC_DIR) remote.create.assert_called_once_with(input) remote.fetch_initial.assert_called_once_with(remote.create.return_value) development_build.assert_called_once_with([])
def test_cookies_not_there(self, os, LWPCookieJar): os.path.exists.return_value = False os.getcwd.return_value = '/here' Remote(dummy_config()) LWPCookieJar.return_value.save.assert_called_once_with()
def setup(self): self.test_config = dummy_config() self.remote = Remote(self.test_config)
def setup(self): self.manager = Manager(dummy_config())