def test_create_migration_create_a_migration_with_all_stages(self): # given m = migration.Migration() data = {"migration": {"name": "myMigrationTest", "os": "linux"}} target_format = self.create_targetFormat("nameTargetFormat") cred_account = uforge.CredAccountVSphere() install_profile = uforge.InstallProfile() image = uforge.Image() image.installProfile = install_profile publish_image = uforge.PublishImageVSphere() publish_image.credAccount = cred_account # when my_migration = m.create_migration(data["migration"]["name"], data["migration"]["os"], target_format.name, image, publish_image) # then self.assertEqual(my_migration.name, "myMigrationTest") self.assertEqual(my_migration.stages.stage[0].family, data["migration"]["os"]) self.assertEqual(my_migration.stages.stage[1].image.targetFormat.name, target_format.name) self.assertEqual(my_migration.stages.stage[1].image.installProfile, install_profile) self.assertEqual( my_migration.stages.stage[2].publishImage.targetFormat.name, target_format.name) self.assertEqual(my_migration.stages.stage[2].publishImage.credAccount, cred_account)
def test_set_install_profile_disk_size_set_disk_size_when_format_aws(self): # given install_profile = uforge.InstallProfile() install_profile.diskSize = 0 builder = {"installation": {"diskSize": 12}} # when install_profile = migration_utils.set_install_profile_disk_size( install_profile, builder, "aws") # then self.assertEqual(install_profile.diskSize, 12)
def test_check_mandatory_installation_raise_exception_when_no_installation_for_format_aws(self): # given install_profile = uforge.InstallProfile() install_profile.diskSize = 0 builder = { "type": "Amazon AWS" } # when with self.assertRaises(Exception) as e: migration_utils.check_mandatory_installation("aws", builder) # then self.assertTrue("check yours parameters in file, no attribute [installation] for [migration][target][builder], mandatory to migrate to [Amazon AWS]" in e.exception)
def test_set_install_profile_disk_size_raise_exception_when_no_diskSize(self): # given install_profile = uforge.InstallProfile() install_profile.diskSize = 0 builder = { "type": "Amazon AWS", "installation": {} } # when with self.assertRaises(Exception) as e: migration_utils.set_install_profile_disk_size(install_profile, builder, "aws") # then self.assertTrue("check yours parameters in file, no attribute [disksize] for [migration][target][builder][installation], mandatory to migrate to [Amazon AWS]" in e.exception)