How to use the @jupyterlab/services.Drive function in @jupyterlab/services

To help you get started, we’ve selected a few @jupyterlab/services examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyterlab / jupyterlab / tests / test-services / src / contents / index.spec.ts View on Github external
it('should accept server settings', async () => {
      const drive = new Drive({ serverSettings });
      handleRequest(drive, 201, DEFAULT_DIR);
      const options: Contents.ICreateOptions = {
        path: '/foo',
        type: 'file',
        ext: 'txt'
      };
      const model = await drive.newUntitled(options);
      expect(model.content[0].path).to.equal(DEFAULT_DIR.content[0].path);
    });
github jupyterlab / jupyterlab / tests / test-services / src / contents / index.spec.ts View on Github external
it('should encode characters', async () => {
      const drive = new Drive({ serverSettings: settings });
      const url = await drive.getDownloadUrl('b ar?3.txt');
      expect(url).to.equal('http://foo/files/b%20ar%3F3.txt');
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / contents / index.spec.ts View on Github external
it('should be emitted when a file changes', async () => {
      const drive = new Drive();
      handleRequest(drive, 201, DEFAULT_FILE);
      let called = false;
      drive.fileChanged.connect((sender, args) => {
        expect(sender).to.equal(drive);
        expect(args.type).to.equal('new');
        expect(args.oldValue).to.be.null;
        expect(args.newValue.path).to.equal(DEFAULT_FILE.path);
        called = true;
      });
      await drive.newUntitled();
      expect(called).to.equal(true);
    });
  });
github jupyterlab / jupyterlab / tests / test-services / src / contents / index.spec.ts View on Github external
it('should accept options', () => {
      const contents = new ContentsManager({
        defaultDrive: new Drive()
      });
      expect(contents).to.be.an.instanceof(ContentsManager);
    });
  });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / contents / index.spec.ts View on Github external
it('should fail for an incorrect model', async () => {
      const drive = new Drive();
      const cp = JSON.parse(JSON.stringify(DEFAULT_CP));
      delete cp.last_modified;
      handleRequest(drive, 201, cp);
      const checkpoint = drive.createCheckpoint('/foo/bar.txt');
      await expectFailure(checkpoint);
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / contents / index.spec.ts View on Github external
it('should leave alone names with ":" that are not drive names', () => {
      contents.addDrive(new Drive({ name: 'other' }));

      expect(
        contents.driveName('which:foo/odd:directory/example:file.txt')
      ).to.equal('');
    });
  });
github jupyterlab / jupyterlab / tests / test-services / src / contents / index.spec.ts View on Github external
it('should encode characters', async () => {
      const drive = new Drive({ serverSettings: settings });
      const contents = new ContentsManager({ defaultDrive: drive });
      const url = await contents.getDownloadUrl('b ar?3.txt');
      expect(url).to.equal('http://foo/files/b%20ar%3F3.txt');
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / contents / index.spec.ts View on Github external
it('should create a directory', async () => {
      const drive = new Drive();
      handleRequest(drive, 201, DEFAULT_DIR);
      const options: Contents.ICreateOptions = {
        path: '/foo',
        type: 'directory'
      };
      const newDir = drive.newUntitled(options);
      const model = await newDir;
      expect(model.content[0].path).to.equal(DEFAULT_DIR.content[0].path);
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-services / src / contents / index.spec.ts View on Github external
it('should emit the fileChanged signal', async () => {
      const drive = new Drive();
      handleRequest(drive, 201, DEFAULT_FILE);
      let called = false;
      drive.fileChanged.connect((sender, args) => {
        expect(args.type).to.equal('new');
        expect(args.oldValue).to.be.null;
        expect(args.newValue.path).to.equal(DEFAULT_FILE.path);
        called = true;
      });
      await drive.copy('/foo/bar.txt', '/baz');
      expect(called).to.equal(true);
    });
github jupyterlab / jupyterlab / tests / test-services / src / contents / index.spec.ts View on Github external
it('should create a new file', async () => {
      const drive = new Drive();
      handleRequest(drive, 201, DEFAULT_FILE);
      const save = drive.save('/foo', { type: 'file', name: 'test' });
      const model = await save;
      expect(model.created).to.equal(DEFAULT_FILE.created);
    });