Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed May 20, 2020
1 parent 035f6f4 commit 7a09cb9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
1 change: 0 additions & 1 deletion jupyter_conda/envmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ async def export_env(
)
else:
command.append("--from-history")

ans = await self._execute(*command)
rcode, output = ans
if rcode > 0:
Expand Down
6 changes: 2 additions & 4 deletions jupyter_conda/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,10 @@ def test_env_export_history(self):
)

def test_env_export_not_supporting_history(self):
manager = TestEnvironmentHandler.notebook.web_app.settings["env_manager"]
manager._conda_version = (4, 6, 0)

try:
n = generate_name()
self.wait_for_task(self.mk_env, n)
EnvManager._conda_version = (4, 6, 0)
r = self.conda_api.get(
["environments", n], params={"download": 1, "history": 1}
)
Expand All @@ -597,7 +595,7 @@ def test_env_export_not_supporting_history(self):
self.assertRegex(content, r"- python=\d\.\d+\.\d+=\w+")
self.assertRegex(content, r"prefix:")
finally:
manager._conda_version = None
EnvManager._conda_version = None


class TestCondaVersion(JupyterCondaAPITest):
Expand Down
31 changes: 29 additions & 2 deletions labextension/src/__tests__/services.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ describe("jupyterlab_conda/services", () => {
// TODO describe("dispose()", () => {});

describe("export()", () => {
it("should request to export", async () => {
it("should request to export in full format", async () => {
const name = "dummy";
(ServerConnection.makeRequest as jest.Mock).mockResolvedValue(
new Response("", { status: 200 })
Expand All @@ -258,7 +258,33 @@ describe("jupyterlab_conda/services", () => {
const envManager = new CondaEnvironments();
await envManager.export(name);

const queryArgs = URLExt.objectToQueryString({ download: 1 });
const queryArgs = URLExt.objectToQueryString({
download: 1,
history: 0
});
expect(ServerConnection.makeRequest).toBeCalledWith(
URLExt.join(settings.baseUrl, "conda", "environments", name) +
queryArgs,
{
method: "GET"
},
settings
);
});

it("should request to export in history format", async () => {
const name = "dummy";
(ServerConnection.makeRequest as jest.Mock).mockResolvedValue(
new Response("", { status: 200 })
);

const envManager = new CondaEnvironments();
await envManager.export(name, true);

const queryArgs = URLExt.objectToQueryString({
download: 1,
history: 1
});
expect(ServerConnection.makeRequest).toBeCalledWith(
URLExt.join(settings.baseUrl, "conda", "environments", name) +
queryArgs,
Expand Down Expand Up @@ -364,6 +390,7 @@ describe("jupyterlab_conda/services", () => {
get: jest.fn().mockImplementation((key: string) => {
// @ts-ignore
return {
fromHistory: { composite: false },
types: { composite: {} },
whitelist: { composite: true }
}[key];
Expand Down
2 changes: 1 addition & 1 deletion labextension/src/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface IEnvironmentManager extends IDisposable {
* @param name Name of the environment to be exported
* @param fromHistory Whether to export only from the history
*/
export(name: string, fromHistory: boolean): Promise<Response>;
export(name: string, fromHistory?: boolean): Promise<Response>;
/**
* Create an environment from a packages list file
*
Expand Down

0 comments on commit 7a09cb9

Please # to comment.