mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-26 06:40:30 -04:00
Initial Code Layering (#3788)
* working on formatting * fixed basic lint errors; starting moving things to their appropriate location * formatting * update tslint to match the version of vscode we have * remove unused code * work in progress fixing layering * formatting * moved connection management service to platform * formatting * add missing file * moving more servies * formatting * moving more services * formatting * wip * moving more services * formatting * revert back tslint rules * move css file * add missing svgs
This commit is contained in:
@@ -9,9 +9,9 @@ import * as assert from 'assert';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { EventVerifierSingle } from 'sqltest/utils/eventVerifier';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { AccountPicker } from 'sql/parts/accountManagement/accountPicker/accountPicker';
|
||||
import { AccountPickerService } from 'sql/parts/accountManagement/accountPicker/accountPickerService';
|
||||
import { AccountPickerViewModel } from 'sql/parts/accountManagement/accountPicker/accountPickerViewModel';
|
||||
import { AccountPicker } from 'sql/platform/accountManagement/browser/accountPicker';
|
||||
import { AccountPickerService } from 'sql/platform/accountManagement/browser/accountPickerService';
|
||||
import { AccountPickerViewModel } from 'sql/platform/accountManagement/common/accountPickerViewModel';
|
||||
import { AccountManagementTestService } from 'sqltest/stubs/accountManagementStubs';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import * as assert from 'assert';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { EventVerifierSingle } from 'sqltest/utils/eventVerifier';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { AccountPickerViewModel } from 'sql/parts/accountManagement/accountPicker/accountPickerViewModel';
|
||||
import { UpdateAccountListEventParams } from 'sql/services/accountManagement/eventTypes';
|
||||
import { AccountPickerViewModel } from 'sql/platform/accountManagement/common/accountPickerViewModel';
|
||||
import { UpdateAccountListEventParams } from 'sql/platform/accountManagement/common/eventTypes';
|
||||
import { AccountManagementTestService } from 'sqltest/stubs/accountManagementStubs';
|
||||
|
||||
// SUITE STATE /////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -11,7 +11,7 @@ import * as TypeMoq from 'typemoq';
|
||||
import { EventVerifierSingle } from 'sqltest/utils/eventVerifier';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { AccountViewModel } from 'sql/parts/accountManagement/accountDialog/accountViewModel';
|
||||
import { AccountProviderAddedEventParams, UpdateAccountListEventParams } from 'sql/services/accountManagement/eventTypes';
|
||||
import { AccountProviderAddedEventParams, UpdateAccountListEventParams } from 'sql/platform/accountManagement/common/eventTypes';
|
||||
import { AccountManagementTestService } from 'sqltest/stubs/accountManagementStubs';
|
||||
|
||||
// SUITE STATE /////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { FirewallRuleDialog } from 'sql/parts/accountManagement/firewallRuleDialog/firewallRuleDialog';
|
||||
import { FirewallRuleViewModel } from 'sql/parts/accountManagement/firewallRuleDialog/firewallRuleViewModel';
|
||||
import { FirewallRuleDialogController } from 'sql/parts/accountManagement/firewallRuleDialog/firewallRuleDialogController';
|
||||
|
||||
@@ -5,18 +5,14 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
|
||||
import { AdminService } from 'sql/parts/admin/common/adminService';
|
||||
import { AdminService } from 'sql/workbench/services/admin/common/adminService';
|
||||
|
||||
suite('SQL AdminService tests', () => {
|
||||
|
||||
let adminService: AdminService;
|
||||
setup(() => {
|
||||
adminService = new AdminService(
|
||||
undefined, undefined, undefined, undefined
|
||||
undefined, undefined, undefined
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -4,33 +4,24 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import * as Constants from 'sql/parts/connection/common/constants';
|
||||
import * as Utils from 'sql/parts/connection/common/utils';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import * as sqlops from 'sqlops';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as assert from 'assert';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { CommandLineService } from 'sql/parts/commandLine/common/commandLineService';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { CommandLineService } from 'sql/workbench/services/commandLine/common/commandLineService';
|
||||
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||
import { CapabilitiesService, ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
||||
import { QueryEditorService } from 'sql/parts/query/services/queryEditorService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ObjectExplorerService } from 'sql/parts/objectExplorer/common/objectExplorerService';
|
||||
import {
|
||||
IConnectionManagementService, IConnectionDialogService, INewConnectionParams,
|
||||
ConnectionType, IConnectableInput, IConnectionCompletionOptions, IConnectionCallbacks,
|
||||
IConnectionParams, IConnectionResult, IServerGroupController, IServerGroupDialogCallbacks,
|
||||
RunQueryOnConnectionMode
|
||||
} from 'sql/parts/connection/common/connectionManagement';
|
||||
import { ConnectionStore } from 'sql/parts/connection/common/connectionStore';
|
||||
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionStore } from 'sql/platform/connection/common/connectionStore';
|
||||
import { TestConnectionManagementService } from 'sqltest/stubs/connectionManagementService.test';
|
||||
import { ICommandService, ICommandEvent, CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { TestCommandService } from 'vs/editor/test/browser/editorTestServices';
|
||||
import { WorkspaceConfigurationTestService } from 'sqltest/stubs/workspaceConfigurationTestService';
|
||||
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
|
||||
@@ -120,8 +111,8 @@ suite('commandLineService tests', () => {
|
||||
commandService?: ICommandService
|
||||
): CommandLineService {
|
||||
let service = new CommandLineService(
|
||||
connectionManagementService,
|
||||
capabilitiesService,
|
||||
connectionManagementService,
|
||||
environmentService,
|
||||
undefined,
|
||||
undefined,
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
|
||||
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { ConnectionConfig, ISaveGroupResult } from 'sql/parts/connection/common/connectionConfig';
|
||||
import { IConnectionProfile, IConnectionProfileStore } from 'sql/parts/connection/common/interfaces';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { ConnectionConfig, ISaveGroupResult } from 'sql/platform/connection/common/connectionConfig';
|
||||
import { IConnectionProfile, IConnectionProfileStore } from 'sql/platform/connection/common/interfaces';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { WorkspaceConfigurationTestService } from 'sqltest/stubs/workspaceConfigurationTestService';
|
||||
import { IConfigurationValue, ConfigurationEditingService } from 'vs/workbench/services/configuration/node/configurationEditingService';
|
||||
import * as Constants from 'sql/parts/connection/common/constants';
|
||||
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as assert from 'assert';
|
||||
import { ProviderFeatures, ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import { ProviderFeatures, ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import * as sqlops from 'sqlops';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
import { ConnectionDialogService } from 'sql/parts/connection/connectionDialog/connectionDialogService';
|
||||
import { ConnectionDialogWidget } from 'sql/parts/connection/connectionDialog/connectionDialogWidget';
|
||||
import { ConnectionManagementService } from 'sql/parts/connection/common/connectionManagementService';
|
||||
import { ConnectionType, IConnectableInput, IConnectionResult, INewConnectionParams } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { ConnectionManagementService } from 'sql/platform/connection/common/connectionManagementService';
|
||||
import { ConnectionType, IConnectableInput, IConnectionResult, INewConnectionParams } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ContextKeyServiceStub } from 'sqltest/stubs/contextKeyServiceStub';
|
||||
import { ErrorMessageServiceStub } from 'sqltest/stubs/errorMessageServiceStub';
|
||||
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
'use strict';
|
||||
|
||||
import { ConnectionDialogTestService } from 'sqltest/stubs/connectionDialogTestService';
|
||||
import { ConnectionManagementService } from 'sql/parts/connection/common/connectionManagementService';
|
||||
import { ConnectionStatusManager } from 'sql/parts/connection/common/connectionStatusManager';
|
||||
import { ConnectionStore } from 'sql/parts/connection/common/connectionStore';
|
||||
import { ConnectionManagementService } from 'sql/platform/connection/common/connectionManagementService';
|
||||
import { ConnectionStatusManager } from 'sql/platform/connection/common/connectionStatusManager';
|
||||
import { ConnectionStore } from 'sql/platform/connection/common/connectionStore';
|
||||
import {
|
||||
INewConnectionParams, ConnectionType,
|
||||
IConnectionCompletionOptions, IConnectionResult,
|
||||
RunQueryOnConnectionMode
|
||||
} from 'sql/parts/connection/common/connectionManagement';
|
||||
import * as Constants from 'sql/parts/connection/common/constants';
|
||||
import * as Utils from 'sql/parts/connection/common/utils';
|
||||
import { IHandleFirewallRuleResult } from 'sql/parts/accountManagement/common/interfaces';
|
||||
} from 'sql/platform/connection/common/connectionManagement';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import * as Utils from 'sql/platform/connection/common/utils';
|
||||
import { IHandleFirewallRuleResult } from 'sql/workbench/services/resourceProvider/common/resourceProviderService';
|
||||
|
||||
import { WorkbenchEditorTestService } from 'sqltest/stubs/workbenchEditorTestService';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { EditorGroupTestService } from 'sqltest/stubs/editorGroupService';
|
||||
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
||||
import { ConnectionProviderStub } from 'sqltest/stubs/connectionProviderStub';
|
||||
@@ -32,8 +32,8 @@ import { WorkspaceConfigurationTestService } from 'sqltest/stubs/workspaceConfig
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { AccountManagementTestService } from 'sqltest/stubs/accountManagementStubs';
|
||||
|
||||
suite('SQL ConnectionManagementService tests', () => {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { IConnectionProfile, IConnectionProfileStore } from 'sql/parts/connection/common/interfaces';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { IConnectionProfile, IConnectionProfileStore } from 'sql/platform/connection/common/interfaces';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as assert from 'assert';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
import { ConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
||||
import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import * as assert from 'assert';
|
||||
|
||||
suite('SQL ConnectionProfileGroup tests', () => {
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as sqlops from 'sqlops';
|
||||
import { ConnectionStatusManager } from 'sql/parts/connection/common/connectionStatusManager';
|
||||
import * as Utils from 'sql/parts/connection/common/utils';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { ConnectionStatusManager } from 'sql/platform/connection/common/connectionStatusManager';
|
||||
import * as Utils from 'sql/platform/connection/common/utils';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
|
||||
let connections: ConnectionStatusManager;
|
||||
let capabilitiesService: CapabilitiesTestService;
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
'use strict';
|
||||
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { ConnectionConfig } from 'sql/parts/connection/common/connectionConfig';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { ConnectionConfig } from 'sql/platform/connection/common/connectionConfig';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { WorkspaceConfigurationTestService } from 'sqltest/stubs/workspaceConfigurationTestService';
|
||||
import * as Constants from 'sql/parts/connection/common/constants';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import { StorageTestService } from 'sqltest/stubs/storageTestService';
|
||||
import { ConnectionStore } from 'sql/parts/connection/common/connectionStore';
|
||||
import { CredentialsService } from 'sql/services/credentials/credentialsService';
|
||||
import { ConnectionStore } from 'sql/platform/connection/common/connectionStore';
|
||||
import { CredentialsService } from 'sql/platform/credentials/common/credentialsService';
|
||||
import * as assert from 'assert';
|
||||
import { Memento } from 'vs/workbench/common/memento';
|
||||
import { CapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import { CapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import * as sqlops from 'sqlops';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { ConnectionProfileGroup, IConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
||||
import { ConnectionProfileGroup, IConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { CapabilitiesTestService } from '../../stubs/capabilitiesTestService';
|
||||
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import * as assert from 'assert';
|
||||
import { ConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import {
|
||||
RefreshAction, AddServerAction, DeleteConnectionAction, DisconnectConnectionAction,
|
||||
ActiveConnectionsFilterAction, RecentConnectionsFilterAction
|
||||
@@ -19,7 +19,7 @@ import { TestConnectionManagementService } from 'sqltest/stubs/connectionManagem
|
||||
import { ErrorMessageServiceStub } from 'sqltest/stubs/errorMessageServiceStub';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { ServerTreeView } from 'sql/parts/objectExplorer/viewlet/serverTreeView';
|
||||
import * as Constants from 'sql/parts/connection/common/constants';
|
||||
import * as Constants from 'sql/platform/connection/common/constants';
|
||||
import * as LocalizedConstants from 'sql/parts/connection/common/localizedConstants';
|
||||
import { ObjectExplorerService, ObjectExplorerNodeEventArgs } from 'sql/parts/objectExplorer/common/objectExplorerService';
|
||||
import { TreeNode } from 'sql/parts/objectExplorer/common/treeNode';
|
||||
@@ -31,7 +31,7 @@ import WinJS = require('vs/base/common/winjs.base');
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { ObjectExplorerActionsContext, ManageConnectionAction } from 'sql/parts/objectExplorer/viewlet/objectExplorerActions';
|
||||
import { IConnectionResult, IConnectionParams } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { IConnectionResult, IConnectionParams } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { TreeSelectionHandler } from 'sql/parts/objectExplorer/viewlet/treeSelectionHandler';
|
||||
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
'use strict';
|
||||
import { ObjectExplorerProviderTestService } from 'sqltest/stubs/objectExplorerProviderTestService';
|
||||
import { TestConnectionManagementService } from 'sqltest/stubs/connectionManagementService.test';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { ConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import { ObjectExplorerService } from 'sql/parts/objectExplorer/common/objectExplorerService';
|
||||
import { NodeType } from 'sql/parts/objectExplorer/common/nodeType';
|
||||
import { TreeNode, TreeItemCollapsibleState, ObjectExplorerCallbacks } from 'sql/parts/objectExplorer/common/treeNode';
|
||||
@@ -19,7 +19,7 @@ import * as assert from 'assert';
|
||||
import { ServerTreeView } from 'sql/parts/objectExplorer/viewlet/serverTreeView';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { CapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import { CapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
||||
|
||||
suite('SQL Object Explorer Service tests', () => {
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
import { ProviderConnectionInfo } from 'sql/parts/connection/common/providerConnectionInfo';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { ProviderConnectionInfo } from 'sql/platform/connection/common/providerConnectionInfo';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as assert from 'assert';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService';
|
||||
|
||||
suite('SQL ProviderConnectionInfo tests', () => {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ObjectMetadataWrapper } from 'sql/parts/dashboard/widgets/explorer/explorerTree';
|
||||
import { MetadataType } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { MetadataType } from 'sql/platform/connection/common/connectionManagement';
|
||||
|
||||
import * as assert from 'assert';
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import { WidgetConfig } from 'sql/parts/dashboard/common/dashboardWidget';
|
||||
import { DashboardServiceInterface } from 'sql/parts/dashboard/services/dashboardServiceInterface.service';
|
||||
import { SingleAdminService, SingleConnectionManagementService } from 'sql/services/common/commonServiceInterface.service';
|
||||
import { PropertiesWidgetComponent } from 'sql/parts/dashboard/widgets/properties/propertiesWidget.component';
|
||||
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
|
||||
import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo';
|
||||
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import * as assert from 'assert';
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
import { InsightsDialogController } from 'sql/parts/insights/node/insightsDialogController';
|
||||
import { InsightsDialogModel } from 'sql/parts/insights/common/insightsDialogModel';
|
||||
import QueryRunner, { EventType } from 'sql/parts/query/execution/queryRunner';
|
||||
import { ConnectionManagementService } from 'sql/parts/connection/common/connectionManagementService';
|
||||
import QueryRunner, { EventType } from 'sql/platform/query/common/queryRunner';
|
||||
import { ConnectionManagementService } from 'sql/platform/connection/common/connectionManagementService';
|
||||
import { IInsightsConfigDetails } from 'sql/parts/dashboard/widgets/insights/interfaces';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as assert from 'assert';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { JobManagementService } from 'sql/parts/jobManagement/common/jobManagementService';
|
||||
import { JobManagementService } from 'sql/platform/jobManagement/common/jobManagementService';
|
||||
|
||||
// TESTS ///////////////////////////////////////////////////////////////////
|
||||
suite('Job Management service tests', () => {
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Mock, It, Times, MockBehavior } from 'typemoq';
|
||||
import { ComponentBase, ContainerBase, ItemDescriptor } from 'sql/parts/modelComponents/componentBase';
|
||||
import { IComponentDescriptor, IModelStore, ComponentEventType } from 'sql/parts/modelComponents/interfaces';
|
||||
import { ModelStore } from 'sql/parts/modelComponents/modelStore';
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
|
||||
'use strict';
|
||||
|
||||
class TestComponent extends ComponentBase {
|
||||
public descriptor: IComponentDescriptor;
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import TableComponent from 'sql/parts/modelComponents/table.component';
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import TableComponent from 'sql/parts/modelComponents/table.component';
|
||||
|
||||
suite('TableComponent Tests', () => {
|
||||
|
||||
|
||||
@@ -10,96 +10,96 @@ import { nb, IConnectionProfile } from 'sqlops';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { INotebookModel, ICellModel, IClientSession, IDefaultConnection, NotebookContentChange } from 'sql/parts/notebook/models/modelInterfaces';
|
||||
import { NotebookChangeType, CellType } from 'sql/parts/notebook/models/contracts';
|
||||
import { INotebookManager } from 'sql/services/notebook/notebookService';
|
||||
import { INotebookManager } from 'sql/workbench/services/notebook/common/notebookService';
|
||||
import { ISingleNotebookEditOperation } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
export class NotebookModelStub implements INotebookModel {
|
||||
constructor(private _languageInfo?: nb.ILanguageInfo) {
|
||||
}
|
||||
public trustedMode: boolean;
|
||||
constructor(private _languageInfo?: nb.ILanguageInfo) {
|
||||
}
|
||||
public trustedMode: boolean;
|
||||
|
||||
public get languageInfo(): nb.ILanguageInfo {
|
||||
return this._languageInfo;
|
||||
}
|
||||
onCellChange(cell: ICellModel, change: NotebookChangeType): void {
|
||||
// Default: do nothing
|
||||
}
|
||||
get cells(): ReadonlyArray<ICellModel> {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get clientSession(): IClientSession {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get notebookManagers(): INotebookManager[] {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get kernelChanged(): Event<nb.IKernelChangedArgs> {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get kernelsChanged(): Event<nb.IKernelSpec> {
|
||||
throw new Error('method not implemented.');
|
||||
} get defaultKernel(): nb.IKernelSpec {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get contextsChanged(): Event<void> {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get contentChanged(): Event<NotebookContentChange> {
|
||||
public get languageInfo(): nb.ILanguageInfo {
|
||||
return this._languageInfo;
|
||||
}
|
||||
onCellChange(cell: ICellModel, change: NotebookChangeType): void {
|
||||
// Default: do nothing
|
||||
}
|
||||
get cells(): ReadonlyArray<ICellModel> {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get specs(): nb.IAllKernels {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get contexts(): IDefaultConnection {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get providerId(): string {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
changeKernel(displayName: string): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
changeContext(host: string, connection?: IConnectionProfile): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
findCellIndex(cellModel: ICellModel): number {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
addCell(cellType: CellType, index?: number): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
deleteCell(cellModel: ICellModel): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
saveModel(): Promise<boolean> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
pushEditOperations(edits: ISingleNotebookEditOperation[]): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
get clientSession(): IClientSession {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get notebookManagers(): INotebookManager[] {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get kernelChanged(): Event<nb.IKernelChangedArgs> {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get kernelsChanged(): Event<nb.IKernelSpec> {
|
||||
throw new Error('method not implemented.');
|
||||
} get defaultKernel(): nb.IKernelSpec {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get contextsChanged(): Event<void> {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get contentChanged(): Event<NotebookContentChange> {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get specs(): nb.IAllKernels {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get contexts(): IDefaultConnection {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
get providerId(): string {
|
||||
throw new Error('method not implemented.');
|
||||
}
|
||||
changeKernel(displayName: string): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
changeContext(host: string, connection?: IConnectionProfile): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
findCellIndex(cellModel: ICellModel): number {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
addCell(cellType: CellType, index?: number): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
deleteCell(cellModel: ICellModel): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
saveModel(): Promise<boolean> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
pushEditOperations(edits: ISingleNotebookEditOperation[]): void {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
}
|
||||
|
||||
export class NotebookManagerStub implements INotebookManager {
|
||||
providerId: string;
|
||||
contentManager: nb.ContentManager;
|
||||
sessionManager: nb.SessionManager;
|
||||
serverManager: nb.ServerManager;
|
||||
providerId: string;
|
||||
contentManager: nb.ContentManager;
|
||||
sessionManager: nb.SessionManager;
|
||||
serverManager: nb.ServerManager;
|
||||
}
|
||||
|
||||
export class ServerManagerStub implements nb.ServerManager {
|
||||
public onServerStartedEmitter = new Emitter<void>();
|
||||
onServerStarted: Event<void> = this.onServerStartedEmitter.event;
|
||||
isStarted: boolean = false;
|
||||
calledStart: boolean = false;
|
||||
calledEnd: boolean = false;
|
||||
public result: Promise<void> = undefined;
|
||||
public onServerStartedEmitter = new Emitter<void>();
|
||||
onServerStarted: Event<void> = this.onServerStartedEmitter.event;
|
||||
isStarted: boolean = false;
|
||||
calledStart: boolean = false;
|
||||
calledEnd: boolean = false;
|
||||
public result: Promise<void> = undefined;
|
||||
|
||||
startServer(): Promise<void> {
|
||||
this.calledStart = true;
|
||||
return this.result;
|
||||
}
|
||||
stopServer(): Promise<void> {
|
||||
this.calledEnd = true;
|
||||
return this.result;
|
||||
}
|
||||
startServer(): Promise<void> {
|
||||
this.calledStart = true;
|
||||
return this.result;
|
||||
}
|
||||
stopServer(): Promise<void> {
|
||||
this.calledEnd = true;
|
||||
return this.result;
|
||||
}
|
||||
}
|
||||
@@ -14,265 +14,265 @@ import * as objects from 'vs/base/common/objects';
|
||||
import { CellTypes } from 'sql/parts/notebook/models/contracts';
|
||||
import { ModelFactory } from 'sql/parts/notebook/models/modelFactory';
|
||||
import { NotebookModelStub } from '../common';
|
||||
import { EmptyFuture } from 'sql/services/notebook/sessionManager';
|
||||
import { EmptyFuture } from 'sql/workbench/services/notebook/common/sessionManager';
|
||||
import { ICellModel } from 'sql/parts/notebook/models/modelInterfaces';
|
||||
|
||||
describe('Cell Model', function (): void {
|
||||
let factory = new ModelFactory();
|
||||
it('Should set default values if none defined', async function (): Promise<void> {
|
||||
let cell = factory.createCell(undefined, undefined);
|
||||
should(cell.cellType).equal(CellTypes.Code);
|
||||
should(cell.source).equal('');
|
||||
});
|
||||
let factory = new ModelFactory();
|
||||
it('Should set default values if none defined', async function (): Promise<void> {
|
||||
let cell = factory.createCell(undefined, undefined);
|
||||
should(cell.cellType).equal(CellTypes.Code);
|
||||
should(cell.source).equal('');
|
||||
});
|
||||
|
||||
it('Should update values', async function (): Promise<void> {
|
||||
let cell = factory.createCell(undefined, undefined);
|
||||
cell.language = 'sql';
|
||||
should(cell.language).equal('sql');
|
||||
cell.source = 'abcd';
|
||||
should(cell.source).equal('abcd');
|
||||
});
|
||||
it('Should update values', async function (): Promise<void> {
|
||||
let cell = factory.createCell(undefined, undefined);
|
||||
cell.language = 'sql';
|
||||
should(cell.language).equal('sql');
|
||||
cell.source = 'abcd';
|
||||
should(cell.source).equal('abcd');
|
||||
});
|
||||
|
||||
it('Should match ICell values if defined', async function (): Promise<void> {
|
||||
let output: nb.IStreamResult = {
|
||||
output_type: 'stream',
|
||||
text: 'Some output',
|
||||
name: 'stdout'
|
||||
};
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Markdown,
|
||||
source: 'some *markdown*',
|
||||
outputs: [output],
|
||||
metadata: { language: 'python'},
|
||||
execution_count: 1
|
||||
};
|
||||
let cell = factory.createCell(cellData, undefined);
|
||||
should(cell.cellType).equal(cellData.cell_type);
|
||||
should(cell.source).equal(cellData.source);
|
||||
should(cell.outputs).have.length(1);
|
||||
should(cell.outputs[0].output_type).equal('stream');
|
||||
should((<nb.IStreamResult>cell.outputs[0]).text).equal('Some output');
|
||||
});
|
||||
it('Should match ICell values if defined', async function (): Promise<void> {
|
||||
let output: nb.IStreamResult = {
|
||||
output_type: 'stream',
|
||||
text: 'Some output',
|
||||
name: 'stdout'
|
||||
};
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Markdown,
|
||||
source: 'some *markdown*',
|
||||
outputs: [output],
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
};
|
||||
let cell = factory.createCell(cellData, undefined);
|
||||
should(cell.cellType).equal(cellData.cell_type);
|
||||
should(cell.source).equal(cellData.source);
|
||||
should(cell.outputs).have.length(1);
|
||||
should(cell.outputs[0].output_type).equal('stream');
|
||||
should((<nb.IStreamResult>cell.outputs[0]).text).equal('Some output');
|
||||
});
|
||||
|
||||
|
||||
it('Should set cell language to python if defined as python in languageInfo', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(\'1\')',
|
||||
metadata: { language: 'python'},
|
||||
execution_count: 1
|
||||
};
|
||||
it('Should set cell language to python if defined as python in languageInfo', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(\'1\')',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: 'python',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('python');
|
||||
});
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: 'python',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('python');
|
||||
});
|
||||
|
||||
it('Should set cell language to python if defined as pyspark in languageInfo', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(\'1\')',
|
||||
metadata: { language: 'python'},
|
||||
execution_count: 1
|
||||
};
|
||||
it('Should set cell language to python if defined as pyspark in languageInfo', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(\'1\')',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: 'pyspark',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('python');
|
||||
});
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: 'pyspark',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('python');
|
||||
});
|
||||
|
||||
it('Should set cell language to scala if defined as scala in languageInfo', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(\'1\')',
|
||||
metadata: { },
|
||||
execution_count: 1
|
||||
};
|
||||
it('Should set cell language to scala if defined as scala in languageInfo', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(\'1\')',
|
||||
metadata: {},
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: 'scala',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('scala');
|
||||
});
|
||||
it('Should keep cell language as python if cell has language override', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(\'1\')',
|
||||
metadata: { language: 'python'},
|
||||
execution_count: 1
|
||||
};
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: 'scala',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('scala');
|
||||
});
|
||||
it('Should keep cell language as python if cell has language override', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(\'1\')',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: 'scala',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('python');
|
||||
});
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: 'scala',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('python');
|
||||
});
|
||||
|
||||
it('Should set cell language to python if no language defined', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(\'1\')',
|
||||
metadata: { language: 'python'},
|
||||
execution_count: 1
|
||||
};
|
||||
it('Should set cell language to python if no language defined', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(\'1\')',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: '',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('python');
|
||||
});
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: '',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('python');
|
||||
});
|
||||
|
||||
it('Should match cell language to language specified if unknown language defined in languageInfo', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'std::cout << "hello world";',
|
||||
metadata: { },
|
||||
execution_count: 1
|
||||
};
|
||||
it('Should match cell language to language specified if unknown language defined in languageInfo', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'std::cout << "hello world";',
|
||||
metadata: {},
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: 'cplusplus',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('cplusplus');
|
||||
});
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: 'cplusplus',
|
||||
version: '',
|
||||
mimetype: ''
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('cplusplus');
|
||||
});
|
||||
|
||||
it('Should match cell language to mimetype name is not supplied in languageInfo', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(\'1\')',
|
||||
metadata: { },
|
||||
execution_count: 1
|
||||
};
|
||||
it('Should match cell language to mimetype name is not supplied in languageInfo', async function (): Promise<void> {
|
||||
let cellData: nb.ICellContents = {
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print(\'1\')',
|
||||
metadata: {},
|
||||
execution_count: 1
|
||||
};
|
||||
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: '',
|
||||
version: '',
|
||||
mimetype: 'x-scala'
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('scala');
|
||||
});
|
||||
let notebookModel = new NotebookModelStub({
|
||||
name: '',
|
||||
version: '',
|
||||
mimetype: 'x-scala'
|
||||
});
|
||||
let cell = factory.createCell(cellData, { notebook: notebookModel, isTrusted: false });
|
||||
should(cell.language).equal('scala');
|
||||
});
|
||||
|
||||
describe('Model Future handling', function(): void {
|
||||
let future: TypeMoq.Mock<EmptyFuture>;
|
||||
let cell: ICellModel;
|
||||
beforeEach(() => {
|
||||
future = TypeMoq.Mock.ofType(EmptyFuture);
|
||||
cell = factory.createCell({
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print "Hello"',
|
||||
metadata: { language: 'python'},
|
||||
execution_count: 1
|
||||
}, {
|
||||
notebook: new NotebookModelStub({
|
||||
name: '',
|
||||
version: '',
|
||||
mimetype: 'x-scala'
|
||||
}),
|
||||
isTrusted: false
|
||||
});
|
||||
});
|
||||
describe('Model Future handling', function (): void {
|
||||
let future: TypeMoq.Mock<EmptyFuture>;
|
||||
let cell: ICellModel;
|
||||
beforeEach(() => {
|
||||
future = TypeMoq.Mock.ofType(EmptyFuture);
|
||||
cell = factory.createCell({
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'print "Hello"',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
}, {
|
||||
notebook: new NotebookModelStub({
|
||||
name: '',
|
||||
version: '',
|
||||
mimetype: 'x-scala'
|
||||
}),
|
||||
isTrusted: false
|
||||
});
|
||||
});
|
||||
|
||||
it('should send and handle incoming messages', async () => {
|
||||
// Given a future
|
||||
let onReply: nb.MessageHandler<nb.IShellMessage>;
|
||||
let onIopub: nb.MessageHandler<nb.IIOPubMessage>;
|
||||
future.setup(f => f.setReplyHandler(TypeMoq.It.isAny())).callback((handler) => onReply = handler);
|
||||
future.setup(f => f.setIOPubHandler(TypeMoq.It.isAny())).callback((handler) => onIopub = handler);
|
||||
let outputs: ReadonlyArray<nb.ICellOutput> = undefined;
|
||||
cell.onOutputsChanged((o => outputs = o));
|
||||
it('should send and handle incoming messages', async () => {
|
||||
// Given a future
|
||||
let onReply: nb.MessageHandler<nb.IShellMessage>;
|
||||
let onIopub: nb.MessageHandler<nb.IIOPubMessage>;
|
||||
future.setup(f => f.setReplyHandler(TypeMoq.It.isAny())).callback((handler) => onReply = handler);
|
||||
future.setup(f => f.setIOPubHandler(TypeMoq.It.isAny())).callback((handler) => onIopub = handler);
|
||||
let outputs: ReadonlyArray<nb.ICellOutput> = undefined;
|
||||
cell.onOutputsChanged((o => outputs = o));
|
||||
|
||||
// When I set it on the cell
|
||||
cell.setFuture(future.object);
|
||||
// When I set it on the cell
|
||||
cell.setFuture(future.object);
|
||||
|
||||
// Then I expect outputs to have been cleared
|
||||
should(outputs).have.length(0);
|
||||
should(onReply).not.be.undefined();
|
||||
// ... And when I send an IoPub message
|
||||
let message: nb.IIOPubMessage = {
|
||||
channel: 'iopub',
|
||||
type: 'iopub',
|
||||
parent_header: undefined,
|
||||
metadata: undefined,
|
||||
header: <nb.IHeader> {
|
||||
msg_type: 'stream'
|
||||
},
|
||||
content: {
|
||||
text: 'Printed hello world'
|
||||
}
|
||||
};
|
||||
onIopub.handle(message);
|
||||
// Then I expect an output to be added
|
||||
should(outputs).have.length(1);
|
||||
should(outputs[0].output_type).equal('stream');
|
||||
// Then I expect outputs to have been cleared
|
||||
should(outputs).have.length(0);
|
||||
should(onReply).not.be.undefined();
|
||||
// ... And when I send an IoPub message
|
||||
let message: nb.IIOPubMessage = {
|
||||
channel: 'iopub',
|
||||
type: 'iopub',
|
||||
parent_header: undefined,
|
||||
metadata: undefined,
|
||||
header: <nb.IHeader>{
|
||||
msg_type: 'stream'
|
||||
},
|
||||
content: {
|
||||
text: 'Printed hello world'
|
||||
}
|
||||
};
|
||||
onIopub.handle(message);
|
||||
// Then I expect an output to be added
|
||||
should(outputs).have.length(1);
|
||||
should(outputs[0].output_type).equal('stream');
|
||||
|
||||
message = objects.deepClone(message);
|
||||
message.header.msg_type = 'display_data';
|
||||
onIopub.handle(message);
|
||||
should(outputs[1].output_type).equal('display_data');
|
||||
message = objects.deepClone(message);
|
||||
message.header.msg_type = 'display_data';
|
||||
onIopub.handle(message);
|
||||
should(outputs[1].output_type).equal('display_data');
|
||||
|
||||
// ... TODO: And when I sent a reply I expect it to be processed.
|
||||
});
|
||||
// ... TODO: And when I sent a reply I expect it to be processed.
|
||||
});
|
||||
|
||||
it('should delete transient tag while handling incoming messages', async () => {
|
||||
// Given a future
|
||||
let onIopub: nb.MessageHandler<nb.IIOPubMessage>;
|
||||
future.setup(f => f.setIOPubHandler(TypeMoq.It.isAny())).callback((handler) => onIopub = handler);
|
||||
let outputs: ReadonlyArray<nb.ICellOutput> = undefined;
|
||||
cell.onOutputsChanged((o => outputs = o));
|
||||
it('should delete transient tag while handling incoming messages', async () => {
|
||||
// Given a future
|
||||
let onIopub: nb.MessageHandler<nb.IIOPubMessage>;
|
||||
future.setup(f => f.setIOPubHandler(TypeMoq.It.isAny())).callback((handler) => onIopub = handler);
|
||||
let outputs: ReadonlyArray<nb.ICellOutput> = undefined;
|
||||
cell.onOutputsChanged((o => outputs = o));
|
||||
|
||||
//Set the future
|
||||
cell.setFuture(future.object);
|
||||
//Set the future
|
||||
cell.setFuture(future.object);
|
||||
|
||||
// ... And when I send an IoPub message
|
||||
let message: nb.IIOPubMessage = {
|
||||
channel: 'iopub',
|
||||
type: 'iopub',
|
||||
parent_header: undefined,
|
||||
metadata: undefined,
|
||||
header: <nb.IHeader> {
|
||||
msg_type: 'display_data'
|
||||
},
|
||||
content: {
|
||||
text: 'Printed hello world',
|
||||
transient: 'transient data'
|
||||
}
|
||||
};
|
||||
onIopub.handle(message);
|
||||
//Output array's length should be 1
|
||||
//'transient' tag should no longer exist in the output
|
||||
should(outputs).have.length(1);
|
||||
should(outputs[0]['transient']).be.undefined();
|
||||
});
|
||||
// ... And when I send an IoPub message
|
||||
let message: nb.IIOPubMessage = {
|
||||
channel: 'iopub',
|
||||
type: 'iopub',
|
||||
parent_header: undefined,
|
||||
metadata: undefined,
|
||||
header: <nb.IHeader>{
|
||||
msg_type: 'display_data'
|
||||
},
|
||||
content: {
|
||||
text: 'Printed hello world',
|
||||
transient: 'transient data'
|
||||
}
|
||||
};
|
||||
onIopub.handle(message);
|
||||
//Output array's length should be 1
|
||||
//'transient' tag should no longer exist in the output
|
||||
should(outputs).have.length(1);
|
||||
should(outputs[0]['transient']).be.undefined();
|
||||
});
|
||||
|
||||
it('should dispose old future', async () => {
|
||||
let oldFuture = TypeMoq.Mock.ofType(EmptyFuture);
|
||||
cell.setFuture(oldFuture.object);
|
||||
it('should dispose old future', async () => {
|
||||
let oldFuture = TypeMoq.Mock.ofType(EmptyFuture);
|
||||
cell.setFuture(oldFuture.object);
|
||||
|
||||
cell.setFuture(future.object);
|
||||
cell.setFuture(future.object);
|
||||
|
||||
oldFuture.verify(f => f.dispose(), TypeMoq.Times.once());
|
||||
});
|
||||
});
|
||||
oldFuture.verify(f => f.dispose(), TypeMoq.Times.once());
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -15,188 +15,188 @@ import { TestNotificationService } from 'vs/platform/notification/test/common/te
|
||||
import URI from 'vs/base/common/uri';
|
||||
|
||||
import { ClientSession } from 'sql/parts/notebook/models/clientSession';
|
||||
import { SessionManager, EmptySession } from 'sql/services/notebook/sessionManager';
|
||||
import { SessionManager, EmptySession } from 'sql/workbench/services/notebook/common/sessionManager';
|
||||
import { NotebookManagerStub, ServerManagerStub } from 'sqltest/parts/notebook/common';
|
||||
|
||||
describe('Client Session', function(): void {
|
||||
let path = URI.file('my/notebook.ipynb');
|
||||
let notebookManager: NotebookManagerStub;
|
||||
let serverManager: ServerManagerStub;
|
||||
let mockSessionManager: TypeMoq.Mock<nb.SessionManager>;
|
||||
let notificationService: TypeMoq.Mock<INotificationService>;
|
||||
let session: ClientSession;
|
||||
let remoteSession: ClientSession;
|
||||
describe('Client Session', function (): void {
|
||||
let path = URI.file('my/notebook.ipynb');
|
||||
let notebookManager: NotebookManagerStub;
|
||||
let serverManager: ServerManagerStub;
|
||||
let mockSessionManager: TypeMoq.Mock<nb.SessionManager>;
|
||||
let notificationService: TypeMoq.Mock<INotificationService>;
|
||||
let session: ClientSession;
|
||||
let remoteSession: ClientSession;
|
||||
|
||||
beforeEach(() => {
|
||||
serverManager = new ServerManagerStub();
|
||||
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
|
||||
notebookManager = new NotebookManagerStub();
|
||||
notebookManager.serverManager = serverManager;
|
||||
notebookManager.sessionManager = mockSessionManager.object;
|
||||
beforeEach(() => {
|
||||
serverManager = new ServerManagerStub();
|
||||
mockSessionManager = TypeMoq.Mock.ofType(SessionManager);
|
||||
notebookManager = new NotebookManagerStub();
|
||||
notebookManager.serverManager = serverManager;
|
||||
notebookManager.sessionManager = mockSessionManager.object;
|
||||
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
|
||||
session = new ClientSession({
|
||||
notebookManager: notebookManager,
|
||||
notebookUri: path,
|
||||
notificationService: notificationService.object
|
||||
});
|
||||
session = new ClientSession({
|
||||
notebookManager: notebookManager,
|
||||
notebookUri: path,
|
||||
notificationService: notificationService.object
|
||||
});
|
||||
|
||||
let serverlessNotebookManager = new NotebookManagerStub();
|
||||
serverlessNotebookManager.sessionManager = mockSessionManager.object;
|
||||
remoteSession = new ClientSession({
|
||||
notebookManager: serverlessNotebookManager,
|
||||
notebookUri: path,
|
||||
notificationService: notificationService.object
|
||||
});
|
||||
});
|
||||
let serverlessNotebookManager = new NotebookManagerStub();
|
||||
serverlessNotebookManager.sessionManager = mockSessionManager.object;
|
||||
remoteSession = new ClientSession({
|
||||
notebookManager: serverlessNotebookManager,
|
||||
notebookUri: path,
|
||||
notificationService: notificationService.object
|
||||
});
|
||||
});
|
||||
|
||||
it('Should set path, isReady and ready on construction', function(): void {
|
||||
should(session.notebookUri).equal(path);
|
||||
should(session.ready).not.be.undefined();
|
||||
should(session.isReady).be.false();
|
||||
should(session.status).equal('starting');
|
||||
should(session.isInErrorState).be.false();
|
||||
should(session.errorMessage).be.undefined();
|
||||
});
|
||||
it('Should set path, isReady and ready on construction', function (): void {
|
||||
should(session.notebookUri).equal(path);
|
||||
should(session.ready).not.be.undefined();
|
||||
should(session.isReady).be.false();
|
||||
should(session.status).equal('starting');
|
||||
should(session.isInErrorState).be.false();
|
||||
should(session.errorMessage).be.undefined();
|
||||
});
|
||||
|
||||
it('Should call on serverManager startup if set', async function(): Promise<void> {
|
||||
// Given I have a serverManager that starts successfully
|
||||
serverManager.result = Promise.resolve();
|
||||
should(session.isReady).be.false();
|
||||
it('Should call on serverManager startup if set', async function (): Promise<void> {
|
||||
// Given I have a serverManager that starts successfully
|
||||
serverManager.result = Promise.resolve();
|
||||
should(session.isReady).be.false();
|
||||
|
||||
// When I kick off initialization
|
||||
await session.initialize();
|
||||
// When I kick off initialization
|
||||
await session.initialize();
|
||||
|
||||
// Then I expect ready to be completed too
|
||||
await session.ready;
|
||||
should(serverManager.calledStart).be.true();
|
||||
should(session.isReady).be.true();
|
||||
});
|
||||
// Then I expect ready to be completed too
|
||||
await session.ready;
|
||||
should(serverManager.calledStart).be.true();
|
||||
should(session.isReady).be.true();
|
||||
});
|
||||
|
||||
it('Should go to error state if serverManager startup fails', async function(): Promise<void> {
|
||||
// Given I have a serverManager that fails to start
|
||||
serverManager.result = Promise.reject('error');
|
||||
should(session.isInErrorState).be.false();
|
||||
it('Should go to error state if serverManager startup fails', async function (): Promise<void> {
|
||||
// Given I have a serverManager that fails to start
|
||||
serverManager.result = Promise.reject('error');
|
||||
should(session.isInErrorState).be.false();
|
||||
|
||||
// When I initialize
|
||||
await session.initialize();
|
||||
// When I initialize
|
||||
await session.initialize();
|
||||
|
||||
// Then I expect ready to complete, but isInErrorState to be true
|
||||
await session.ready;
|
||||
should(session.isReady).be.true();
|
||||
should(serverManager.calledStart).be.true();
|
||||
should(session.isInErrorState).be.true();
|
||||
should(session.errorMessage).equal('error');
|
||||
});
|
||||
// Then I expect ready to complete, but isInErrorState to be true
|
||||
await session.ready;
|
||||
should(session.isReady).be.true();
|
||||
should(serverManager.calledStart).be.true();
|
||||
should(session.isInErrorState).be.true();
|
||||
should(session.errorMessage).equal('error');
|
||||
});
|
||||
|
||||
it('Should be ready when session manager is ready', async function(): Promise<void> {
|
||||
serverManager.result = new Promise((resolve) => {
|
||||
serverManager.isStarted = true;
|
||||
resolve();
|
||||
});
|
||||
mockSessionManager.setup(s => s.ready).returns(() => Promise.resolve());
|
||||
it('Should be ready when session manager is ready', async function (): Promise<void> {
|
||||
serverManager.result = new Promise((resolve) => {
|
||||
serverManager.isStarted = true;
|
||||
resolve();
|
||||
});
|
||||
mockSessionManager.setup(s => s.ready).returns(() => Promise.resolve());
|
||||
|
||||
// When I call initialize
|
||||
await session.initialize();
|
||||
// When I call initialize
|
||||
await session.initialize();
|
||||
|
||||
// Then
|
||||
should(session.isReady).be.true();
|
||||
should(session.isInErrorState).be.false();
|
||||
await session.ready;
|
||||
});
|
||||
// Then
|
||||
should(session.isReady).be.true();
|
||||
should(session.isInErrorState).be.false();
|
||||
await session.ready;
|
||||
});
|
||||
|
||||
it('Should be in error state if server fails to start', async function(): Promise<void> {
|
||||
serverManager.result = new Promise((resolve) => {
|
||||
serverManager.isStarted = false;
|
||||
resolve();
|
||||
});
|
||||
mockSessionManager.setup(s => s.ready).returns(() => Promise.resolve());
|
||||
it('Should be in error state if server fails to start', async function (): Promise<void> {
|
||||
serverManager.result = new Promise((resolve) => {
|
||||
serverManager.isStarted = false;
|
||||
resolve();
|
||||
});
|
||||
mockSessionManager.setup(s => s.ready).returns(() => Promise.resolve());
|
||||
|
||||
// When I call initialize
|
||||
await session.initialize();
|
||||
// When I call initialize
|
||||
await session.initialize();
|
||||
|
||||
// Then
|
||||
await session.ready;
|
||||
should(session.isReady).be.true();
|
||||
should(session.isInErrorState).be.true();
|
||||
});
|
||||
// Then
|
||||
await session.ready;
|
||||
should(session.isReady).be.true();
|
||||
should(session.isInErrorState).be.true();
|
||||
});
|
||||
|
||||
it('Should go to error state if sessionManager fails', async function(): Promise<void> {
|
||||
serverManager.isStarted = true;
|
||||
mockSessionManager.setup(s => s.isReady).returns(() => false);
|
||||
mockSessionManager.setup(s => s.ready).returns(() => Promise.reject('error'));
|
||||
it('Should go to error state if sessionManager fails', async function (): Promise<void> {
|
||||
serverManager.isStarted = true;
|
||||
mockSessionManager.setup(s => s.isReady).returns(() => false);
|
||||
mockSessionManager.setup(s => s.ready).returns(() => Promise.reject('error'));
|
||||
|
||||
// When I call initialize
|
||||
await session.initialize();
|
||||
// When I call initialize
|
||||
await session.initialize();
|
||||
|
||||
// Then
|
||||
should(session.isReady).be.true();
|
||||
should(session.isInErrorState).be.true();
|
||||
should(session.errorMessage).equal('error');
|
||||
});
|
||||
// Then
|
||||
should(session.isReady).be.true();
|
||||
should(session.isInErrorState).be.true();
|
||||
should(session.errorMessage).equal('error');
|
||||
});
|
||||
|
||||
it('Should start session automatically if kernel preference requests it', async function(): Promise<void> {
|
||||
serverManager.isStarted = true;
|
||||
mockSessionManager.setup(s => s.ready).returns(() => Promise.resolve());
|
||||
let sessionMock = TypeMoq.Mock.ofType(EmptySession);
|
||||
let startOptions: nb.ISessionOptions = undefined;
|
||||
mockSessionManager.setup(s => s.startNew(TypeMoq.It.isAny())).returns((options) => {
|
||||
startOptions = options;
|
||||
return Promise.resolve(sessionMock.object);
|
||||
});
|
||||
it('Should start session automatically if kernel preference requests it', async function (): Promise<void> {
|
||||
serverManager.isStarted = true;
|
||||
mockSessionManager.setup(s => s.ready).returns(() => Promise.resolve());
|
||||
let sessionMock = TypeMoq.Mock.ofType(EmptySession);
|
||||
let startOptions: nb.ISessionOptions = undefined;
|
||||
mockSessionManager.setup(s => s.startNew(TypeMoq.It.isAny())).returns((options) => {
|
||||
startOptions = options;
|
||||
return Promise.resolve(sessionMock.object);
|
||||
});
|
||||
|
||||
// When I call initialize after defining kernel preferences
|
||||
session.kernelPreference = {
|
||||
shouldStart: true,
|
||||
name: 'python'
|
||||
};
|
||||
await session.initialize();
|
||||
// When I call initialize after defining kernel preferences
|
||||
session.kernelPreference = {
|
||||
shouldStart: true,
|
||||
name: 'python'
|
||||
};
|
||||
await session.initialize();
|
||||
|
||||
// Then
|
||||
should(session.isReady).be.true();
|
||||
should(session.isInErrorState).be.false();
|
||||
should(startOptions.kernelName).equal('python');
|
||||
should(startOptions.path).equal(path.fsPath);
|
||||
});
|
||||
// Then
|
||||
should(session.isReady).be.true();
|
||||
should(session.isInErrorState).be.false();
|
||||
should(startOptions.kernelName).equal('python');
|
||||
should(startOptions.path).equal(path.fsPath);
|
||||
});
|
||||
|
||||
it('Should shutdown session even if no serverManager is set', async function(): Promise<void> {
|
||||
// Given a session against a remote server
|
||||
let expectedId = 'abc';
|
||||
mockSessionManager.setup(s => s.isReady).returns(() => true);
|
||||
mockSessionManager.setup(s => s.shutdown(TypeMoq.It.isAny())).returns(() => Promise.resolve());
|
||||
let sessionMock = TypeMoq.Mock.ofType(EmptySession);
|
||||
sessionMock.setup(s => s.id).returns(() => expectedId);
|
||||
mockSessionManager.setup(s => s.startNew(TypeMoq.It.isAny())).returns(() => Promise.resolve(sessionMock.object));
|
||||
it('Should shutdown session even if no serverManager is set', async function (): Promise<void> {
|
||||
// Given a session against a remote server
|
||||
let expectedId = 'abc';
|
||||
mockSessionManager.setup(s => s.isReady).returns(() => true);
|
||||
mockSessionManager.setup(s => s.shutdown(TypeMoq.It.isAny())).returns(() => Promise.resolve());
|
||||
let sessionMock = TypeMoq.Mock.ofType(EmptySession);
|
||||
sessionMock.setup(s => s.id).returns(() => expectedId);
|
||||
mockSessionManager.setup(s => s.startNew(TypeMoq.It.isAny())).returns(() => Promise.resolve(sessionMock.object));
|
||||
|
||||
remoteSession.kernelPreference = {
|
||||
shouldStart: true,
|
||||
name: 'python'
|
||||
};
|
||||
await remoteSession.initialize();
|
||||
remoteSession.kernelPreference = {
|
||||
shouldStart: true,
|
||||
name: 'python'
|
||||
};
|
||||
await remoteSession.initialize();
|
||||
|
||||
// When I call shutdown
|
||||
await remoteSession.shutdown();
|
||||
// When I call shutdown
|
||||
await remoteSession.shutdown();
|
||||
|
||||
// Then
|
||||
mockSessionManager.verify(s => s.shutdown(TypeMoq.It.isValue(expectedId)), TypeMoq.Times.once());
|
||||
});
|
||||
// Then
|
||||
mockSessionManager.verify(s => s.shutdown(TypeMoq.It.isValue(expectedId)), TypeMoq.Times.once());
|
||||
});
|
||||
|
||||
|
||||
it('Should stop server if server is set', async function(): Promise<void> {
|
||||
// Given a kernel has been started
|
||||
serverManager.isStarted = true;
|
||||
serverManager.result = Promise.resolve();
|
||||
mockSessionManager.setup(s => s.isReady).returns(() => true);
|
||||
mockSessionManager.setup(s => s.shutdown(TypeMoq.It.isAny())).returns(() => Promise.resolve());
|
||||
it('Should stop server if server is set', async function (): Promise<void> {
|
||||
// Given a kernel has been started
|
||||
serverManager.isStarted = true;
|
||||
serverManager.result = Promise.resolve();
|
||||
mockSessionManager.setup(s => s.isReady).returns(() => true);
|
||||
mockSessionManager.setup(s => s.shutdown(TypeMoq.It.isAny())).returns(() => Promise.resolve());
|
||||
|
||||
await session.initialize();
|
||||
await session.initialize();
|
||||
|
||||
// When I call shutdown
|
||||
await session.shutdown();
|
||||
// When I call shutdown
|
||||
await session.shutdown();
|
||||
|
||||
// Then
|
||||
should(serverManager.calledEnd).be.true();
|
||||
});
|
||||
// Then
|
||||
should(serverManager.calledEnd).be.true();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -6,109 +6,107 @@
|
||||
'use strict';
|
||||
|
||||
import * as should from 'should';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import * as path from 'path';
|
||||
import { nb } from 'sqlops';
|
||||
|
||||
import URI from 'vs/base/common/uri';
|
||||
import * as tempWrite from 'temp-write';
|
||||
import { LocalContentManager } from 'sql/services/notebook/localContentManager';
|
||||
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
|
||||
import * as testUtils from '../../../utils/testUtils';
|
||||
import { CellTypes } from 'sql/parts/notebook/models/contracts';
|
||||
|
||||
let expectedNotebookContent: nb.INotebookContents = {
|
||||
cells: [{
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'insert into t1 values (c1, c2)',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
}],
|
||||
metadata: {
|
||||
kernelspec: {
|
||||
name: 'mssql',
|
||||
language: 'sql'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 2
|
||||
cells: [{
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'insert into t1 values (c1, c2)',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
}],
|
||||
metadata: {
|
||||
kernelspec: {
|
||||
name: 'mssql',
|
||||
language: 'sql'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 2
|
||||
};
|
||||
let notebookContentString = JSON.stringify(expectedNotebookContent);
|
||||
|
||||
function verifyMatchesExpectedNotebook(notebook: nb.INotebookContents): void {
|
||||
should(notebook.cells).have.length(1, 'Expected 1 cell');
|
||||
should(notebook.cells[0].cell_type).equal(CellTypes.Code);
|
||||
should(notebook.cells[0].source).equal(expectedNotebookContent.cells[0].source);
|
||||
should(notebook.metadata.kernelspec.name).equal(expectedNotebookContent.metadata.kernelspec.name);
|
||||
should(notebook.nbformat).equal(expectedNotebookContent.nbformat);
|
||||
should(notebook.nbformat_minor).equal(expectedNotebookContent.nbformat_minor);
|
||||
should(notebook.cells).have.length(1, 'Expected 1 cell');
|
||||
should(notebook.cells[0].cell_type).equal(CellTypes.Code);
|
||||
should(notebook.cells[0].source).equal(expectedNotebookContent.cells[0].source);
|
||||
should(notebook.metadata.kernelspec.name).equal(expectedNotebookContent.metadata.kernelspec.name);
|
||||
should(notebook.nbformat).equal(expectedNotebookContent.nbformat);
|
||||
should(notebook.nbformat_minor).equal(expectedNotebookContent.nbformat_minor);
|
||||
}
|
||||
|
||||
describe('Local Content Manager', function(): void {
|
||||
let contentManager = new LocalContentManager();
|
||||
describe('Local Content Manager', function (): void {
|
||||
let contentManager = new LocalContentManager();
|
||||
|
||||
it('Should return undefined if path is undefined', async function(): Promise<void> {
|
||||
let content = await contentManager.getNotebookContents(undefined);
|
||||
should(content).be.undefined();
|
||||
// tslint:disable-next-line:no-null-keyword
|
||||
content = await contentManager.getNotebookContents(null);
|
||||
should(content).be.undefined();
|
||||
});
|
||||
it('Should return undefined if path is undefined', async function (): Promise<void> {
|
||||
let content = await contentManager.getNotebookContents(undefined);
|
||||
should(content).be.undefined();
|
||||
// tslint:disable-next-line:no-null-keyword
|
||||
content = await contentManager.getNotebookContents(null);
|
||||
should(content).be.undefined();
|
||||
});
|
||||
|
||||
it('Should throw if file does not exist', async function(): Promise<void> {
|
||||
await testUtils.assertThrowsAsync(async () => await contentManager.getNotebookContents(URI.file('/path/doesnot/exist.ipynb')), undefined);
|
||||
});
|
||||
it('Should return notebook contents parsed as INotebook when valid notebook file parsed', async function(): Promise<void> {
|
||||
// Given a file containing a valid notebook
|
||||
let localFile = tempWrite.sync(notebookContentString, 'notebook.ipynb');
|
||||
// when I read the content
|
||||
let notebook = await contentManager.getNotebookContents(URI.file(localFile));
|
||||
// then I expect notebook format to match
|
||||
verifyMatchesExpectedNotebook(notebook);
|
||||
});
|
||||
it('Should ignore invalid content in the notebook file', async function(): Promise<void> {
|
||||
// Given a file containing a notebook with some garbage properties
|
||||
let invalidContent = notebookContentString + '\\nasddfdsafasdf';
|
||||
let localFile = tempWrite.sync(invalidContent, 'notebook.ipynb');
|
||||
// when I read the content
|
||||
let notebook = await contentManager.getNotebookContents(URI.file(localFile));
|
||||
// then I expect notebook format to still be valid
|
||||
verifyMatchesExpectedNotebook(notebook);
|
||||
});
|
||||
it('Should inline mime data into a single string', async function(): Promise<void> {
|
||||
let mimeNotebook: nb.INotebookContents = {
|
||||
cells: [{
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'insert into t1 values (c1, c2)',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1,
|
||||
outputs: [
|
||||
<nb.IDisplayData> {
|
||||
output_type: 'display_data',
|
||||
data: {
|
||||
'text/html': [
|
||||
'<div>',
|
||||
'</div>'
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}],
|
||||
metadata: {
|
||||
kernelspec: {
|
||||
name: 'mssql',
|
||||
language: 'sql'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 2
|
||||
};
|
||||
let mimeContentString = JSON.stringify(mimeNotebook);
|
||||
// Given a file containing a valid notebook with multiline mime type
|
||||
let localFile = tempWrite.sync(mimeContentString, 'notebook.ipynb');
|
||||
// when I read the content
|
||||
let notebook = await contentManager.getNotebookContents(URI.file(localFile));
|
||||
// then I expect output to have been normalized into a single string
|
||||
let displayOutput = <nb.IDisplayData> notebook.cells[0].outputs[0];
|
||||
should(displayOutput.data['text/html']).equal('<div></div>');
|
||||
});
|
||||
it('Should throw if file does not exist', async function (): Promise<void> {
|
||||
await testUtils.assertThrowsAsync(async () => await contentManager.getNotebookContents(URI.file('/path/doesnot/exist.ipynb')), undefined);
|
||||
});
|
||||
it('Should return notebook contents parsed as INotebook when valid notebook file parsed', async function (): Promise<void> {
|
||||
// Given a file containing a valid notebook
|
||||
let localFile = tempWrite.sync(notebookContentString, 'notebook.ipynb');
|
||||
// when I read the content
|
||||
let notebook = await contentManager.getNotebookContents(URI.file(localFile));
|
||||
// then I expect notebook format to match
|
||||
verifyMatchesExpectedNotebook(notebook);
|
||||
});
|
||||
it('Should ignore invalid content in the notebook file', async function (): Promise<void> {
|
||||
// Given a file containing a notebook with some garbage properties
|
||||
let invalidContent = notebookContentString + '\\nasddfdsafasdf';
|
||||
let localFile = tempWrite.sync(invalidContent, 'notebook.ipynb');
|
||||
// when I read the content
|
||||
let notebook = await contentManager.getNotebookContents(URI.file(localFile));
|
||||
// then I expect notebook format to still be valid
|
||||
verifyMatchesExpectedNotebook(notebook);
|
||||
});
|
||||
it('Should inline mime data into a single string', async function (): Promise<void> {
|
||||
let mimeNotebook: nb.INotebookContents = {
|
||||
cells: [{
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'insert into t1 values (c1, c2)',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1,
|
||||
outputs: [
|
||||
<nb.IDisplayData>{
|
||||
output_type: 'display_data',
|
||||
data: {
|
||||
'text/html': [
|
||||
'<div>',
|
||||
'</div>'
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}],
|
||||
metadata: {
|
||||
kernelspec: {
|
||||
name: 'mssql',
|
||||
language: 'sql'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 2
|
||||
};
|
||||
let mimeContentString = JSON.stringify(mimeNotebook);
|
||||
// Given a file containing a valid notebook with multiline mime type
|
||||
let localFile = tempWrite.sync(mimeContentString, 'notebook.ipynb');
|
||||
// when I read the content
|
||||
let notebook = await contentManager.getNotebookContents(URI.file(localFile));
|
||||
// then I expect output to have been normalized into a single string
|
||||
let displayOutput = <nb.IDisplayData>notebook.cells[0].outputs[0];
|
||||
should(displayOutput.data['text/html']).equal('<div></div>');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||
import { TestNotificationService } from 'vs/platform/notification/test/common/testNotificationService';
|
||||
import URI from 'vs/base/common/uri';
|
||||
|
||||
import { LocalContentManager } from 'sql/services/notebook/localContentManager';
|
||||
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
|
||||
import * as testUtils from '../../../utils/testUtils';
|
||||
import { NotebookManagerStub } from '../common';
|
||||
import { NotebookModel } from 'sql/parts/notebook/models/notebookModel';
|
||||
@@ -22,47 +22,47 @@ import { IClientSession, ICellModel, INotebookModelOptions } from 'sql/parts/not
|
||||
import { ClientSession } from 'sql/parts/notebook/models/clientSession';
|
||||
import { CellTypes } from 'sql/parts/notebook/models/contracts';
|
||||
import { Deferred } from 'sql/base/common/promise';
|
||||
import { ConnectionManagementService } from 'sql/parts/connection/common/connectionManagementService';
|
||||
import { ConnectionManagementService } from 'sql/platform/connection/common/connectionManagementService';
|
||||
import { Memento } from 'vs/workbench/common/memento';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
|
||||
let expectedNotebookContent: nb.INotebookContents = {
|
||||
cells: [{
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'insert into t1 values (c1, c2)',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
}, {
|
||||
cell_type: CellTypes.Markdown,
|
||||
source: 'I am *markdown*',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
}],
|
||||
metadata: {
|
||||
kernelspec: {
|
||||
name: 'mssql',
|
||||
language: 'sql'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
cells: [{
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'insert into t1 values (c1, c2)',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
}, {
|
||||
cell_type: CellTypes.Markdown,
|
||||
source: 'I am *markdown*',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
}],
|
||||
metadata: {
|
||||
kernelspec: {
|
||||
name: 'mssql',
|
||||
language: 'sql'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
};
|
||||
|
||||
let expectedNotebookContentOneCell: nb.INotebookContents = {
|
||||
cells: [{
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'insert into t1 values (c1, c2)',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
}],
|
||||
metadata: {
|
||||
kernelspec: {
|
||||
name: 'mssql',
|
||||
language: 'sql'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
cells: [{
|
||||
cell_type: CellTypes.Code,
|
||||
source: 'insert into t1 values (c1, c2)',
|
||||
metadata: { language: 'python' },
|
||||
execution_count: 1
|
||||
}],
|
||||
metadata: {
|
||||
kernelspec: {
|
||||
name: 'mssql',
|
||||
language: 'sql'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
};
|
||||
|
||||
let defaultUri = URI.file('/some/path.ipynb');
|
||||
@@ -72,180 +72,181 @@ let sessionReady: Deferred<void>;
|
||||
let mockModelFactory: TypeMoq.Mock<ModelFactory>;
|
||||
let notificationService: TypeMoq.Mock<INotificationService>;
|
||||
|
||||
describe('notebook model', function(): void {
|
||||
let notebookManagers = [new NotebookManagerStub()];
|
||||
let memento: TypeMoq.Mock<Memento>;
|
||||
let queryConnectionService: TypeMoq.Mock<ConnectionManagementService>;
|
||||
let defaultModelOptions: INotebookModelOptions;
|
||||
beforeEach(() => {
|
||||
sessionReady = new Deferred<void>();
|
||||
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
||||
memento.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => void 0);
|
||||
queryConnectionService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined);
|
||||
queryConnectionService.callBase = true;
|
||||
defaultModelOptions = {
|
||||
notebookUri: defaultUri,
|
||||
factory: new ModelFactory(),
|
||||
notebookManagers,
|
||||
notificationService: notificationService.object,
|
||||
connectionService: queryConnectionService.object,
|
||||
providerId: 'jupyter' };
|
||||
mockClientSession = TypeMoq.Mock.ofType(ClientSession, undefined, defaultModelOptions);
|
||||
mockClientSession.setup(c => c.initialize(TypeMoq.It.isAny())).returns(() => {
|
||||
return Promise.resolve();
|
||||
});
|
||||
mockClientSession.setup(c => c.ready).returns(() => sessionReady.promise);
|
||||
mockModelFactory = TypeMoq.Mock.ofType(ModelFactory);
|
||||
mockModelFactory.callBase = true;
|
||||
mockModelFactory.setup(f => f.createClientSession(TypeMoq.It.isAny())).returns(() => {
|
||||
return mockClientSession.object;
|
||||
});
|
||||
});
|
||||
describe('notebook model', function (): void {
|
||||
let notebookManagers = [new NotebookManagerStub()];
|
||||
let memento: TypeMoq.Mock<Memento>;
|
||||
let queryConnectionService: TypeMoq.Mock<ConnectionManagementService>;
|
||||
let defaultModelOptions: INotebookModelOptions;
|
||||
beforeEach(() => {
|
||||
sessionReady = new Deferred<void>();
|
||||
notificationService = TypeMoq.Mock.ofType(TestNotificationService, TypeMoq.MockBehavior.Loose);
|
||||
memento = TypeMoq.Mock.ofType(Memento, TypeMoq.MockBehavior.Loose, '');
|
||||
memento.setup(x => x.getMemento(TypeMoq.It.isAny())).returns(() => void 0);
|
||||
queryConnectionService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Loose, memento.object, undefined);
|
||||
queryConnectionService.callBase = true;
|
||||
defaultModelOptions = {
|
||||
notebookUri: defaultUri,
|
||||
factory: new ModelFactory(),
|
||||
notebookManagers,
|
||||
notificationService: notificationService.object,
|
||||
connectionService: queryConnectionService.object,
|
||||
providerId: 'jupyter'
|
||||
};
|
||||
mockClientSession = TypeMoq.Mock.ofType(ClientSession, undefined, defaultModelOptions);
|
||||
mockClientSession.setup(c => c.initialize(TypeMoq.It.isAny())).returns(() => {
|
||||
return Promise.resolve();
|
||||
});
|
||||
mockClientSession.setup(c => c.ready).returns(() => sessionReady.promise);
|
||||
mockModelFactory = TypeMoq.Mock.ofType(ModelFactory);
|
||||
mockModelFactory.callBase = true;
|
||||
mockModelFactory.setup(f => f.createClientSession(TypeMoq.It.isAny())).returns(() => {
|
||||
return mockClientSession.object;
|
||||
});
|
||||
});
|
||||
|
||||
it('Should create no cells if model has no contents', async function(): Promise<void> {
|
||||
// Given an empty notebook
|
||||
let emptyNotebook: nb.INotebookContents = {
|
||||
cells: [],
|
||||
metadata: {
|
||||
kernelspec: {
|
||||
name: 'mssql',
|
||||
language: 'sql'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
};
|
||||
it('Should create no cells if model has no contents', async function (): Promise<void> {
|
||||
// Given an empty notebook
|
||||
let emptyNotebook: nb.INotebookContents = {
|
||||
cells: [],
|
||||
metadata: {
|
||||
kernelspec: {
|
||||
name: 'mssql',
|
||||
language: 'sql'
|
||||
}
|
||||
},
|
||||
nbformat: 4,
|
||||
nbformat_minor: 5
|
||||
};
|
||||
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(emptyNotebook));
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(emptyNotebook));
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
|
||||
// When I initialize the model
|
||||
let model = new NotebookModel(defaultModelOptions);
|
||||
await model.requestModelLoad();
|
||||
// When I initialize the model
|
||||
let model = new NotebookModel(defaultModelOptions);
|
||||
await model.requestModelLoad();
|
||||
|
||||
// Then I expect to have 0 code cell as the contents
|
||||
should(model.cells).have.length(0);
|
||||
});
|
||||
// Then I expect to have 0 code cell as the contents
|
||||
should(model.cells).have.length(0);
|
||||
});
|
||||
|
||||
it('Should throw if model load fails', async function(): Promise<void> {
|
||||
// Given a call to get Contents fails
|
||||
let error = new Error('File not found');
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).throws(error);
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
it('Should throw if model load fails', async function (): Promise<void> {
|
||||
// Given a call to get Contents fails
|
||||
let error = new Error('File not found');
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).throws(error);
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
|
||||
// When I initalize the model
|
||||
// Then it should throw
|
||||
let model = new NotebookModel(defaultModelOptions);
|
||||
should(model.inErrorState).be.false();
|
||||
await testUtils.assertThrowsAsync(() => model.requestModelLoad(), error.message);
|
||||
should(model.inErrorState).be.true();
|
||||
});
|
||||
// When I initalize the model
|
||||
// Then it should throw
|
||||
let model = new NotebookModel(defaultModelOptions);
|
||||
should(model.inErrorState).be.false();
|
||||
await testUtils.assertThrowsAsync(() => model.requestModelLoad(), error.message);
|
||||
should(model.inErrorState).be.true();
|
||||
});
|
||||
|
||||
it('Should convert cell info to CellModels', async function(): Promise<void> {
|
||||
// Given a notebook with 2 cells
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedNotebookContent));
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
it('Should convert cell info to CellModels', async function (): Promise<void> {
|
||||
// Given a notebook with 2 cells
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedNotebookContent));
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
|
||||
// When I initalize the model
|
||||
let model = new NotebookModel(defaultModelOptions);
|
||||
await model.requestModelLoad();
|
||||
// When I initalize the model
|
||||
let model = new NotebookModel(defaultModelOptions);
|
||||
await model.requestModelLoad();
|
||||
|
||||
// Then I expect all cells to be in the model
|
||||
should(model.cells).have.length(2);
|
||||
should(model.cells[0].source).be.equal(expectedNotebookContent.cells[0].source);
|
||||
should(model.cells[1].source).be.equal(expectedNotebookContent.cells[1].source);
|
||||
});
|
||||
// Then I expect all cells to be in the model
|
||||
should(model.cells).have.length(2);
|
||||
should(model.cells[0].source).be.equal(expectedNotebookContent.cells[0].source);
|
||||
should(model.cells[1].source).be.equal(expectedNotebookContent.cells[1].source);
|
||||
});
|
||||
|
||||
it('Should load contents but then go to error state if client session startup fails', async function(): Promise<void> {
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedNotebookContentOneCell));
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
it('Should load contents but then go to error state if client session startup fails', async function (): Promise<void> {
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedNotebookContentOneCell));
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
|
||||
// Given I have a session that fails to start
|
||||
mockClientSession.setup(c => c.isInErrorState).returns(() => true);
|
||||
mockClientSession.setup(c => c.errorMessage).returns(() => 'Error');
|
||||
sessionReady.resolve();
|
||||
let sessionFired = false;
|
||||
// Given I have a session that fails to start
|
||||
mockClientSession.setup(c => c.isInErrorState).returns(() => true);
|
||||
mockClientSession.setup(c => c.errorMessage).returns(() => 'Error');
|
||||
sessionReady.resolve();
|
||||
let sessionFired = false;
|
||||
|
||||
let options: INotebookModelOptions = Object.assign({}, defaultModelOptions, <Partial<INotebookModelOptions>> {
|
||||
factory: mockModelFactory.object
|
||||
});
|
||||
let model = new NotebookModel(options);
|
||||
model.onClientSessionReady((session) => sessionFired = true);
|
||||
await model.requestModelLoad();
|
||||
model.backgroundStartSession();
|
||||
let options: INotebookModelOptions = Object.assign({}, defaultModelOptions, <Partial<INotebookModelOptions>>{
|
||||
factory: mockModelFactory.object
|
||||
});
|
||||
let model = new NotebookModel(options);
|
||||
model.onClientSessionReady((session) => sessionFired = true);
|
||||
await model.requestModelLoad();
|
||||
model.backgroundStartSession();
|
||||
|
||||
// Then I expect load to succeed
|
||||
shouldHaveOneCell(model);
|
||||
should(model.clientSession).not.be.undefined();
|
||||
// but on server load completion I expect error state to be set
|
||||
// Note: do not expect serverLoad event to throw even if failed
|
||||
await model.sessionLoadFinished;
|
||||
should(model.inErrorState).be.true();
|
||||
should(sessionFired).be.false();
|
||||
});
|
||||
// Then I expect load to succeed
|
||||
shouldHaveOneCell(model);
|
||||
should(model.clientSession).not.be.undefined();
|
||||
// but on server load completion I expect error state to be set
|
||||
// Note: do not expect serverLoad event to throw even if failed
|
||||
await model.sessionLoadFinished;
|
||||
should(model.inErrorState).be.true();
|
||||
should(sessionFired).be.false();
|
||||
});
|
||||
|
||||
it('Should not be in error state if client session initialization succeeds', async function(): Promise<void> {
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedNotebookContentOneCell));
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
let kernelChangedEmitter: Emitter<nb.IKernelChangedArgs> = new Emitter<nb.IKernelChangedArgs>();
|
||||
it('Should not be in error state if client session initialization succeeds', async function (): Promise<void> {
|
||||
let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager);
|
||||
mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(expectedNotebookContentOneCell));
|
||||
notebookManagers[0].contentManager = mockContentManager.object;
|
||||
let kernelChangedEmitter: Emitter<nb.IKernelChangedArgs> = new Emitter<nb.IKernelChangedArgs>();
|
||||
|
||||
mockClientSession.setup(c => c.isInErrorState).returns(() => false);
|
||||
mockClientSession.setup(c => c.isReady).returns(() => true);
|
||||
mockClientSession.setup(c => c.kernelChanged).returns(() => kernelChangedEmitter.event);
|
||||
mockClientSession.setup(c => c.isInErrorState).returns(() => false);
|
||||
mockClientSession.setup(c => c.isReady).returns(() => true);
|
||||
mockClientSession.setup(c => c.kernelChanged).returns(() => kernelChangedEmitter.event);
|
||||
|
||||
queryConnectionService.setup(c => c.getActiveConnections(TypeMoq.It.isAny())).returns(() => null);
|
||||
queryConnectionService.setup(c => c.getActiveConnections(TypeMoq.It.isAny())).returns(() => null);
|
||||
|
||||
sessionReady.resolve();
|
||||
let actualSession: IClientSession = undefined;
|
||||
sessionReady.resolve();
|
||||
let actualSession: IClientSession = undefined;
|
||||
|
||||
let options: INotebookModelOptions = Object.assign({}, defaultModelOptions, <Partial<INotebookModelOptions>> {
|
||||
factory: mockModelFactory.object
|
||||
});
|
||||
let model = new NotebookModel(options, false);
|
||||
model.onClientSessionReady((session) => actualSession = session);
|
||||
await model.requestModelLoad();
|
||||
model.backgroundStartSession();
|
||||
let options: INotebookModelOptions = Object.assign({}, defaultModelOptions, <Partial<INotebookModelOptions>>{
|
||||
factory: mockModelFactory.object
|
||||
});
|
||||
let model = new NotebookModel(options, false);
|
||||
model.onClientSessionReady((session) => actualSession = session);
|
||||
await model.requestModelLoad();
|
||||
model.backgroundStartSession();
|
||||
|
||||
// Then I expect load to succeed
|
||||
should(model.clientSession).not.be.undefined();
|
||||
// but on server load completion I expect error state to be set
|
||||
// Note: do not expect serverLoad event to throw even if failed
|
||||
let kernelChangedArg: nb.IKernelChangedArgs = undefined;
|
||||
model.kernelChanged((kernel) => kernelChangedArg = kernel);
|
||||
await model.sessionLoadFinished;
|
||||
should(model.inErrorState).be.false();
|
||||
should(actualSession).equal(mockClientSession.object);
|
||||
should(model.clientSession).equal(mockClientSession.object);
|
||||
});
|
||||
// Then I expect load to succeed
|
||||
should(model.clientSession).not.be.undefined();
|
||||
// but on server load completion I expect error state to be set
|
||||
// Note: do not expect serverLoad event to throw even if failed
|
||||
let kernelChangedArg: nb.IKernelChangedArgs = undefined;
|
||||
model.kernelChanged((kernel) => kernelChangedArg = kernel);
|
||||
await model.sessionLoadFinished;
|
||||
should(model.inErrorState).be.false();
|
||||
should(actualSession).equal(mockClientSession.object);
|
||||
should(model.clientSession).equal(mockClientSession.object);
|
||||
});
|
||||
|
||||
it('Should sanitize kernel display name when IP is included', async function(): Promise<void> {
|
||||
let model = new NotebookModel(defaultModelOptions);
|
||||
let displayName = 'PySpark (1.1.1.1)';
|
||||
let sanitizedDisplayName = model.sanitizeDisplayName(displayName);
|
||||
should(sanitizedDisplayName).equal('PySpark');
|
||||
});
|
||||
it('Should sanitize kernel display name when IP is included', async function (): Promise<void> {
|
||||
let model = new NotebookModel(defaultModelOptions);
|
||||
let displayName = 'PySpark (1.1.1.1)';
|
||||
let sanitizedDisplayName = model.sanitizeDisplayName(displayName);
|
||||
should(sanitizedDisplayName).equal('PySpark');
|
||||
});
|
||||
|
||||
it('Should sanitize kernel display name properly when IP is not included', async function(): Promise<void> {
|
||||
let model = new NotebookModel(defaultModelOptions);
|
||||
let displayName = 'PySpark';
|
||||
let sanitizedDisplayName = model.sanitizeDisplayName(displayName);
|
||||
should(sanitizedDisplayName).equal('PySpark');
|
||||
});
|
||||
it('Should sanitize kernel display name properly when IP is not included', async function (): Promise<void> {
|
||||
let model = new NotebookModel(defaultModelOptions);
|
||||
let displayName = 'PySpark';
|
||||
let sanitizedDisplayName = model.sanitizeDisplayName(displayName);
|
||||
should(sanitizedDisplayName).equal('PySpark');
|
||||
});
|
||||
|
||||
function shouldHaveOneCell(model: NotebookModel): void {
|
||||
should(model.cells).have.length(1);
|
||||
verifyCellModel(model.cells[0], { cell_type: CellTypes.Code, source: 'insert into t1 values (c1, c2)', metadata: { language: 'python' }, execution_count: 1 });
|
||||
}
|
||||
function shouldHaveOneCell(model: NotebookModel): void {
|
||||
should(model.cells).have.length(1);
|
||||
verifyCellModel(model.cells[0], { cell_type: CellTypes.Code, source: 'insert into t1 values (c1, c2)', metadata: { language: 'python' }, execution_count: 1 });
|
||||
}
|
||||
|
||||
function verifyCellModel(cellModel: ICellModel, expected: nb.ICellContents): void {
|
||||
should(cellModel.cellType).equal(expected.cell_type);
|
||||
should(cellModel.source).equal(expected.source);
|
||||
}
|
||||
function verifyCellModel(cellModel: ICellModel, expected: nb.ICellContents): void {
|
||||
should(cellModel.cellType).equal(expected.cell_type);
|
||||
should(cellModel.source).equal(expected.source);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { FilterData } from 'sql/parts/profiler/service/profilerFilter';
|
||||
import { ProfilerFilterClauseOperator, ProfilerFilter } from 'sql/parts/profiler/service/interfaces';
|
||||
import { ProfilerFilterClauseOperator, ProfilerFilter } from 'sql/workbench/services/profiler/common/interfaces';
|
||||
|
||||
const property1 = 'property1';
|
||||
const property2 = 'property2';
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
INewConnectionParams,
|
||||
ConnectionType,
|
||||
RunQueryOnConnectionMode
|
||||
} from 'sql/parts/connection/common/connectionManagement';
|
||||
} from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionDialogService } from 'sql/parts/connection/connectionDialog/connectionDialogService';
|
||||
import {
|
||||
RunQueryAction, CancelQueryAction, ListDatabasesActionItem,
|
||||
@@ -23,9 +23,9 @@ import {
|
||||
} from 'sql/parts/query/execution/queryActions';
|
||||
import { QueryInput } from 'sql/parts/query/common/queryInput';
|
||||
import { QueryEditor } from 'sql/parts/query/editor/queryEditor';
|
||||
import { QueryModelService } from 'sql/parts/query/execution/queryModelService';
|
||||
import { ConnectionManagementService } from 'sql/parts/connection/common/connectionManagementService';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { QueryModelService } from 'sql/platform/query/common/queryModelService';
|
||||
import { ConnectionManagementService } from 'sql/platform/connection/common/connectionManagementService';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
import { TestThemeService } from 'sqltest/stubs/themeTestService';
|
||||
import { ConfigurationService } from 'vs/platform/configuration/node/configurationService';
|
||||
|
||||
@@ -16,10 +16,10 @@ import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorIn
|
||||
|
||||
import { QueryResultsInput } from 'sql/parts/query/common/queryResultsInput';
|
||||
import { QueryEditor } from 'sql/parts/query/editor/queryEditor';
|
||||
import { QueryModelService } from 'sql/parts/query/execution/queryModelService';
|
||||
import { QueryModelService } from 'sql/platform/query/common/queryModelService';
|
||||
import { QueryInput } from 'sql/parts/query/common/queryInput';
|
||||
import { INewConnectionParams, ConnectionType, RunQueryOnConnectionMode } from 'sql/parts/connection/common/connectionManagement';
|
||||
import { ConnectionManagementService } from 'sql/parts/connection/common/connectionManagementService';
|
||||
import { INewConnectionParams, ConnectionType, RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { ConnectionManagementService } from 'sql/platform/connection/common/connectionManagementService';
|
||||
import { RunQueryAction, ListDatabasesActionItem } from 'sql/parts/query/execution/queryActions';
|
||||
import { EditorDescriptorService } from 'sql/parts/query/editor/editorDescriptorService';
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ServerTreeView } from 'sql/parts/objectExplorer/viewlet/serverTreeView';
|
||||
import { ConnectionManagementService } from 'sql/parts/connection/common/connectionManagementService';
|
||||
import { ConnectionManagementService } from 'sql/platform/connection/common/connectionManagementService';
|
||||
|
||||
import { Tree } from 'vs/base/parts/tree/browser/treeImpl';
|
||||
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
|
||||
@@ -24,7 +24,7 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => {
|
||||
let instantiationService = new TestInstantiationService();
|
||||
let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict, {}, {});
|
||||
mockConnectionManagementService.setup(x => x.getConnectionGroups()).returns(x => []);
|
||||
serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, undefined, undefined, undefined, undefined);
|
||||
serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, undefined, undefined, undefined);
|
||||
let tree = <Tree>{
|
||||
clearSelection() { },
|
||||
getSelection() { },
|
||||
|
||||
@@ -3,15 +3,14 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Mock, It, Times, GlobalMock } from 'typemoq';
|
||||
import { Dialog, DialogTab } from 'sql/platform/dialog/dialogTypes';
|
||||
import { DialogPane } from 'sql/platform/dialog/dialogPane';
|
||||
import { DialogComponentParams } from 'sql/platform/dialog/dialogContainer.component';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { bootstrapAngular } from 'sql/services/bootstrap/bootstrapService';
|
||||
|
||||
'use strict';
|
||||
|
||||
interface BootstrapAngular {
|
||||
(collection, moduleType, container, selectorString, params: DialogComponentParams, input, callbackSetModule): void;
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
import * as assert from 'assert';
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import AccountStore from 'sql/services/accountManagement/accountStore';
|
||||
import AccountStore from 'sql/platform/accountManagement/common/accountStore';
|
||||
import { AccountDialogController } from 'sql/parts/accountManagement/accountDialog/accountDialogController';
|
||||
import { AccountManagementService } from 'sql/services/accountManagement/accountManagementService';
|
||||
import { AccountAdditionResult, AccountProviderAddedEventParams, UpdateAccountListEventParams } from 'sql/services/accountManagement/eventTypes';
|
||||
import { IAccountStore } from 'sql/services/accountManagement/interfaces';
|
||||
import { AccountManagementService } from 'sql/workbench/services/accountManagement/browser/accountManagementService';
|
||||
import { AccountAdditionResult, AccountProviderAddedEventParams, UpdateAccountListEventParams } from 'sql/platform/accountManagement/common/eventTypes';
|
||||
import { IAccountStore } from 'sql/platform/accountManagement/common/interfaces';
|
||||
import { AccountProviderStub } from 'sqltest/stubs/accountManagementStubs';
|
||||
import { EventVerifierSingle } from 'sqltest/utils/eventVerifier';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as sqlops from 'sqlops';
|
||||
import AccountStore from 'sql/services/accountManagement/accountStore';
|
||||
import AccountStore from 'sql/platform/accountManagement/common/accountStore';
|
||||
import { EventVerifierSingle } from 'sqltest/utils/eventVerifier';
|
||||
|
||||
suite('Account Store Tests', () => {
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IAccountManagementService } from 'sql/services/accountManagement/interfaces';
|
||||
import { AccountProviderAddedEventParams, UpdateAccountListEventParams } from 'sql/services/accountManagement/eventTypes';
|
||||
import { IAccountManagementService } from 'sql/platform/accountManagement/common/interfaces';
|
||||
import { AccountProviderAddedEventParams, UpdateAccountListEventParams } from 'sql/platform/accountManagement/common/eventTypes';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
|
||||
export class AccountManagementTestService implements IAccountManagementService {
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
'use strict';
|
||||
import * as sqlops from 'sqlops';
|
||||
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
|
||||
import { ICapabilitiesService, clientCapabilities, ProviderFeatures } from 'sql/services/capabilities/capabilitiesService';
|
||||
import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo';
|
||||
import { ICapabilitiesService, ProviderFeatures } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
@@ -16,8 +16,6 @@ export class CapabilitiesTestService implements ICapabilitiesService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
private _providers: sqlops.CapabilitiesProvider[] = [];
|
||||
|
||||
public capabilities: { [id: string]: ProviderFeatures } = {};
|
||||
|
||||
constructor() {
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
import {
|
||||
IConnectionDialogService, IConnectionManagementService, INewConnectionParams, IConnectionResult
|
||||
} from 'sql/parts/connection/common/connectionManagement';
|
||||
} from 'sql/platform/connection/common/connectionManagement';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
export class ConnectionDialogTestService implements IConnectionDialogService {
|
||||
_serviceBrand: any;
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IConnectionManagementService, IConnectableInput, IConnectionCompletionOptions, IConnectionCallbacks, IConnectionResult, INewConnectionParams }
|
||||
from 'sql/parts/connection/common/connectionManagement';
|
||||
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/parts/connection/common/connectionProfileGroup';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { ConnectionManagementInfo } from 'sql/parts/connection/common/connectionManagementInfo';
|
||||
from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IConnectionProfileGroup, ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo';
|
||||
import * as sqlops from 'sqlops';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { CredentialManagementEvents, ICredentialsService } from 'sql/services/credentials/credentialsService';
|
||||
import { CredentialManagementEvents, ICredentialsService } from 'sql/platform/credentials/common/credentialsService';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export class CredentialsTestProvider implements sqlops.CredentialProvider {
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import { IErrorMessageService } from 'sql/parts/connection/common/connectionManagement';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||
|
||||
export class ErrorMessageServiceStub implements IErrorMessageService {
|
||||
_serviceBrand: any;
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import { IHandleFirewallRuleResult, IResourceProviderService } from 'sql/parts/accountManagement/common/interfaces';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { IHandleFirewallRuleResult, IResourceProviderService } from 'sql/workbench/services/resourceProvider/common/resourceProviderService';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
|
||||
export class ResourceProviderStub implements IResourceProviderService {
|
||||
_serviceBrand: any;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
|
||||
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
|
||||
import { IConfigurationData, IConfigurationOverrides, ConfigurationTarget, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
@@ -24,7 +24,7 @@ export class WorkspaceConfigurationTestService implements IWorkspaceConfiguratio
|
||||
|
||||
onDidChangeConfiguration: Event<IConfigurationChangeEvent>;
|
||||
|
||||
getConfigurationData(): IConfigurationData { return undefined; }
|
||||
getConfigurationData(): IConfigurationData { return undefined; }
|
||||
|
||||
getConfiguration<T>(): T;
|
||||
getConfiguration<T>(section: string): T;
|
||||
@@ -54,7 +54,7 @@ export class WorkspaceConfigurationTestService implements IWorkspaceConfiguratio
|
||||
workspaceFolder: T,
|
||||
memory?: T,
|
||||
value: T,
|
||||
} { return undefined; }
|
||||
} { return undefined; }
|
||||
|
||||
keys(): {
|
||||
default: string[];
|
||||
@@ -62,7 +62,7 @@ export class WorkspaceConfigurationTestService implements IWorkspaceConfiguratio
|
||||
workspace: string[];
|
||||
workspaceFolder: string[];
|
||||
memory?: string[];
|
||||
} { return undefined; }
|
||||
} { return undefined; }
|
||||
|
||||
getUnsupportedWorkspaceKeys(): string[] { return undefined; }
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
|
||||
import { IRPCProtocol } from 'vs/workbench/services/extensions/node/proxyIdentifier';
|
||||
import { SqlMainContext } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { MainThreadAccountManagement } from 'sql/workbench/api/node/mainThreadAccountManagement';
|
||||
import { IAccountManagementService, AzureResource } from 'sql/services/accountManagement/interfaces';
|
||||
import { IAccountManagementService, AzureResource } from 'sql/platform/accountManagement/common/interfaces';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
const IRPCProtocol = createDecorator<IRPCProtocol>('rpcProtocol');
|
||||
@@ -365,9 +365,9 @@ suite('ExtHostAccountManagement', () => {
|
||||
|
||||
extHost.$getAllAccounts()
|
||||
.then((accounts) => {
|
||||
// If: I get security token it will not throw
|
||||
return extHost.$getSecurityToken(mockAccount1, AzureResource.ResourceManagement);
|
||||
}
|
||||
// If: I get security token it will not throw
|
||||
return extHost.$getSecurityToken(mockAccount1, AzureResource.ResourceManagement);
|
||||
}
|
||||
).then(() => done(), (err) => done(new Error(err)));
|
||||
});
|
||||
|
||||
@@ -416,15 +416,15 @@ suite('ExtHostAccountManagement', () => {
|
||||
};
|
||||
|
||||
extHost.$getAllAccounts()
|
||||
.then(accounts => {
|
||||
return extHost.$getSecurityToken(mockAccount2, AzureResource.ResourceManagement);
|
||||
})
|
||||
.then((noError) => {
|
||||
done(new Error('Expected getSecurityToken to throw'));
|
||||
}, (err) => {
|
||||
// Expected error caught
|
||||
done();
|
||||
});
|
||||
.then(accounts => {
|
||||
return extHost.$getSecurityToken(mockAccount2, AzureResource.ResourceManagement);
|
||||
})
|
||||
.then((noError) => {
|
||||
done(new Error('Expected getSecurityToken to throw'));
|
||||
}, (err) => {
|
||||
// Expected error caught
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -448,9 +448,9 @@ function getMockAccountManagementService(accounts: sqlops.Account[]): TypeMoq.Mo
|
||||
mockAccountManagementService.setup(x => x.getAccountsForProvider(TypeMoq.It.isAny()))
|
||||
.returns(() => Promise.resolve(accounts));
|
||||
mockAccountManagementService.setup(x => x.getSecurityToken(TypeMoq.It.isValue(accounts[0]), TypeMoq.It.isAny()))
|
||||
.returns(() => Promise.resolve({}));
|
||||
.returns(() => Promise.resolve({}));
|
||||
mockAccountManagementService.setup(x => x.updateAccountListEvent)
|
||||
.returns(() => () => { return undefined; } );
|
||||
.returns(() => () => { return undefined; });
|
||||
|
||||
return mockAccountManagementService;
|
||||
}
|
||||
@@ -3,6 +3,8 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as assert from 'assert';
|
||||
import { Mock, It, Times } from 'typemoq';
|
||||
@@ -10,7 +12,6 @@ import { ExtHostBackgroundTaskManagement, TaskStatus } from 'sql/workbench/api/n
|
||||
import { MainThreadBackgroundTaskManagementShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
|
||||
'use strict';
|
||||
|
||||
suite('ExtHostBackgroundTaskManagement Tests', () => {
|
||||
let extHostBackgroundTaskManagement: ExtHostBackgroundTaskManagement;
|
||||
|
||||
@@ -13,7 +13,7 @@ import { SqlMainContext } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { IRPCProtocol } from 'vs/workbench/services/extensions/node/proxyIdentifier';
|
||||
import { MainThreadCredentialManagement } from 'sql/workbench/api/node/mainThreadCredentialManagement';
|
||||
import { CredentialsTestProvider, CredentialsTestService } from 'sqltest/stubs/credentialsTestStubs';
|
||||
import { ICredentialsService } from 'sql/services/credentials/credentialsService';
|
||||
import { ICredentialsService } from 'sql/platform/credentials/common/credentialsService';
|
||||
import { Credential, CredentialProvider } from 'sqlops';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Mock, It, Times, MockBehavior } from 'typemoq';
|
||||
import * as sqlops from 'sqlops';
|
||||
import { ExtHostModelView } from 'sql/workbench/api/node/extHostModelView';
|
||||
import { MainThreadModelViewShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { Deferred } from 'sql/base/common/promise';
|
||||
import { IComponentShape, IItemConfig, ComponentEventType, IComponentEventArgs, ModelComponentTypes } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { TitledFormItemLayout } from 'sql/parts/modelComponents/formContainer.component';
|
||||
|
||||
'use strict';
|
||||
interface InternalItemConfig {
|
||||
toIItemConfig(): IItemConfig;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as assert from 'assert';
|
||||
import { Mock, It, Times } from 'typemoq';
|
||||
@@ -11,7 +13,6 @@ import { MainThreadModelViewDialogShape, ExtHostModelViewShape } from 'sql/workb
|
||||
import { IMainContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { MessageLevel } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
|
||||
'use strict';
|
||||
|
||||
suite('ExtHostModelViewDialog Tests', () => {
|
||||
let extHostModelViewDialog: ExtHostModelViewDialog;
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as sqlops from 'sqlops';
|
||||
import * as assert from 'assert';
|
||||
import { Mock, It, Times } from 'typemoq';
|
||||
import { MainThreadBackgroundTaskManagement, TaskStatus } from 'sql/workbench/api/node/mainThreadBackgroundTaskManagement';
|
||||
import { ExtHostBackgroundTaskManagementShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { ITaskService } from 'sql/parts/taskHistory/common/taskService';
|
||||
import { ITaskService } from 'sql/platform/taskHistory/common/taskService';
|
||||
import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
import { TaskNode } from 'sql/parts/taskHistory/common/taskNode';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
|
||||
'use strict';
|
||||
|
||||
suite('MainThreadBackgroundTaskManagement Tests', () => {
|
||||
let mainThreadBackgroundTaskManagement: MainThreadBackgroundTaskManagement;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Mock, It, Times } from 'typemoq';
|
||||
import { MainThreadModelViewDialog } from 'sql/workbench/api/node/mainThreadModelViewDialog';
|
||||
@@ -13,7 +15,6 @@ import { Dialog, DialogTab, Wizard } from 'sql/platform/dialog/dialogTypes';
|
||||
import { ExtHostModelViewDialogShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
|
||||
'use strict';
|
||||
|
||||
suite('MainThreadModelViewDialog Tests', () => {
|
||||
let mainThreadModelViewDialog: MainThreadModelViewDialog;
|
||||
|
||||
@@ -14,10 +14,10 @@ import { IExtHostContext } from 'vs/workbench/api/node/extHost.protocol';
|
||||
|
||||
import { ExtHostNotebookShape } from 'sql/workbench/api/node/sqlExtHost.protocol';
|
||||
import { MainThreadNotebook } from 'sql/workbench/api/node/mainThreadNotebook';
|
||||
import { NotebookService } from 'sql/services/notebook/notebookServiceImpl';
|
||||
import { INotebookProvider } from 'sql/services/notebook/notebookService';
|
||||
import { NotebookService } from 'sql/workbench/services/notebook/common/notebookServiceImpl';
|
||||
import { INotebookProvider } from 'sql/workbench/services/notebook/common/notebookService';
|
||||
import { INotebookManagerDetails, INotebookSessionDetails, INotebookKernelDetails, INotebookFutureDetails } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { LocalContentManager } from 'sql/services/notebook/localContentManager';
|
||||
import { LocalContentManager } from 'sql/workbench/services/notebook/node/localContentManager';
|
||||
|
||||
suite('MainThreadNotebook Tests', () => {
|
||||
|
||||
@@ -91,7 +91,7 @@ suite('MainThreadNotebook Tests', () => {
|
||||
hasServerManager: false
|
||||
};
|
||||
mockProxy.setup(p => p.$getNotebookManager(TypeMoq.It.isAnyNumber(), TypeMoq.It.isValue(notebookUri)))
|
||||
.returns(() => Promise.resolve(details));
|
||||
.returns(() => Promise.resolve(details));
|
||||
|
||||
// When I get the notebook manager
|
||||
let manager = await provider.getNotebookManager(notebookUri);
|
||||
@@ -105,7 +105,7 @@ suite('MainThreadNotebook Tests', () => {
|
||||
test('should return manager with a content & server manager if extension host has these', async () => {
|
||||
// Given the extension provider doesn't have acontent or server manager
|
||||
mockProxy.setup(p => p.$getNotebookManager(TypeMoq.It.isAnyNumber(), TypeMoq.It.isValue(notebookUri)))
|
||||
.returns(() => Promise.resolve(managerWithAllFeatures));
|
||||
.returns(() => Promise.resolve(managerWithAllFeatures));
|
||||
|
||||
// When I get the notebook manager
|
||||
let manager = await provider.getNotebookManager(notebookUri);
|
||||
|
||||
@@ -10,8 +10,8 @@ import * as TypeMoq from 'typemoq';
|
||||
import * as TaskUtilities from 'sql/workbench/common/taskUtilities';
|
||||
import { IObjectExplorerService } from 'sql/parts/objectExplorer/common/objectExplorerService';
|
||||
import { TestConnectionManagementService } from 'sqltest/stubs/connectionManagementService.test';
|
||||
import { IConnectionProfile } from 'sql/parts/connection/common/interfaces';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { WorkbenchEditorTestService } from 'sqltest/stubs/workbenchEditorTestService';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
|
||||
|
||||
Reference in New Issue
Block a user