def test_trace_testing(fabric_fixture):
  tazor = ActiveObject()
  tazor.start_at(arming)
  time.sleep(0.4)
  target_with_timestamp = tazor.trace()
  print(target_with_timestamp)
  other_with_timestamp = tazor.trace()

  with stripped(target_with_timestamp) as twt, \
       stripped(other_with_timestamp) as owt:

    for target_item, other_item in zip(twt, owt):
      print(target_item)
      assert(target_item == other_item)

  with stripped('[2017-11-05 15:17:39.424492] [75c8c] e->BATTERY_CHARGE() armed->armed') as swt:
    assert(swt == '[75c8c] e->BATTERY_CHARGE() armed->armed')

  assert(tazor.state.fun.__name__ == 'armed')
Esempio n. 2
0
def test_strip_with_nothing_to_do():
  '''Ignore blocks that don't have a timestamp'''

  target = \
    '''[75c8c] e->start_at() top->arming
       [75c8c] e->BATTERY_CHARGE() arming->armed
       [75c8c] e->BATTERY_CHARGE() armed->armed
       [75c8c] e->BATTERY_CHARGE() armed->armed
    '''

  result = \
    '''[75c8c] e->start_at() top->arming
       [75c8c] e->BATTERY_CHARGE() arming->armed
       [75c8c] e->BATTERY_CHARGE() armed->armed
       [75c8c] e->BATTERY_CHARGE() armed->armed
     '''
  with stripped(target) as twt, \
       stripped(result) as owt:
    for target_item, other_item in zip(twt, owt):
      assert(target_item == other_item)
Esempio n. 3
0
def test_trace_testing_single_block():
  '''Remove the timestamp off of a group of lines'''

  target = \
    '''[2017-11-05 21:31:56.098526] [75c8c] e->start_at() top->arming
       [2017-11-05 21:31:56.200047] [75c8c] e->BATTERY_CHARGE() arming->armed
       [2017-11-05 21:31:56.300974] [75c8c] e->BATTERY_CHARGE() armed->armed
       [2017-11-05 21:31:56.401682] [75c8c] e->BATTERY_CHARGE() armed->armed
    '''

  result = \
    '''[2018-11-05 01:31:56.098526] [75c8c] e->start_at() top->arming
       [2018-11-05 01:31:56.200047] [75c8c] e->BATTERY_CHARGE() arming->armed
       [2018-11-05 01:31:56.300974] [75c8c] e->BATTERY_CHARGE() armed->armed
       [2018-11-05 01:31:56.401682] [75c8c] e->BATTERY_CHARGE() armed->armed
     '''

  with stripped(target) as twt, \
       stripped(result) as owt:
    for target_item, other_item in zip(twt, owt):
      assert(target_item == other_item)
Esempio n. 4
0
def test_trace_testing():
    tazor = ActiveObject()
    tazor.start_at(arming)
    time.sleep(0.4)
    target_with_timestamp = tazor.trace()
    print(target_with_timestamp)
    other_with_timestamp = tazor.trace()

    with stripped(target_with_timestamp) as twt, \
         stripped(other_with_timestamp) as owt:

        for target_item, other_item in zip(twt, owt):
            print(target_item)
            assert (target_item == other_item)

    with stripped(
            '[2017-11-05 15:17:39.424492] [75c8c] e->BATTERY_CHARGE() armed->armed'
    ) as swt:
        assert (swt == '[75c8c] e->BATTERY_CHARGE() armed->armed')

    assert (tazor.state.fun.__name__ == 'armed')
Esempio n. 5
0
def test_trace_testing_single_line():
  '''Remove the timestamp off of a signal line'''

  with stripped('[2017-11-05 15:17:39.424492] [75c8c] e->BATTERY_CHARGE() armed->armed') as swt:
    assert(swt == '[75c8c] e->BATTERY_CHARGE() armed->armed')
Esempio n. 6
0
    test_buzz_events('baking', baking_time_ms, baking_buzz_test_spec, buzz_times)

  # Confirm our graph's structure
  trace_target = """
  [2019-02-04 06:37:04.538413] [oven] e->start_at() top->off
  [2019-02-04 06:37:04.540290] [oven] e->Door_Open() off->door_open
  [2019-02-04 06:37:04.540534] [oven] e->Door_Close() door_open->off
  [2019-02-04 06:37:04.540825] [oven] e->Baking() off->baking
  [2019-02-04 06:37:04.541109] [oven] e->Door_Open() baking->door_open
  [2019-02-04 06:37:04.541393] [oven] e->Door_Close() door_open->baking
  [2019-02-04 06:37:04.541751] [oven] e->Toasting() baking->toasting
  [2019-02-04 06:37:04.542083] [oven] e->Door_Open() toasting->door_open
  [2019-02-04 06:37:04.542346] [oven] e->Door_Close() door_open->toasting
  """

  with stripped(trace_target) as stripped_target, \
       stripped(trace_through_all_states()) as stripped_trace_result:
    
    for target, result in zip(stripped_target, stripped_trace_result):
      assert(target == result)

  # Confirm the our statemachine is triggering the methods we want when we want them
  assert re.search(r'light_off', spy_on_light_off())

  # Confirm our light turns on
  assert re.search(r'light_on', spy_on_light_on())

  # Confirm the heater turns on
  assert re.search(r'heater_on', spy_on_heater_on())

  # Confirm the heater turns off
Esempio n. 7
0
                         buzz_times)

    # Confirm our graph's structure
    trace_target = """
  [2019-02-04 06:37:04.538413] [oven] e->start_at() top->off
  [2019-02-04 06:37:04.540290] [oven] e->Door_Open() off->door_open
  [2019-02-04 06:37:04.540534] [oven] e->Door_Close() door_open->off
  [2019-02-04 06:37:04.540825] [oven] e->Baking() off->baking
  [2019-02-04 06:37:04.541109] [oven] e->Door_Open() baking->door_open
  [2019-02-04 06:37:04.541393] [oven] e->Door_Close() door_open->baking
  [2019-02-04 06:37:04.541751] [oven] e->Toasting() baking->toasting
  [2019-02-04 06:37:04.542083] [oven] e->Door_Open() toasting->door_open
  [2019-02-04 06:37:04.542346] [oven] e->Door_Close() door_open->toasting
  """

    with stripped(trace_target) as stripped_target, \
         stripped(trace_through_all_states()) as stripped_trace_result:

        for target, result in zip(stripped_target, stripped_trace_result):
            assert (target == result)

    # Confirm the our statemachine is triggering the methods we want when we want them
    assert re.search(r'light_off', spy_on_light_off())

    # Confirm our light turns on
    assert re.search(r'light_on', spy_on_light_on())

    # Confirm the heater turns on
    assert re.search(r'heater_on', spy_on_heater_on())

    # Confirm the heater turns off