def test_clear_mappings(self):
        hostmap = HostMap()
        self.perform_mapping(hostmap)
        self.assertEquals(len(hostmap.all_hostids()), 0)

        hostmap.add_hostref("test")

        self.perform_mapping(hostmap)
        self.assertEquals(len(hostmap.all_hostids()), 1)

        hostmap.clear_mappings()

        self.perform_mapping(hostmap)
        self.assertEquals(len(hostmap.all_hostids()), 0)
    def test_clear_mappings(self):
        hostmap = HostMap()
        self.perform_mapping(hostmap)
        self.assertEquals(len(hostmap.all_hostids()), 0)

        hostmap.add_hostref("test")

        self.perform_mapping(hostmap)
        self.assertEquals(len(hostmap.all_hostids()), 1)

        hostmap.clear_mappings()

        self.perform_mapping(hostmap)
        self.assertEquals(len(hostmap.all_hostids()), 0)
    def test_freeze_thaw_mappings(self):
        hostmap = HostMap()
        hostmap.add_hostref("test1")
        hostmap.add_hostref("test2")
        hostmap.add_hostref("test3")
        hostmap.assert_host_id("test2", "host-test2-forcedid")
        self.perform_mapping(hostmap)
        self.assertEquals(len(hostmap.all_hostids()), 3)

        frozen = hostmap.freeze_mappings()

        hostmap.clear_mappings()
        hostmap.thaw_mappings(frozen)
        hostmap.add_hostref("test1")
        hostmap.add_hostref("test2")
        hostmap.add_hostref("test3")
        self.perform_mapping(hostmap)
        self.assertEquals(len(hostmap.all_hostids()), 3)

        self.assertEquals(hostmap.get_hostid("test1"), "host-test1")
        self.assertEquals(hostmap.get_hostid("test2"), "host-test2-forcedid")
        self.assertEquals(hostmap.get_hostid("test3"), "host-test3")
    def test_freeze_thaw_mappings(self):
        hostmap = HostMap()
        hostmap.add_hostref("test1")
        hostmap.add_hostref("test2")
        hostmap.add_hostref("test3")
        hostmap.assert_host_id("test2", "host-test2-forcedid")
        self.perform_mapping(hostmap)
        self.assertEquals(len(hostmap.all_hostids()), 3)

        frozen = hostmap.freeze_mappings()

        hostmap.clear_mappings()
        hostmap.thaw_mappings(frozen)
        hostmap.add_hostref("test1")
        hostmap.add_hostref("test2")
        hostmap.add_hostref("test3")
        self.perform_mapping(hostmap)
        self.assertEquals(len(hostmap.all_hostids()), 3)

        self.assertEquals(hostmap.get_hostid("test1"), "host-test1")
        self.assertEquals(hostmap.get_hostid("test2"), "host-test2-forcedid")
        self.assertEquals(hostmap.get_hostid("test3"), "host-test3")