Example #1
0
 def do_GET(self):  # pylint: disable=invalid-name
   """Reply with a JSON representation of the current framwork and test
   states.
   """
   result = {'test': util.convert_to_dict(self.executor.GetState()),
             'framework': util.convert_to_dict(self.executor)}
   self.wfile.write(json.dumps(result))
Example #2
0
 def __call__(self, test_record):
   assert self.filename_pattern, 'filename_pattern required'
   if self.inline_attachments:
     as_dict = util.convert_to_dict(test_record)
   else:
     as_dict = util.convert_to_dict(test_record, ignore_keys='attachments')
   with open(self.filename_pattern % as_dict, 'w') as f:
     f.write(self.encode(as_dict))
Example #3
0
def _AttachJson(record, testrun):
  """Attach a copy of the JSON-ified record as an info parameter.

  Save a copy of the JSON-ified record in an attachment so we can access
  un-mangled fields later if we want.  Remove attachments since those get
  copied over and can potentially be quite large.
  """
  record_dict = util.convert_to_dict(record, ignore_keys=('attachments',))
  record_json = json_factory.OutputToJSON(sort_keys=True).encode(record_dict)
  testrun_param = testrun.info_parameters.add()
  testrun_param.name = 'OpenHTF_record.json'
  testrun_param.value_binary = record_json
  # pylint: disable=no-member
  testrun_param.type = testrun_pb2.InformationParameter.TEXT_UTF8
Example #4
0
        def do_GET(self):  # pylint: disable=invalid-name
            """Reply with a JSON representation of the current test state.

      If there is no test state make sure we still serve prompt state in case
      a test start trigger is waiting on a prompt.
      """
            state = self.executor.GetState()
            prompt = user_input.get_prompt_manager().prompt
            if state:
                self.wfile.write(state.AsJSON())
            else:
                result = {'state': 'NOTEST'}
                prompt = user_input.get_prompt_manager().prompt
                if prompt:
                    result['prompt'] = util.convert_to_dict(prompt)
                self.wfile.write(json.JSONEncoder().encode(result))
Example #5
0
    def do_GET(self):  # pylint: disable=invalid-name
      """Reply with a JSON representation of the current test state.

      If there is no test state make sure we still serve prompt state in case
      a test start trigger is waiting on a prompt.
      """
      state = self.executor.GetState()
      prompt = user_input.get_prompt_manager().prompt
      if state:
        self.wfile.write(state.AsJSON())
      else:
        result = {'state': 'NOTEST'}
        prompt = user_input.get_prompt_manager().prompt
        if prompt:
          result['prompt'] = util.convert_to_dict(prompt)
        self.wfile.write(json.JSONEncoder().encode(result))
Example #6
0
 def __call__(self, test_record):  # pylint: disable=invalid-name
   as_dict = util.convert_to_dict(test_record)
   with open(self.filename_pattern % as_dict, 'w') as f:  # pylint: disable=invalid-name
     f.write(self.encode(as_dict))
Example #7
0
 def AsJSON(self):
   """Return JSON representation of the test's serialized state."""
   return json.JSONEncoder().encode(util.convert_to_dict(self))
Example #8
0
 def __call__(self, test_record):  # pylint: disable=invalid-name
   as_dict = util.convert_to_dict(test_record)
   with open(self.filename_pattern % as_dict, 'w') as outfile:
     outfile.write(mfg_inspector.TestRunFromTestRecord(
         test_record).SerializeToString())