<commit_before>require "spec_helper"

describe MoovAtom::MoovEngine do
  before do
    @args = {
      username: 'jsmith',
      userkey: '123',
      guid: '456',
      title: 'Test Video Title',
      blurb: 'A Short description about the video.',
      sourcefile: 'http://example.com/path/to/file/test.mp4',
      callbackurl: 'http://example.com/job_complete'
    }

    @moov_engine = MoovAtom::MoovEngine.new @args
  end

  after do
    FakeWeb.clean_registry
  end

  describe "Details request..." do
    it "gets the details of an existing video" do
      xml = File.join(File.dirname(__FILE__), 'fixtures', 'detail.xml')
      FakeWeb.register_uri(:post, MoovAtom::API_URL, :body => xml)
      xml_res = @moov_engine.details
      xml_res.body.must_include "<uuid>456</uuid>"
      xml_res.body.must_include "<versions>"
    end
  end

  describe "Status request success..." do
    it "handles a successful status request" do
      xml = File.join(File.dirname(__FILE__), 'fixtures', 'status_success.xml')
      FakeWeb.register_uri(:post, MoovAtom::API_URL, :body => xml)
      xml_res = @moov_engine.status
      xml_res.body.must_include "<uuid>456</uuid>"
      xml_res.body.must_include "<processing>True</processing>"
      xml_res.body.must_include "<error></error>"
    end
  end

  describe "Status request error..." do
    it "handles an unsuccessful status request" do
      xml = File.join(File.dirname(__FILE__), 'fixtures', 'status_error.xml')
      FakeWeb.register_uri(:post, MoovAtom::API_URL, :body => xml)
      xml_res = @moov_engine.status
      xml_res.body.must_include "<uuid>456</uuid>"
      xml_res.body.must_include "<processing>False</processing>"
      xml_res.body.must_include "<error>This was not a recognized format.</error>"
    end
  end

  describe "Encode request..." do
    it "starts encoding a new video" do
      xml = File.join(File.dirname(__FILE__), 'fixtures', 'encode.xml')
      FakeWeb.register_uri(:post, MoovAtom::API_URL, :body => xml)
      xml_res = @moov_engine.encode
      xml_res.must_equal "456"
    end
  end

  describe "Cancel request..." do
    it "cancels the encoding of an existing video" do
      xml = File.join(File.dirname(__FILE__), 'fixtures', 'cancel.xml')
      FakeWeb.register_uri(:post, MoovAtom::API_URL, :body => xml)
      xml_res = @moov_engine.cancel
      xml_res.body.must_include "<uuid>456</uuid>"
      xml_res.body.must_include "<message>This job was successfully cancelled.</message>"
    end
  end
end

<commit_msg>removed the code that runs before each test in request_spec.rb<commit_after>require "spec_helper"

describe MoovAtom::MoovEngine do
  before do
  end

  after do
    FakeWeb.clean_registry
  end

  describe "Details request..." do
    it "gets the details of an existing video" do
      xml = File.join(File.dirname(__FILE__), 'fixtures', 'detail.xml')
      FakeWeb.register_uri(:post, MoovAtom::API_URL, :body => xml)
      xml_res = @moov_engine.details
      xml_res.body.must_include "<uuid>456</uuid>"
      xml_res.body.must_include "<versions>"
    end
  end

  describe "Status request success..." do
    it "handles a successful status request" do
      xml = File.join(File.dirname(__FILE__), 'fixtures', 'status_success.xml')
      FakeWeb.register_uri(:post, MoovAtom::API_URL, :body => xml)
      xml_res = @moov_engine.status
      xml_res.body.must_include "<uuid>456</uuid>"
      xml_res.body.must_include "<processing>True</processing>"
      xml_res.body.must_include "<error></error>"
    end
  end

  describe "Status request error..." do
    it "handles an unsuccessful status request" do
      xml = File.join(File.dirname(__FILE__), 'fixtures', 'status_error.xml')
      FakeWeb.register_uri(:post, MoovAtom::API_URL, :body => xml)
      xml_res = @moov_engine.status
      xml_res.body.must_include "<uuid>456</uuid>"
      xml_res.body.must_include "<processing>False</processing>"
      xml_res.body.must_include "<error>This was not a recognized format.</error>"
    end
  end

  describe "Encode request..." do
    it "starts encoding a new video" do
      xml = File.join(File.dirname(__FILE__), 'fixtures', 'encode.xml')
      FakeWeb.register_uri(:post, MoovAtom::API_URL, :body => xml)
      xml_res = @moov_engine.encode
      xml_res.must_equal "456"
    end
  end

  describe "Cancel request..." do
    it "cancels the encoding of an existing video" do
      xml = File.join(File.dirname(__FILE__), 'fixtures', 'cancel.xml')
      FakeWeb.register_uri(:post, MoovAtom::API_URL, :body => xml)
      xml_res = @moov_engine.cancel
      xml_res.body.must_include "<uuid>456</uuid>"
      xml_res.body.must_include "<message>This job was successfully cancelled.</message>"
    end
  end
end


{'fraction_non_alphanumeric': 0.12721518987341773, 'fraction_numerical': 0.007805907172995781, 'mean_word_length': 3.361545538178473, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 62}, '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': '4585455', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1520, 'n_words': 364}