Repository navigation
Expand file tree
/
Copy pathlegacyIOC.unit.test.ts
More file actions
145 lines (134 loc) · 7.12 KB
/
Copy pathlegacyIOC.unit.test.ts
File metadata and controls
145 lines (134 loc) · 7.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
// tslint:disable: no-any
import {
anything, instance, mock, verify,
} from 'ts-mockito';
import {
CONDA_ENV_FILE_SERVICE,
CONDA_ENV_SERVICE,
CURRENT_PATH_SERVICE,
GLOBAL_VIRTUAL_ENV_SERVICE,
ICondaService,
IInterpreterLocatorHelper,
IInterpreterLocatorProgressService,
IInterpreterLocatorService,
IInterpreterWatcher,
IInterpreterWatcherBuilder,
IKnownSearchPathsForInterpreters,
INTERPRETER_LOCATOR_SERVICE,
IVirtualEnvironmentsSearchPathProvider,
KNOWN_PATH_SERVICE,
PIPENV_SERVICE,
WINDOWS_REGISTRY_SERVICE,
WORKSPACE_VIRTUAL_ENV_SERVICE,
} from '../../client/interpreter/contracts';
import { IPipEnvServiceHelper, IPythonInPathCommandProvider } from '../../client/interpreter/locators/types';
import { ServiceContainer } from '../../client/ioc/container';
import { ServiceManager } from '../../client/ioc/serviceManager';
import { PythonEnvironments } from '../../client/pythonEnvironments';
import { PythonInterpreterLocatorService } from '../../client/pythonEnvironments/discovery/locators';
import { InterpreterLocatorHelper } from '../../client/pythonEnvironments/discovery/locators/helpers';
import { InterpreterLocatorProgressService } from '../../client/pythonEnvironments/discovery/locators/progressService';
import { CondaEnvFileService } from '../../client/pythonEnvironments/discovery/locators/services/condaEnvFileService';
import { CondaEnvService } from '../../client/pythonEnvironments/discovery/locators/services/condaEnvService';
import { CondaService } from '../../client/pythonEnvironments/discovery/locators/services/condaService';
import {
CurrentPathService,
PythonInPathCommandProvider,
} from '../../client/pythonEnvironments/discovery/locators/services/currentPathService';
import {
GlobalVirtualEnvironmentsSearchPathProvider,
GlobalVirtualEnvService,
} from '../../client/pythonEnvironments/discovery/locators/services/globalVirtualEnvService';
import { InterpreterHashProvider } from '../../client/pythonEnvironments/discovery/locators/services/hashProvider';
import { InterpeterHashProviderFactory } from '../../client/pythonEnvironments/discovery/locators/services/hashProviderFactory';
import { InterpreterWatcherBuilder } from '../../client/pythonEnvironments/discovery/locators/services/interpreterWatcherBuilder';
import {
KnownPathsService,
KnownSearchPathsForInterpreters,
} from '../../client/pythonEnvironments/discovery/locators/services/KnownPathsService';
import { PipEnvService } from '../../client/pythonEnvironments/discovery/locators/services/pipEnvService';
import { PipEnvServiceHelper } from '../../client/pythonEnvironments/discovery/locators/services/pipEnvServiceHelper';
import { WindowsRegistryService } from '../../client/pythonEnvironments/discovery/locators/services/windowsRegistryService';
import { WindowsStoreInterpreter } from '../../client/pythonEnvironments/discovery/locators/services/windowsStoreInterpreter';
import {
WorkspaceVirtualEnvironmentsSearchPathProvider,
WorkspaceVirtualEnvService,
} from '../../client/pythonEnvironments/discovery/locators/services/workspaceVirtualEnvService';
import { WorkspaceVirtualEnvWatcherService } from '../../client/pythonEnvironments/discovery/locators/services/workspaceVirtualEnvWatcherService';
import { IEnvironmentInfoService } from '../../client/pythonEnvironments/info/environmentInfoService';
import { registerForIOC } from '../../client/pythonEnvironments/legacyIOC';
suite('Interpreters - Service Registry', () => {
test('Registrations', () => {
const serviceManager = mock(ServiceManager);
const serviceContainer = mock(ServiceContainer);
const api = mock(PythonEnvironments);
registerForIOC(instance(serviceManager), instance(serviceContainer), instance(api));
verify(serviceManager.addSingleton(IKnownSearchPathsForInterpreters, KnownSearchPathsForInterpreters)).once();
verify(serviceManager.addSingleton(IVirtualEnvironmentsSearchPathProvider, GlobalVirtualEnvironmentsSearchPathProvider, 'global')).once();
verify(serviceManager.addSingleton(IVirtualEnvironmentsSearchPathProvider, WorkspaceVirtualEnvironmentsSearchPathProvider, 'workspace')).once();
verify(serviceManager.addSingleton(ICondaService, CondaService)).once();
verify(serviceManager.addSingleton(IPipEnvServiceHelper, PipEnvServiceHelper)).once();
verify(serviceManager.addSingleton(IPythonInPathCommandProvider, PythonInPathCommandProvider)).once();
verify(serviceManager.addSingleton(IInterpreterWatcherBuilder, InterpreterWatcherBuilder)).once();
verify(
serviceManager.addSingleton(
IInterpreterLocatorService,
PythonInterpreterLocatorService,
INTERPRETER_LOCATOR_SERVICE,
),
).once();
verify(
serviceManager.addSingleton(IInterpreterLocatorService, CondaEnvFileService, CONDA_ENV_FILE_SERVICE),
).once();
verify(serviceManager.addSingleton(IInterpreterLocatorService, CondaEnvService, CONDA_ENV_SERVICE)).once();
verify(
serviceManager.addSingleton(IInterpreterLocatorService, CurrentPathService, CURRENT_PATH_SERVICE),
).once();
verify(
serviceManager.addSingleton(
IInterpreterLocatorService,
GlobalVirtualEnvService,
GLOBAL_VIRTUAL_ENV_SERVICE,
),
).once();
verify(
serviceManager.addSingleton(
IInterpreterLocatorService,
WorkspaceVirtualEnvService,
WORKSPACE_VIRTUAL_ENV_SERVICE,
),
).once();
verify(serviceManager.addSingleton(IInterpreterLocatorService, PipEnvService, PIPENV_SERVICE)).once();
verify(
serviceManager.addSingleton(
IInterpreterLocatorService,
WindowsRegistryService,
WINDOWS_REGISTRY_SERVICE,
),
).once();
verify(serviceManager.addSingleton(IInterpreterLocatorService, KnownPathsService, KNOWN_PATH_SERVICE)).once();
verify(serviceManager.addSingleton(IInterpreterLocatorHelper, InterpreterLocatorHelper)).once();
verify(
serviceManager.addSingleton(
IInterpreterLocatorProgressService,
InterpreterLocatorProgressService,
),
).once();
verify(serviceManager.addSingleton(WindowsStoreInterpreter, WindowsStoreInterpreter)).once();
verify(serviceManager.addSingleton(InterpreterHashProvider, InterpreterHashProvider)).once();
verify(serviceManager.addSingleton(InterpeterHashProviderFactory, InterpeterHashProviderFactory)).once();
verify(
serviceManager.add<IInterpreterWatcher>(
IInterpreterWatcher,
WorkspaceVirtualEnvWatcherService,
WORKSPACE_VIRTUAL_ENV_SERVICE,
),
).once();
verify(
serviceManager.addSingletonInstance<IEnvironmentInfoService>(IEnvironmentInfoService, anything()),
).once();
});
});