<commit_before>require 'spec_helper'

describe Fission::VM do
  before do
    @vm = Fission::VM.new('foo')
    @conf_file_path = File.join(@vm.path, 'foo.vmx')
    @vmrun_cmd = Fission.config['vmrun_cmd']
    @conf_file_response_mock = mock('conf_file_response')
  end

  describe 'new' do
    it 'should set the vm name' do
      Fission::VM.new('foo').name.should == 'foo'
    end
  end

  describe 'delete' do
    before do
      @vm_deleter           = mock 'vm deleter'
      @delete_response_mock = mock 'vm delete response'
      Fission::Action::VM::Deleter.stub(:new).and_return(@vm_deleter)
    end

    it 'should return an unsuccessful response when unable to delete the vm' do
      @vm_deleter.should_receive(:delete).
                  and_return(@delete_response_mock)
      @delete_response_mock.stub_as_unsuccessful
      @vm.delete.should be_an_unsuccessful_response
    end

    it 'should return a successful response when deleting' do
      @vm_deleter.should_receive(:delete).
                  and_return(@delete_response_mock)
      @delete_response_mock.stub_as_successful
      @vm.delete.should be_a_successful_response
    end
  end

  describe 'start' do
    before do
      @vm_starter          = mock 'vm starter'
      @start_response_mock = mock 'vm start response'
      Fission::Action::VM::Starter.stub(:new).and_return(@vm_starter)
    end

    it 'should return an unsuccessful response when unable to start the vm' do
      @vm_starter.should_receive(:start).
                  and_return(@start_response_mock)
      @start_response_mock.stub_as_unsuccessful
      @vm.start.should be_an_unsuccessful_response
    end

    it 'should return a successful response when starting headless' do
      @vm_starter.should_receive(:start).
                  with(:headless => true).
                  and_return(@start_response_mock)
      @start_response_mock.stub_as_successful
      @vm.start(:headless => true).should be_a_successful_response
    end

    it 'should return a successful response when starting' do
      @vm_starter.should_receive(:start).
                  and_return(@start_response_mock)
      @start_response_mock.stub_as_successful
      @vm.start.should be_a_successful_response
    end
  end

  describe 'stop' do
    before do
      @vm_stopper         = mock 'vm stopper'
      @stop_response_mock = mock 'vm stop response'
      Fission::Action::VM::Stopper.stub(:new).and_return(@vm_stopper)
    end

    it 'should return a successful response when stopping' do
      @vm_stopper.should_receive(:stop).
                  and_return(@stop_response_mock)
      @stop_response_mock.stub_as_successful
      @vm.stop.should be_a_successful_response
    end

    it 'should return an unsuccessful response when unable to stop the vm' do
      @vm_stopper.should_receive(:stop).
                  and_return(@stop_response_mock)
      @stop_response_mock.stub_as_unsuccessful
      @vm.stop.should be_an_unsuccessful_response
    end

    it 'should return a successful response when stopping hard' do
      @vm_stopper.should_receive(:stop).
                  with(:hard => true).
                  and_return(@stop_response_mock)
      @stop_response_mock.stub_as_successful
      @vm.stop(:hard => true).should be_a_successful_response
    end
  end

  describe 'suspend' do
    before do
      @vm_suspender          = mock 'vm suspender'
      @suspend_response_mock = mock 'vm suspend response'
      Fission::Action::VM::Suspender.stub(:new).and_return(@vm_suspender)
    end

    it 'should return a successful response when suspending' do
      @vm_suspender.should_receive(:suspend).
                    and_return(@suspend_response_mock)
      @suspend_response_mock.stub_as_successful
      @vm.suspend.should be_a_successful_response
    end

    it 'should return an unsuccessful response when unable to suspend the vm' do
      @vm_suspender.should_receive(:suspend).
                    and_return(@suspend_response_mock)
      @suspend_response_mock.stub_as_unsuccessful
      @vm.suspend.should be_an_unsuccessful_response
    end
  end

  describe 'snapshots' do
    before do
      @snapshot_lister_mock = mock 'snapshot lister'
      @snapshots_response_mock = mock 'snapshots mock'
      Fission::Action::Snapshot::Lister.stub(:new).and_return(@snapshot_lister_mock)
      @snapshot_lister_mock.should_receive(:snapshots).
                            and_return(@snapshots_response_mock)
    end
<commit_msg>minor clean up of VM spec<commit_after>require 'spec_helper'

