Ejemplo n.º 1
0
    def test_index_serialization(self):
        migrations_out = migrations.output(migrations_obj)
        res_xml = self.serializer.serialize({'migrations': migrations_out})

        tree = etree.XML(res_xml)
        children = tree.findall('migration')
        self.assertEqual(tree.tag, 'migrations')
        self.assertEqual(2, len(children))

        for idx, child in enumerate(children):
            self.assertEqual(child.tag, 'migration')
            migration = migrations_out[idx]
            for attr in migration.keys():
                self.assertEqual(str(migration[attr]), child.get(attr))
Ejemplo n.º 2
0
    def test_index_serialization(self):
        migrations_out = migrations.output(migrations_obj)
        res_xml = self.serializer.serialize(
            {'migrations': migrations_out})

        tree = etree.XML(res_xml)
        children = tree.findall('migration')
        self.assertEqual(tree.tag, 'migrations')
        self.assertEqual(2, len(children))

        for idx, child in enumerate(children):
            self.assertEqual(child.tag, 'migration')
            migration = migrations_out[idx]
            for attr in migration.keys():
                self.assertEqual(str(migration[attr]),
                                 child.get(attr))
Ejemplo n.º 3
0
    def test_index(self):
        migrations_in_progress = {
            'migrations': migrations.output(migrations_obj)}

        for mig in migrations_in_progress['migrations']:
            self.assertTrue('id' in mig)
            self.assertTrue('deleted' not in mig)
            self.assertTrue('deleted_at' not in mig)

        filters = {'host': 'host1', 'status': 'migrating',
                   'cell_name': 'ChildCell'}
        self.req.GET = filters
        self.mox.StubOutWithMock(self.controller.compute_api,
                                 "get_migrations")

        self.controller.compute_api.get_migrations(
            self.context, filters).AndReturn(migrations_obj)
        self.mox.ReplayAll()

        response = self.controller.index(self.req)
        self.assertEqual(migrations_in_progress, response)