Example #1
0
    def test_conf_stop_on_first_failure_phase(self):

        ev = threading.Event()
        group = phase_group.PhaseGroup(
            main=[phase_return_fail_and_continue, phase_one],
            teardown=[lambda: ev.set()])  # pylint: disable=unnecessary-lambda
        test = openhtf.Test(group)
        test.configure(default_dut_id='dut', )
        conf.load(stop_on_first_failure=True)
        executor = test_executor.TestExecutor(test.descriptor,
                                              'uid',
                                              start_phase,
                                              test._test_options,
                                              run_with_profiling=False)

        executor.start()
        executor.wait()
        record = executor.test_state.test_record
        self.assertEqual(record.phases[0].name, start_phase.name)
        self.assertTrue(record.outcome, Outcome.FAIL)
        # Verify phase_one was not run
        ran_phase = [phase.name for phase in record.phases]
        self.assertNotIn('phase_one', ran_phase)
        # Teardown function should be executed.
        self.assertTrue(ev.wait(1))
        executor.close()
Example #2
0
def main():
    conf.load(station_server_port='4444')
    with station_server.StationServer() as server:
        web_launcher.launch('http://localhost:4444')
        for _ in range(5):
            test = htf.Test(hello_world)
            test.add_output_callbacks(server.publish_final_state)
            test.execute(test_start=user_input.prompt_for_test_start())
Example #3
0
def main():
    conf.load(station_server_port='4444')
    with station_server.StationServer() as server:
        while True:
            tests = gather_tests()
            next_test = get_next_test()
            test = tests[next_test]()
            #test.add_output_callbacks(publish_to_db)
            test.add_output_callbacks(server.publish_final_state)
            test.execute(test_start=user_input.prompt_for_test_start())
Example #4
0
 def test_as_dict(self):
   conf.load(station_id='station_id')
   self.assertEquals({
       'flag_key': 'flag_value',
       'enable_station_discovery': True,
       'station_api_port': 8888,
       'allow_unset_measurements': False,
       'capture_source': False,
       'station_discovery_string': 'OPENHTF_DISCOVERY',
       'station_api_bind_address': '0.0.0.0',
       'station_id': 'station_id',
       'other_flag': 'other_value',
       'string_default': 'default',
       'none_default': None,
       'teardown_timeout_s': 3,
       'max_history_size_mb': 256}, conf._asdict())
Example #5
0
 def test_as_dict(self):
   conf.load(station_id='station_id')
   self.assertEqual({
       'flag_key': 'flag_value',
       'true_value': True,
       'num_value': 100,
       'cancel_timeout_s': 2,
       'example_plug_increment_size': 1,
       'allow_unset_measurements': False,
       'capture_source': False,
       'station_id': 'station_id',
       'other_flag': 'other_value',
       'plug_teardown_timeout_s': 0,
       'string_default': 'default',
       'none_default': None,
       'teardown_timeout_s': 30,
   }, conf._asdict())
Example #6
0
 def test_as_dict(self):
     conf.load(station_id='station_id')
     self.assertEqual(
         {
             'flag_key': 'flag_value',
             'true_value': True,
             'num_value': 100,
             'cancel_timeout_s': 2,
             'example_plug_increment_size': 1,
             'allow_unset_measurements': False,
             'capture_source': False,
             'station_id': 'station_id',
             'other_flag': 'other_value',
             'plug_teardown_timeout_s': 0,
             'string_default': 'default',
             'none_default': None,
             'teardown_timeout_s': 30,
         }, conf._asdict())
Example #7
0
 def test_as_dict(self):
     conf.load(station_id='station_id')
     self.assertEquals(
         {
             'flag_key': 'flag_value',
             'enable_station_discovery': True,
             'station_api_port': 8888,
             'allow_unset_measurements': False,
             'capture_source': False,
             'station_discovery_string': 'OPENHTF_DISCOVERY',
             'station_api_bind_address': '0.0.0.0',
             'station_id': 'station_id',
             'other_flag': 'other_value',
             'string_default': 'default',
             'none_default': None,
             'teardown_timeout_s': 30,
             'max_history_size_mb': 256
         }, conf._asdict())
Example #8
0
 def test_load_no_override(self):
     conf.load(overridden_key='overridden_value')
     conf.load(overridden_key='new_value', _override=False)
     self.assertEqual('overridden_value', conf.overridden_key)
Example #9
0
 def modifies_conf():
     conf.load(string_default='modified')
     self.assertEqual('modified', conf.string_default)
Example #10
0
 def test_load_override(self):
     conf.load(overridden_key='overridden_value')
     conf.load(overridden_key='new_value')
     self.assertEquals('new_value', conf.overridden_key)
Example #11
0
 def test_non_str_flag_values(self):
   self.assertEqual(True, conf.true_value)
   self.assertEqual(100, conf.num_value)
   # Make sure flag value takes precedence, even if a value is loaded.
   conf.load(flag_key='loaded_value')
   self.assertEqual(True, conf.true_value)
Example #12
0
 def test_flag_values(self):
   self.assertEqual('flag_value', conf.flag_key)
   self.assertEqual('other_value', conf.other_flag)
   # Make sure flag value takes precedence, even if a value is loaded.
   conf.load(flag_key='loaded_value')
   self.assertEqual('flag_value', conf.flag_key)
Example #13
0
 def modifies_conf():
   conf.load(string_default='modified')
   self.assertEqual('modified', conf.string_default)
Example #14
0
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


"""Simple OpenHTF test which launches the web GUI client."""

import openhtf as htf
from openhtf.util import conf

from openhtf.output.servers import station_server
from openhtf.output.web_gui import web_launcher
from openhtf.plugs import user_input


@htf.measures(htf.Measurement('hello_world_measurement'))
def hello_world(test):
  test.logger.info('Hello World!')
  test.measurements.hello_world_measurement = 'Hello Again!'


if __name__ == '__main__':
  conf.load(station_server_port='4444')
  with station_server.StationServer() as server:
    web_launcher.launch('http://localhost:4444')
    for i in range(5):
      test = htf.Test(hello_world)
      test.add_output_callbacks(server.publish_final_state)
      test.execute(test_start=user_input.prompt_for_test_start())
Example #15
0
 def test_flag_values(self):
     self.assertEqual('flag_value', conf.flag_key)
     self.assertEqual('other_value', conf.other_flag)
     # Make sure flag value takes precedence, even if a value is loaded.
     conf.load(flag_key='loaded_value')
     self.assertEqual('flag_value', conf.flag_key)
Example #16
0
 def test_load_no_override(self):
   conf.load(overridden_key='overridden_value')
   conf.load(overridden_key='new_value', _override=False)
   self.assertEqual('overridden_value', conf.overridden_key)
Example #17
0
 def test_non_str_flag_values(self):
     self.assertEqual(True, conf.true_value)
     self.assertEqual(100, conf.num_value)
     # Make sure flag value takes precedence, even if a value is loaded.
     conf.load(flag_key='loaded_value')
     self.assertEqual(True, conf.true_value)
Example #18
0
 def test_load_override(self):
   conf.load(overridden_key='overridden_value')
   conf.load(overridden_key='new_value')
   self.assertEquals('new_value', conf.overridden_key)