Exemple #1
0
    def test_do_launch_succeed_when_all_parameters_are_ok(self, mock_rmtree, mock_out, mock_api_create, mock_upload_and_launch_migration_binary, mock_create_migration, mock_retrieve_account, mock_build_publish_image, mock_retrieve_image, mock_retrieve_target_format, mock_retrieve_migration_configuration, mock_download_binary):
        # given
        m = migration.Migration()
        m.api = Api("url", username="******", password="******", headers=None,
                    disable_ssl_certificate_validation=False, timeout=constants.HTTP_TIMEOUT)
        m.login = "******"
        m.password = "******"

        mock_retrieve_migration_configuration.return_value = self.get_migration_config()
        mock_retrieve_target_format.return_value = self.create_targetFormat("targetFormatRetrieved")
        mock_retrieve_image.return_value = uforge.Image()
        mock_build_publish_image.return_value = uforge.PublishImageVSphere()
        mock_retrieve_account.return_value = uforge.CredAccountVSphere()
        migration_to_create = uforge.migration()
        mock_create_migration.return_value = migration_to_create
        mock_upload_and_launch_migration_binary.return_value(0)

        # when
        m.do_launch("--file config.json")

        # then
        self.assertEquals(mock_api_create.call_count, 1)
        self.assertEquals(mock_download_binary.call_count, 1)
        self.assertEquals(mock_upload_and_launch_migration_binary.call_count, 1)
        self.assertEquals(mock_rmtree.call_count, 1)
        mock_out.assert_called_with("Migration launched successfully, please go to the platform to follow steps of the migration.", "OK")
Exemple #2
0
    def test_do_launch_succeed_when_all_parameters_are_ok(self, mock_rmtree, mock_out, mock_api_create, mock_upload_and_launch_migration_binary, mock_create_migration, mock_retrieve_account, mock_retrieve_publish_image, mock_retrieve_image, mock_retrieve_target_format, mock_retrieve_migration_configuration, mock_download_binary):
        # given
        m = migration.Migration()
        m.api = Api("url", username="******", password="******", headers=None,
                    disable_ssl_certificate_validation=False, timeout=constants.HTTP_TIMEOUT)
        m.login = "******"
        m.password = "******"

        mock_retrieve_migration_configuration.return_value = self.get_migration_config()
        mock_retrieve_target_format.return_value = self.create_targetFormat("targetFormatRetrieved")
        mock_retrieve_image.return_value = uforge.Image()
        mock_retrieve_publish_image.return_value = uforge.PublishImageVSphere()
        mock_retrieve_account.return_value = uforge.CredAccountVSphere()
        migration_to_create = uforge.migration()
        mock_create_migration.return_value = migration_to_create
        mock_upload_and_launch_migration_binary.return_value(0)

        # when
        m.do_launch("--file config.json")

        # then
        self.assertEquals(mock_api_create.call_count, 1)
        self.assertEquals(mock_download_binary.call_count, 1)
        self.assertEquals(mock_upload_and_launch_migration_binary.call_count, 1)
        self.assertEquals(mock_rmtree.call_count, 1)
        mock_out.assert_called_with("Migration launched successfully, please go to the platform to follow steps of the migration.", "OK")
    def create_migration(self, id, name, percentage, statusMessage, complete, error, cancelled):
        newMigration = uforge.migration()
        newMigration.dbId = id
        newMigration.name = name

        status = uforge.status()
        status.message = statusMessage
        status.percentage = percentage
        status.complete = complete
        status.error = error
        status.cancelled = cancelled

        newMigration.status = status
        return newMigration