code: def test_active(self):
      obs = self.observe()
  
      # P1 can see P2.
      self.create_unit(
          unit_type=units.Protoss.Observer,
          owner=1,
          pos=utils.get_unit(obs[1], unit_type=units.Protoss.Nexus).pos,
      )
  
      self.step(32)  # Make sure visibility updates.
      obs = self.observe()
  
      for i, o in enumerate(obs):
          # Probes are active gathering
          for u in utils.get_units(
              o, unit_type=units.Protoss.Probe
          ).values():
              self.assert_unit(
                  u, display_type=sc_raw.Visible, is_active=True
              )
  
          # Own Nexus is idle
          nexus = utils.get_unit(
              o, unit_type=units.Protoss.Nexus, owner=i + 1
          )
          self.assert_unit(
              nexus, display_type=sc_raw.Visible, is_active=False
          )
          self.assertEmpty(nexus.orders)
  
          # Give it an action.
          self.raw_unit_command(i, "Train_Probe_quick", nexus.tag)
  
      # P1 can tell P2's Nexus is idle.
      nexus = utils.get_unit(
          obs[0], unit_type=units.Protoss.Nexus, owner=2
      )
      self.assert_unit(
          nexus, display_type=sc_raw.Visible, is_active=False
      )
  
      # Observer is idle.
      self.assert_unit(
          utils.get_unit(obs[0], unit_type=units.Protoss.Observer),
          display_type=sc_raw.Visible,
          is_active=False,
      )
      self.assert_unit(
          utils.get_unit(obs[1], unit_type=units.Protoss.Observer),
          display_type=sc_raw.Hidden,
          is_active=False,
      )
  
      self.step(32)
      obs = self.observe()
  
      # All Nexus are now active
      nexus0 = utils.get_unit(
          obs[0], unit_type=units.Protoss.Nexus, owner=1
      )
      nexus1 = utils.get_unit(
          obs[0], unit_type=units.Protoss.Nexus, owner=2
      )
      nexus2 = utils.get_unit(obs[1], unit_type=units.Protoss.Nexus)
      self.assert_unit(
          nexus0, display_type=sc_raw.Visible, is_active=True
      )
      self.assert_unit(
          nexus1, display_type=sc_raw.Visible, is_active=True
      )
      self.assert_unit(
          nexus2, display_type=sc_raw.Visible, is_active=True
      )
      self.assertLen(nexus0.orders, 1)
      self.assertLen(nexus2.orders, 1)
      self.assertEmpty(nexus1.orders)  # Can't see opponent's orders
  
      # Go back to a snapshot
      self.kill_unit(
          utils.get_unit(obs[0], unit_type=units.Protoss.Observer).tag
      )
  
      self.step(100)  # Make sure visibility updates.
      obs = self.observe()
  
      self.assertIsNone(
          utils.get_unit(obs[0], unit_type=units.Protoss.Observer)
      )
  
      # Own Nexus is now active, snapshot isn't.
      nexus0 = utils.get_unit(
          obs[0], unit_type=units.Protoss.Nexus, owner=1
      )
      nexus1 = utils.get_unit(
          obs[0], unit_type=units.Protoss.Nexus, owner=2
      )
      nexus2 = utils.get_unit(obs[1], unit_type=units.Protoss.Nexus)
      self.assert_unit(
          nexus0, display_type=sc_raw.Visible, is_active=True
      )
      self.assert_unit(
          nexus1, display_type=sc_raw.Snapshot, is_active=False
      )
      self.assert_unit(
          nexus2, display_type=sc_raw.Visible, is_active=True
      )
      self.assertLen(nexus0.orders, 1)
      self.assertLen(nexus2.orders, 1)
      self.assertEmpty(nexus1.orders)
  
file_path: pysc2/pysc2/tests/obs_test.py
imports: from absl.testing import absltest
  from pysc2.lib import actions
  from pysc2.lib import buffs
  from pysc2.lib import features
  from pysc2.lib import units
  from pysc2.tests import utils
  from s2clientprotocol import debug_pb2
  from s2clientprotocol import raw_pb2
label_desc: Use image node_id 7 for calling the ObsTest obj's underlying member method code with example usage: obj.test_active() without return types