def test_get_si_server_image_stored_on(self): """ Tests for the get_si_server_image_stored_on() function. """ class5 = ServerClass("Class 5", num_cpus=1, cores_per_cpu=4, ram_size=4096, disk_size=138) server3 = Class5Server("pgi3.lindenlab.com") server4 = Class5Server("pgi4.lindenlab.com") image3 = PGIImage("pgi-image3") image4 = PGIImage("pgi-image4") self.assertEquals(server3.get_stored_pgi_images(), []) self.assertEquals(server4.get_stored_pgi_images(), []) server3.add_stored_pgi_image(image3) self.assertEquals(server3.get_stored_pgi_images(), [image3]) self.assertEquals(image3.get_si_servers_stored_on(), [server3]) server3.add_stored_pgi_image(image4) self.assertEquals(server3.get_stored_pgi_images(), [image3, image4]) server4.add_stored_pgi_image(image3) self.assertEquals(image3.get_si_servers_stored_on(), [server3, server4]) server3.delete_stored_pgi_image(image3) self.assertEquals(image3.get_si_servers_stored_on(), [server4])
def data(self): llclusto.drivers.HostState('up') class5 = ServerClass("Class 5", num_cpus=1, cores_per_cpu=4, ram_size=4096, disk_size=138) self.server0 = Class5Server("pgi0.lindenlab.com") self.server1 = Class5Server("pgi1.lindenlab.com") self.image0 = PGIImage("pgi-image0") self.image1 = PGIImage("pgi-image1")
class PGIImageTests(testbase.ClustoTestBase): """ """ def data(self): llclusto.drivers.HostState('up') class5 = ServerClass("Class 5", num_cpus=1, cores_per_cpu=4, ram_size=4096, disk_size=138) self.server0 = Class5Server("pgi0.lindenlab.com") self.server1 = Class5Server("pgi1.lindenlab.com") self.image0 = PGIImage("pgi-image0") self.image1 = PGIImage("pgi-image1") def test_get_hosts_associated_with(self): """ Test for get_hosts_associated_with() function. """ self.assertEquals(self.image0.type, 'pgi_image') self.assertEquals(self.image1.type, 'pgi_image') self.assertEquals(self.server0.pgi_image, None) self.assertEquals(self.server1.pgi_image, None) self.server0.pgi_image = self.image0 self.server1.pgi_image = self.image1 self.assertEquals(self.server0.pgi_image, self.image0) self.assertEquals(self.server1.pgi_image, self.image1) self.assertEquals(self.image0.get_hosts_associated_with(), [self.server0]) self.assertEquals(self.image1.get_hosts_associated_with(), [self.server1]) self.server1.pgi_image = self.image0 self.assertEquals(sorted(self.image0.get_hosts_associated_with()), sorted([self.server0, self.server1])) self.assertEquals(self.image1.get_hosts_associated_with(), []) def test_get_si_server_image_stored_on(self): """ Tests for the get_si_server_image_stored_on() function. """ self.assertEquals(self.server0.get_stored_pgi_images(), []) self.assertEquals(self.server1.get_stored_pgi_images(), []) self.server0.add_stored_pgi_image(self.image0) self.assertEquals(self.server0.get_stored_pgi_images(), [self.image0]) self.assertEquals(self.image0.get_si_servers_stored_on(), [self.server0]) self.server0.add_stored_pgi_image(self.image1) self.assertEquals(self.server0.get_stored_pgi_images(), [self.image0, self.image1]) self.server1.add_stored_pgi_image(self.image0) self.assertEquals(self.image0.get_si_servers_stored_on(), [self.server0, self.server1]) self.server0.delete_stored_pgi_image(self.image0) self.assertEquals(self.image0.get_si_servers_stored_on(), [self.server1])
def test_get_image_association(self): """ Test for get_image_association() fucntion. """ class5 = ServerClass("Class 5", num_cpus=1, cores_per_cpu=4, ram_size=4096, disk_size=138) server0 = Class5Server("pgi0.lindenlab.com") server1 = Class5Server("pgi1.lindenlab.com") image0 = PGIImage("pgi-image0") image1 = PGIImage("pgi-image1") self.assertEquals(image0.type, 'pgi_image') self.assertEquals(image1.type, 'pgi_image') self.assertEquals(server0.pgi_image, None) self.assertEquals(server1.pgi_image, None) server0.pgi_image = image0 server1.pgi_image = image1 self.assertEquals(server0.pgi_image, image0) self.assertEquals(server1.pgi_image, image1) self.assertEquals(type(image0.get_hosts_associated_with()), list) self.assertEquals(image0.get_hosts_associated_with(), [server0]) self.assertEquals(image1.get_hosts_associated_with(), [server1]) server1.pgi_image = image0 self.assertEquals(image0.get_hosts_associated_with(), [server0, server1]) self.assertEquals(image1.get_hosts_associated_with(), []) server0.pgi_image = image1 server1.pgi_image = image0 self.assertEquals(server0.pgi_image, image1) self.assertEquals(server1.pgi_image, image0)