Home | History | Annotate | Download | only in cellular
      1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 import cellular_system_error
      6 
      7 
      8 class AirStateVerifierPermissive(object):
      9     """An abstraction for verifying the air-side cellular state.
     10 
     11     This version is for commercial networks where we can't verify
     12     anything, so it's a no-op."""
     13     def AssertDataStatusIn(self, states):
     14         """Assert that the device's status is in states.
     15         Arguments:
     16             states:  Collection of states
     17         Raises:
     18             Error on failure.
     19         """
     20         # This base class is for commercial networks.  It can't verify, so
     21         # it doesn't
     22         pass
     23 
     24     def IsDataStatusIn(self, expected):
     25         return True
     26 
     27 
     28 class AirStateVerifierBasestation(object):
     29     """An abstraction for verifying the air-side cellular state.
     30 
     31     This version checks with the base station emulator.
     32     """
     33     def __init__(self, base_station):
     34         self.base_station = base_station
     35 
     36     def IsDataStatusIn(self, expected):
     37         actual = self.base_station.GetUeDataStatus()
     38         return actual in expected
     39 
     40     def AssertDataStatusIn(self, expected):
     41         actual = self.base_station.GetUeDataStatus()
     42         if actual not in expected:
     43             raise cellular_system_error.BadState(
     44                 'expected UE in status %s, got %s' % (expected, actual))
     45