<commit_before>import { expect } from 'chai';

const Rx = require('rxjs/Rx');

const EventEmitter = require('events');

import * as constants from '../../../src/notebook/constants';

import {
  setLanguageInfo,
  acquireKernelInfo,
} from '../../../src/notebook/epics/kernelLaunch';

import {
  createMessage,
} from '../../../src/notebook/api/messaging';

describe('setLanguageInfo', () => {
  it('creates a SET_LANGUAGE_INFO action', () => {
    const langInfo = {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name":"python",
      "nbconvert_exporter":"python",
      "pygments_lexer":"ipython3",
      "version":"3.5.1",
    };

    expect(setLanguageInfo(langInfo)).to.deep.equal({
      type: constants.SET_LANGUAGE_INFO,
      langInfo: langInfo,
    });
  })
});

describe('acquireKernelInfo', () => {
  it('sends a kernel_info_request and processes kernel_info_reply', (done) => {
    const fakeMessage = {
      parent_header: {
        msg_id: '0',
      },
      header: {
        msg_id: '1',
      },
    }

    const sent = new Rx.Subject();
    const received = new Rx.Subject();

    const mockSocket = Rx.Subject.create(sent, received);

    sent.subscribe((msg) => {
      expect(msg.header.msg_type).to.equal('kernel_info_request');

      const response = createMessage('kernel_info_reply');
      response.parent_header = msg.header;
      response.content = {
        language_info: {
          'language': 'python',
        }
      }

      // TODO: Get the Rx handling proper here
      setTimeout(() => received.next(response), 100);
    })

    const obs = acquireKernelInfo({shell: mockSocket});

    obs.subscribe((langAction) => {
      expect(langAction).to.deep.equal({
        'langInfo': {'language': 'python'},
        type: 'SET_LANGUAGE_INFO'
      })
      done();
    })
  })
})
<commit_msg>pass an actions observable on through<commit_after>import { expect } from 'chai';

const Rx = require('rxjs/Rx');

const EventEmitter = require('events');

import { ActionsObservable } from 'redux-observable';

import * as constants from '../../../src/notebook/constants';

import {
  setLanguageInfo,
  acquireKernelInfo,
  watchExecutionStateEpic,
} from '../../../src/notebook/epics/kernelLaunch';

import {
  createMessage,
} from '../../../src/notebook/api/messaging';

describe('setLanguageInfo', () => {
  it('creates a SET_LANGUAGE_INFO action', () => {
    const langInfo = {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name":"python",
      "nbconvert_exporter":"python",
      "pygments_lexer":"ipython3",
      "version":"3.5.1",
    };

    expect(setLanguageInfo(langInfo)).to.deep.equal({
      type: constants.SET_LANGUAGE_INFO,
      langInfo: langInfo,
    });
  })
});

describe('acquireKernelInfo', () => {
  it('sends a kernel_info_request and processes kernel_info_reply', (done) => {
    const fakeMessage = {
      parent_header: {
        msg_id: '0',
      },
      header: {
        msg_id: '1',
      },
    }

    const sent = new Rx.Subject();
    const received = new Rx.Subject();

    const mockSocket = Rx.Subject.create(sent, received);

    sent.subscribe((msg) => {
      expect(msg.header.msg_type).to.equal('kernel_info_request');

      const response = createMessage('kernel_info_reply');
      response.parent_header = msg.header;
      response.content = {
        language_info: {
          'language': 'python',
        }
      }

      // TODO: Get the Rx handling proper here
      setTimeout(() => received.next(response), 100);
    })

    const obs = acquireKernelInfo({shell: mockSocket});

    obs.subscribe((langAction) => {
      expect(langAction).to.deep.equal({
        'langInfo': {'language': 'python'},
        type: 'SET_LANGUAGE_INFO'
      })
      done();
    })
  })
})

describe('watchExecutionStateEpic', () => {
  it('returns an Observable with an initial state of idle', () => {
    const action$ = new ActionsObservable();
    const obs = watchExecutionStateEpic(action$);
  })
})

{'fraction_non_alphanumeric': 0.16619115549215407, 'fraction_numerical': 0.004755111745126011, 'mean_word_length': 2.7395555555555555, 'pattern_counts': {'":': 18, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '660443', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1315, 'n_words': 247}