describe Fission::VM do
  before do
    @vm = Fission::VM.new('foo')
    @conf_file_path = File.join(@vm.path, 'foo.vmx')
    @vmrun_cmd = Fission.config['vmrun_cmd']
    @conf_file_response_mock = mock('conf_file_response')
  end

  describe 'new' do
    it 'should set the vm name' do
      Fission::VM.new('foo').name.should == 'foo'
    end
  end

  describe 'delete' do
    before do
      @vm_deleter           = mock 'vm deleter'
      @delete_response_mock = mock 'vm delete response'
      Fission::Action::VM::Deleter.stub(:new).and_return(@vm_deleter)
      @vm_deleter.should_receive(:delete).
                  and_return(@delete_response_mock)
    end

    it 'should return an unsuccessful response when unable to delete the vm' do
      @delete_response_mock.stub_as_unsuccessful
      @vm.delete.should be_an_unsuccessful_response
    end

    it 'should return a successful response when deleting' do
      @delete_response_mock.stub_as_successful
      @vm.delete.should be_a_successful_response
    end
  end

  describe 'start' do
    before do
      @vm_starter          = mock 'vm starter'
      @start_response_mock = mock 'vm start response'
      Fission::Action::VM::Starter.stub(:new).and_return(@vm_starter)
    end

    it 'should return an unsuccessful response when unable to start the vm' do
      @vm_starter.should_receive(:start).
                  and_return(@start_response_mock)
      @start_response_mock.stub_as_unsuccessful
      @vm.start.should be_an_unsuccessful_response
    end

    it 'should return a successful response when starting headless' do
      @vm_starter.should_receive(:start).
                  with(:headless => true).
                  and_return(@start_response_mock)
      @start_response_mock.stub_as_successful
      @vm.start(:headless => true).should be_a_successful_response
    end

    it 'should return a successful response when starting' do
      @vm_starter.should_receive(:start).
                  and_return(@start_response_mock)
      @start_response_mock.stub_as_successful
      @vm.start.should be_a_successful_response
    end
  end

  describe 'stop' do
    before do
      @vm_stopper         = mock 'vm stopper'
      @stop_response_mock = mock 'vm stop response'
      Fission::Action::VM::Stopper.stub(:new).and_return(@vm_stopper)
    end

    it 'should return a successful response when stopping' do
      @vm_stopper.should_receive(:stop).
                  and_return(@stop_response_mock)
      @stop_response_mock.stub_as_successful
      @vm.stop.should be_a_successful_response
    end

    it 'should return an unsuccessful response when unable to stop the vm' do
      @vm_stopper.should_receive(:stop).
                  and_return(@stop_response_mock)
      @stop_response_mock.stub_as_unsuccessful
      @vm.stop.should be_an_unsuccessful_response
    end

    it 'should return a successful response when stopping hard' do
      @vm_stopper.should_receive(:stop).
                  with(:hard => true).
                  and_return(@stop_response_mock)
      @stop_response_mock.stub_as_successful
      @vm.stop(:hard => true).should be_a_successful_response
    end
  end

  describe 'suspend' do
    before do
      @vm_suspender          = mock 'vm suspender'
      @suspend_response_mock = mock 'vm suspend response'
      Fission::Action::VM::Suspender.stub(:new).and_return(@vm_suspender)
      @vm_suspender.should_receive(:suspend).
                    and_return(@suspend_response_mock)
    end

    it 'should return a successful response when suspending' do
      @suspend_response_mock.stub_as_successful
      @vm.suspend.should be_a_successful_response
    end

    it 'should return an unsuccessful response when unable to suspend the vm' do
      @suspend_response_mock.stub_as_unsuccessful
      @vm.suspend.should be_an_unsuccessful_response
    end
  end

  describe 'snapshots' do
    before do
      @snapshot_lister_mock = mock 'snapshot lister'
      @snapshots_response_mock = mock 'snapshots mock'
      Fission::Action::Snapshot::Lister.stub(:new).and_return(@snapshot_lister_mock)
      @snapshot_lister_mock.should_receive(:snapshots).
                            and_return(@snapshots_response_mock)
    end

{'fraction_non_alphanumeric': 0.08166515013648772, 'fraction_numerical': 0.0, 'mean_word_length': 2.9679602888086642, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4590706', 'n_tokens_mistral': 2658, 'n_tokens_neox': 2652, 'n_words': 581}