def test_upload_java_app_with_no_appid(self):
    # add in mocks so that there is an appengine-web.xml, but with no appid set
    flexmock(os.path)
    os.path.should_call('exists')
    os.path.should_receive('exists').with_args(
      AppEngineHelper.get_app_yaml_location(self.app_dir)).and_return(False)
    appengine_web_xml_location = AppEngineHelper.get_appengine_web_xml_location(
      self.app_dir)
    os.path.should_receive('exists').with_args(
      AppEngineHelper.get_appengine_web_xml_location(self.app_dir)).and_return(True)
    flexmock(AppEngineHelper).should_receive('get_app_id_from_app_config').and_return('app_id')
    flexmock(AppEngineHelper).should_receive('get_app_runtime_from_app_config').and_return('runtime')
    flexmock(LocalState).should_receive('get_secret_key').and_return()

    # mock out reading the app.yaml file
    builtins = flexmock(sys.modules['__builtin__'])
    builtins.should_call('open')  # set the fall-through

    fake_appengine_web_xml = flexmock(name="fake_appengine_web_xml")
    fake_appengine_web_xml.should_receive('read').and_return("<baz></baz>\n" +
      "<application></application>")
    builtins.should_receive('open').with_args(appengine_web_xml_location, 'r') \
      .and_return(fake_appengine_web_xml)

    argv = [
      "--keyname", self.keyname,
      "--file", self.app_dir
    ]
    options = ParseArgs(argv, self.function).args
    self.assertRaises(AppEngineConfigException, AppScaleTools.upload_app, options)
示例#2
0
    def test_upload_java_app_with_no_appid(self):
        # add in mocks so that there is an appengine-web.xml, but with no appid set
        flexmock(os.path)
        os.path.should_call('exists')
        os.path.should_receive('exists').with_args(
            AppEngineHelper.get_app_yaml_location(
                self.app_dir)).and_return(False)
        appengine_web_xml_location = AppEngineHelper.get_appengine_web_xml_location(
            self.app_dir)
        os.path.should_receive('exists').with_args(
            AppEngineHelper.get_appengine_web_xml_location(
                self.app_dir)).and_return(True)
        flexmock(AppEngineHelper).should_receive(
            'get_app_id_from_app_config').and_return('app_id')
        flexmock(AppEngineHelper).should_receive(
            'get_app_runtime_from_app_config').and_return('runtime')
        flexmock(LocalState).should_receive('get_secret_key').and_return()

        # mock out reading the app.yaml file
        builtins = flexmock(sys.modules['__builtin__'])
        builtins.should_call('open')  # set the fall-through

        fake_appengine_web_xml = flexmock(name="fake_appengine_web_xml")
        fake_appengine_web_xml.should_receive('read').and_return(
            "<baz></baz>\n" + "<application></application>")
        builtins.should_receive('open').with_args(appengine_web_xml_location, 'r') \
          .and_return(fake_appengine_web_xml)

        argv = ["--keyname", self.keyname, "--file", self.app_dir]
        options = ParseArgs(argv, self.function).args
        self.assertRaises(AppEngineConfigException, AppScaleTools.upload_app,
                          options)
示例#3
0
    def test_upload_app_with_no_app_yaml_or_appengine_web_xml(self):
        # all app engine apps must have a config file - abort if we can't find one

        # add in mocks so that the config files aren't found
        flexmock(os.path)
        os.path.should_call('exists')
        os.path.should_receive('exists').with_args(
            AppEngineHelper.get_app_yaml_location(
                self.app_dir)).and_return(False)
        os.path.should_receive('exists').with_args(
          AppEngineHelper.get_appengine_web_xml_location(self.app_dir)) \
          .and_return(False)

        argv = ["--keyname", self.keyname, "--file", self.app_dir]
        options = ParseArgs(argv, self.function).args
        self.assertRaises(AppEngineConfigException, AppScaleTools.upload_app,
                          options)
  def test_upload_app_with_no_app_yaml_or_appengine_web_xml(self):
    # all app engine apps must have a config file - abort if we can't find one

    # add in mocks so that the config files aren't found
    flexmock(os.path)
    os.path.should_call('exists')
    os.path.should_receive('exists').with_args(
      AppEngineHelper.get_app_yaml_location(self.app_dir)).and_return(False)
    os.path.should_receive('exists').with_args(
      AppEngineHelper.get_appengine_web_xml_location(self.app_dir)) \
      .and_return(False)

    argv = [
      "--keyname", self.keyname,
      "--file", self.app_dir
    ]
    options = ParseArgs(argv, self.function).args
    self.assertRaises(AppEngineConfigException, AppScaleTools.upload_app, options)