Exemplo n.º 1
0
 def displayRevisionId(self):  # pylint: disable=invalid-name
     """Returns human readable revision identifier."""
     if self.latestRevision:
         return '%s (currently %s)' % (traffic.GetKey(self),
                                       self.revisionName)
     else:
         return self.revisionName
Exemplo n.º 2
0
 def testGetKey_notLatest(self):
   self.assertEqual(
       traffic.GetKey(
           traffic.TrafficTarget({
               "revisionName": "rev1",
               "latestRevision": False
           })), "rev1")
Exemplo n.º 3
0
 def testGetKey_latest(self):
   self.assertEqual(
       traffic.GetKey(
           traffic.TrafficTarget({
               "revisionName": "rev1",
               "latestRevision": True
           })), "LATEST")
Exemplo n.º 4
0
 def _TrafficDict(traffic_list):
     if traffic_list:
         return {
             traffic.GetKey(tt): [tt]
             for tt in (traffic.TrafficTarget(x) for x in traffic_list)
         }
     else:
         return dict()
Exemplo n.º 5
0
 def status_traffic(self):
     if 'traffic' in self._props['status']:
         return {
             traffic.GetKey(tt): [tt]
             for tt in (traffic.TrafficTarget(x)
                        for x in self._props['status']['traffic'])
         }
     else:
         return dict()
Exemplo n.º 6
0
def SortKeyFromTarget(target):
    """Sorted key function to order TrafficTarget objects by key.

  TrafficTargets keys are one of:
  o revisionName
  o LATEST_REVISION_KEY

  Note LATEST_REVISION_KEY is not a str so its ordering with respect
  to revisionName keys is hard to predict.

  Args:
    target: A TrafficTarget.

  Returns:
    A value that sorts by revisionName with LATEST_REVISION_KEY
    last.
  """
    key = traffic.GetKey(target)
    if key == traffic.LATEST_REVISION_KEY:
        result = (2, key)
    else:
        result = (1, key)
    return result