'Check that NEWEST_TIMESTAMP works as expected.'

def testNewestTimestamps(self):

    predicate1 = 'metadata:predicate1'
    predicate2 = 'metadata:predicate2'
    data_store.DB.Set(self.test_row, predicate1, '1.1', timestamp=10000, replace=False, token=self.token)
    data_store.DB.Set(self.test_row, predicate1, '1.2', timestamp=20000, replace=False, token=self.token)
    data_store.DB.Set(self.test_row, predicate2, '2.1', timestamp=11000, replace=False, token=self.token)
    data_store.DB.Set(self.test_row, predicate2, '2.2', timestamp=22000, replace=False, token=self.token)
    result = data_store.DB.ResolvePrefix(self.test_row, predicate1, timestamp=data_store.DB.ALL_TIMESTAMPS, token=self.token)
    values = [x[1] for x in result]
    self.assertEqual(len(values), 2)
    self.assertListEqual(values, ['1.2', '1.1'])
    times = [x[2] for x in result]
    self.assertListEqual(times, [20000, 10000])
    result = data_store.DB.ResolvePrefix(self.test_row, predicate1, timestamp=data_store.DB.NEWEST_TIMESTAMP, token=self.token)
    self.assertEqual(len(result), 1)
    self.assertEqual(result[0][1], '1.2')
    self.assertEqual(result[0][2], 20000)
    result = list(data_store.DB.ResolvePrefix(self.test_row, 'metadata:', timestamp=data_store.DB.ALL_TIMESTAMPS, token=self.token))
    self.assertEqual(len(result), 4)
    self.assertListEqual([r for r in result if (r[0] == 'metadata:predicate1')], [(u'metadata:predicate1', '1.2', 20000), (u'metadata:predicate1', '1.1', 10000)])
    self.assertListEqual([r for r in result if (r[0] == 'metadata:predicate2')], [(u'metadata:predicate2', '2.2', 22000), (u'metadata:predicate2', '2.1', 11000)])
    result = list(data_store.DB.ResolvePrefix(self.test_row, 'metadata:', timestamp=data_store.DB.NEWEST_TIMESTAMP, token=self.token))
    self.assertItemsEqual(result, [(u'metadata:predicate1', '1.2', 20000), (u'metadata:predicate2', '2.2', 22000)])
