def testPostIdOrdering(self):
    def _Compare(episode_id1, photo_id1, episode_id2, photo_id2):
      result = cmp(episode_id1, episode_id2)
      if result == 0:
        result = cmp(photo_id1, photo_id2)

      post_id1 = Post.ConstructPostId(episode_id1, photo_id1)
      post_id2 = Post.ConstructPostId(episode_id2, photo_id2)
      self.assertEqual(cmp(post_id1, post_id2), result)

    timestamp = time.time()

    episode_id1 = Episode.ConstructEpisodeId(timestamp, 1, (127, None))
    episode_id2 = Episode.ConstructEpisodeId(timestamp, 1, (128, None))
    photo_id1 = Photo.ConstructPhotoId(timestamp, 1, 128)
    photo_id2 = Photo.ConstructPhotoId(timestamp, 1, 127)
    _Compare(episode_id1, photo_id1, episode_id2, photo_id2)

    episode_id1 = Episode.ConstructEpisodeId(timestamp, 127, 1)
    episode_id2 = Episode.ConstructEpisodeId(timestamp, 128, 1)
    photo_id1 = Photo.ConstructPhotoId(timestamp, 128, (1, None))
    photo_id2 = Photo.ConstructPhotoId(timestamp, 127, (1, None))
    _Compare(episode_id1, photo_id1, episode_id2, photo_id2)

    episode_id1 = Episode.ConstructEpisodeId(timestamp, 0, 0)
    episode_id2 = Episode.ConstructEpisodeId(timestamp, 0, 0)
    photo_id1 = Photo.ConstructPhotoId(timestamp, 0, 0)
    photo_id2 = Photo.ConstructPhotoId(timestamp, 0, 0)
    _Compare(episode_id1, photo_id1, episode_id2, photo_id2)

    episode_id1 = Episode.ConstructEpisodeId(timestamp, 1, 0)
    episode_id2 = Episode.ConstructEpisodeId(timestamp, 1, 1)
    photo_id1 = Photo.ConstructPhotoId(timestamp, 1, 1)
    photo_id2 = Photo.ConstructPhotoId(timestamp, 1, 0)
    _Compare(episode_id1, photo_id1, episode_id2, photo_id2)

    episode_id1 = Episode.ConstructEpisodeId(0, 0, 0)
    episode_id2 = Episode.ConstructEpisodeId(1, 0, 0)
    photo_id1 = Photo.ConstructPhotoId(1, 0, (0, None))
    photo_id2 = Photo.ConstructPhotoId(0, 0, (0, None))
    _Compare(episode_id1, photo_id1, episode_id2, photo_id2)

    episode_id1 = Episode.ConstructEpisodeId(timestamp, 0, (0, '1'))
    episode_id2 = Episode.ConstructEpisodeId(timestamp, 0, (0, '2'))
    photo_id1 = Photo.ConstructPhotoId(timestamp, 0, (0, None))
    photo_id2 = Photo.ConstructPhotoId(timestamp, 0, (0, None))
    _Compare(episode_id1, photo_id1, episode_id2, photo_id2)

    episode_id1 = Episode.ConstructEpisodeId(timestamp, 0, 0)
    episode_id2 = Episode.ConstructEpisodeId(timestamp, 0, 0)
    photo_id1 = Photo.ConstructPhotoId(timestamp, 0, (0, u'ab'))
    photo_id2 = Photo.ConstructPhotoId(timestamp, 0, (0, u'cd'))
    _Compare(episode_id1, photo_id1, episode_id2, photo_id2)
Verify that post_id sorts like (episode_id, photo_id) does.
dataset/ETHPy150Open viewfinderco/viewfinder/backend/db/test/post_test.py/PostTestCase.testPostIdOrdering