def setUpClass(cls): """Makes default values""" cls._mount_points = [MountPoint(name='C:\\', size=42)] cls._credentials = Credentials( user_name='User', password='******', domain='xxx.com' ) cls._test_workload = Workload( id=None, ip='111.11.11', credentials=cls._credentials, storage=cls._mount_points ) cls._test_migration_target = MigrationTarget( cloud_type=CloudType.VSPHERE, cloud_credentials=cls._credentials, target_vm=cls._test_workload ) cls._test_migration = Migration( mount_points=cls._mount_points, source=cls._test_workload, migration_target=cls._test_migration_target, migration_state=MigrationState.NOT_STARTED ) cls.results_mock = CollectionResults()
def test_invalid_migrationtarget(self): """Test create the migration model with invalid type of migration target""" with self.assertRaises(Exception): Migration(mount_points=self._mount_points, source=self._test_workload, migration_target=111, migration_state=MigrationState.RUNNING)
def get_migration(self, source_workload: Workload, target_workload: Workload) -> Migration: target = self.migration_target.get_target(target_workload) return Migration(id=self.id, mount_points=self.mount_points, source=source_workload, migration_target=target, migration_state=self.state)
def test_run_migration_which_is_in_running_state(self): """ Test run the migration which is already in running state""" test_migration = Migration( mount_points=self._mount_points, source=self._test_workload, migration_target=self._test_migration_target, migration_state=MigrationState.RUNNING) with self.assertRaises(Exception): test_migration.run()
def test_run_migration_without_c(self): """ Test migration without main mount point (C:\\ drive in this case)""" self._mount_points[0].name = 'D:\\' test_migration = Migration( mount_points=self._mount_points, source=self._test_workload, migration_target=self._test_migration_target, migration_state=MigrationState.NOT_STARTED) with self.assertRaises(Exception): test_migration.run()
def test_valid_migration(self): """Test general properties of the migration model""" test_migration = Migration( mount_points=self._mount_points, source=self._test_workload, migration_target=self._test_migration_target, migration_state=MigrationState.NOT_STARTED) self.assertEqual(test_migration.mount_points, self._mount_points) self.assertEqual(test_migration.source, self._test_workload) self.assertEqual(test_migration.migration_target, self._test_migration_target) self.assertEqual(test_migration.migration_state, MigrationState.NOT_STARTED)