def test_check_add_flavor(self): """Check if flavors are added and modified correctly""" for flavor_id, flavor in OPENSTACK_FLAVOR.items(): self.cmd._add_flavor(flavor, flavor_id) ralph_flavor = CloudFlavor.objects.get(flavor_id=flavor_id) self.assertEqual(ralph_flavor.name, flavor['name']) self.assertEqual(ralph_flavor.cloudprovider, self.cloud_provider) self.assertIn(flavor['tag'], ralph_flavor.tags.names()) self.assertEqual(flavor['cores'], ralph_flavor.cores) self.assertEqual(flavor['memory'], ralph_flavor.memory) self.assertEqual(flavor['disk'], ralph_flavor.disk)
def test_check_complete(self): """Check the whole run of the script""" self.cmd._update_ralph() self.cmd._cleanup() # Objects add/modification for flavor_id, flavor in OPENSTACK_FLAVOR.items(): ralph_flavor = CloudFlavor.objects.get(flavor_id=flavor_id) self.assertEqual(ralph_flavor.name, flavor['name']) self.assertEqual(ralph_flavor.cloudprovider, self.cloud_provider) for project_id, project in OPENSTACK_DATA.items(): ralph_project = CloudProject.objects.get(project_id=project_id) self.assertEqual(project['name'], ralph_project.name) self.assertEqual(self.cloud_provider, ralph_project.cloudprovider) for host_id, host in OPENSTACK_DATA[project_id]['servers'].items(): ralph_host = CloudHost.objects.get(host_id=host_id) ips = ralph_host.ip_addresses self.assertEqual(ralph_host.hostname, host['hostname']) self.assertIn(host['tag'], ralph_host.tags.names()) self.assertEqual(set(host['ips']), set(ips)) # projects removal for project_id in ['project_id2', 'project_id3']: self.assertRaises( ObjectDoesNotExist, CloudProject.objects.get, project_id=project_id, ) self.assertRaises( ObjectDoesNotExist, CloudFlavor.objects.get, flavor_id='flavor_id2', ) self.assertRaises( ObjectDoesNotExist, CloudHost.objects.get, host_id='host_id1', )