Ejemplo n.º 1
0
    def testGetClientIdFromQueue(self):
        def MockQueue(path):
            return mock.MagicMock(Split=lambda: path.split("/")[1:])

        # Returns None if the path can't be parsed.
        self.assertIsNone(
            queue_manager._GetClientIdFromQueue(MockQueue("arbitrary string")))

        # Returns None if the queue isn't a client queue.
        self.assertIsNone(
            queue_manager._GetClientIdFromQueue(MockQueue("/H.fedcba98")))
        self.assertIsNone(
            queue_manager._GetClientIdFromQueue(
                MockQueue("/H.01234567/tasks")))

        # Returns None if the object isn't a queue.
        self.assertIsNone(
            queue_manager._GetClientIdFromQueue(
                MockQueue("/C.0123456789abcdef0")))
        # Returns client ID if the queue is a client queue.
        self.assertEqual(
            "C.abcdefabcdefabcde",
            queue_manager._GetClientIdFromQueue(
                MockQueue("/C.ABCDefabcdefabcde/tasks")))

        # Letter case doesn't matter. The return value is always lowercase, except
        # for the capital "C" in the front.
        self.assertEqual(
            "C.0123456789abcdef0",
            queue_manager._GetClientIdFromQueue(
                MockQueue("/C.0123456789AbCdEF0/TasKS")))
        self.assertEqual(
            "C.abcdefabcdefabcde",
            queue_manager._GetClientIdFromQueue(
                MockQueue("/c.ABCDEFABCDEFABCDE/tasks")))
Ejemplo n.º 2
0
  def testGetClientIdFromQueue(self):

    def MockQueue(path):
      return mock.MagicMock(Split=lambda: path.split("/")[1:])

    # Returns None if the path can't be parsed.
    self.assertIsNone(
        queue_manager._GetClientIdFromQueue(MockQueue("arbitrary string")))

    # Returns None if the queue isn't a client queue.
    self.assertIsNone(
        queue_manager._GetClientIdFromQueue(MockQueue("/H.fedcba98")))
    self.assertIsNone(
        queue_manager._GetClientIdFromQueue(MockQueue("/H.01234567/tasks")))

    # Returns None if the object isn't a queue.
    self.assertIsNone(
        queue_manager._GetClientIdFromQueue(MockQueue("/C.0123456789abcdef0")))
    # Returns client ID if the queue is a client queue.
    self.assertEqual(
        "C.abcdefabcdefabcde",
        queue_manager._GetClientIdFromQueue(
            MockQueue("/C.ABCDefabcdefabcde/tasks")))

    # Letter case doesn't matter. The return value is always lowercase, except
    # for the capital "C" in the front.
    self.assertEqual(
        "C.0123456789abcdef0",
        queue_manager._GetClientIdFromQueue(
            MockQueue("/C.0123456789AbCdEF0/TasKS")))
    self.assertEqual(
        "C.abcdefabcdefabcde",
        queue_manager._GetClientIdFromQueue(
            MockQueue("/c.ABCDEFABCDEFABCDE/tasks")))