<commit_before>import time
import unittest

from conans.server.revision_list import RevisionList
from conans.util.dates import from_timestamp_to_iso8601


class RevisionListTest(unittest.TestCase):

    def test_remove_latest(self):
        rev = RevisionList()
        rev.add_revision("rev1")
        rev.add_revision("rev2")

        dumped = rev.dumps()
        loaded = RevisionList.loads(dumped)
        self.assertEqual(rev, loaded)
        self.assertEqual(loaded.latest_revision().revision, "rev2")

        loaded.remove_revision("rev2")
        self.assertEqual(loaded.latest_revision().revision, "rev1")

    def test_remove_non_latest(self):
        rev = RevisionList()
        rev.add_revision("rev1")
        rev.add_revision("rev2")

        dumped = rev.dumps()
        loaded = RevisionList.loads(dumped)
        loaded.remove_revision("rev1")
        self.assertEqual(loaded.latest_revision().revision, "rev2")

    def test_compatibility_with_timestamps(self):
        the_time = time.time()
        iso = from_timestamp_to_iso8601(the_time)
        old_contents = '{"revisions": [{"revision": "rev1", "time": %s}, ' \<commit_msg>Fix test<commit_after>from math import floor

import time
import unittest

from conans.server.revision_list import RevisionList
from conans.util.dates import from_timestamp_to_iso8601


class RevisionListTest(unittest.TestCase):

    def test_remove_latest(self):
        rev = RevisionList()
        rev.add_revision("rev1")
        rev.add_revision("rev2")

        dumped = rev.dumps()
        loaded = RevisionList.loads(dumped)
        self.assertEqual(rev, loaded)
        self.assertEqual(loaded.latest_revision().revision, "rev2")

        loaded.remove_revision("rev2")
        self.assertEqual(loaded.latest_revision().revision, "rev1")

    def test_remove_non_latest(self):
        rev = RevisionList()
        rev.add_revision("rev1")
        rev.add_revision("rev2")

        dumped = rev.dumps()
        loaded = RevisionList.loads(dumped)
        loaded.remove_revision("rev1")
        self.assertEqual(loaded.latest_revision().revision, "rev2")

    def test_compatibility_with_timestamps(self):
        the_time = floor(time.time())
        iso = from_timestamp_to_iso8601(the_time)
        old_contents = '{"revisions": [{"revision": "rev1", "time": %s}, ' \
{'fraction_non_alphanumeric': 0.11683848797250859, 'fraction_numerical': 0.015463917525773196, 'mean_word_length': 3.320964749536178, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5778930', 'n_tokens_mistral': 758, 'n_tokens_neox': 734, 'n_words': 117}