def test_mark_deleted_servers_no_old(self): """ If old list does not have any servers then it just returns new list """ new = [{'id': 'd', 'd': 3}, {'id': 'b', 'b': 4}] self.assertEqual( self.freeze(mark_deleted_servers([], new)), self.freeze(new))
def test_updated_deleted_servers_no_new(self): """ If new list does not have any servers then old list is updated as DELETED and returned """ old = [{"id": "d", "d": 3}, {"id": "b", "b": 4}] exp_old = deepcopy(old) exp_old[0]["status"] = "DELETED" exp_old[1]["status"] = "DELETED" self.assertEqual(self.freeze(mark_deleted_servers(old, [])), self.freeze(exp_old))
def test_mark_deleted_servers_precedence(self): """ In :func:`mark_deleted_servers`, if old list has common servers with new list, the new one takes precedence """ old = [{"id": "a", "a": 1}, {"id": "b", "b": 2}] new = [{"id": "d", "d": 3}, {"id": "b", "b": 4}] old_server = deepcopy(old[0]) old_server["status"] = "DELETED" self.assertEqual(self.freeze(mark_deleted_servers(old, new)), self.freeze([old_server] + new))
def test_updated_deleted_servers_no_new(self): """ If new list does not have any servers then old list is updated as DELETED and returned """ old = [{'id': 'd', 'd': 3}, {'id': 'b', 'b': 4}] exp_old = deepcopy(old) exp_old[0]["status"] = "DELETED" exp_old[1]["status"] = "DELETED" self.assertEqual(self.freeze(mark_deleted_servers(old, [])), self.freeze(exp_old))
def test_mark_deleted_servers_precedence(self): """ In :func:`mark_deleted_servers`, if old list has common servers with new list, the new one takes precedence """ old = [{'id': 'a', 'a': 1}, {'id': 'b', 'b': 2}] new = [{'id': 'd', 'd': 3}, {'id': 'b', 'b': 4}] old_server = deepcopy(old[0]) old_server["status"] = "DELETED" self.assertEqual(self.freeze(mark_deleted_servers(old, new)), self.freeze([old_server] + new))
def test_mark_deleted_servers_precedence(self): """ In :func:`mark_deleted_servers`, if old list has common servers with new list, the new one takes precedence """ old = [{'id': 'a', 'a': 1}, {'id': 'b', 'b': 2}] new = [{'id': 'd', 'd': 3}, {'id': 'b', 'b': 4}] old_server = deepcopy(old[0]) old_server["status"] = "DELETED" self.assertEqual( self.freeze(mark_deleted_servers(old, new)), self.freeze([old_server] + new))
def test_mark_deleted_servers_no_old(self): """ If old list does not have any servers then it just returns new list """ new = [{"id": "d", "d": 3}, {"id": "b", "b": 4}] self.assertEqual(self.freeze(mark_deleted_servers([], new)), self.freeze(new))