Sha256: 07be9fea99697b9f38026e062628132f6813d9f853d0eb59315ae5148435b6ff

Contents?: true

Size: 1.68 KB

Versions: 4

Compression:

Stored size: 1.68 KB

Contents

require 'test_helper'
require 'vcr_setup.rb'

class StoringMATExportPackageTest < ActiveSupport::TestCase

  setup do
    @cql_mat_export = File.new File.join('test', 'fixtures', 'CMS158_v5_4_Artifacts.zip')
  end

  test "Loading a MAT package, confirming the contents of the MAT package are viewable and stored correctly" do
    VCR.use_cassette("valid_vsac_response_158") do
      dump_db
      user = User.new
      user.save

      measure_details = { 'episode_of_care'=> false }
      Measures::CqlLoader.load(@cql_mat_export, user, measure_details, ENV['VSAC_USERNAME'], ENV['VSAC_PASSWORD']).save
      assert_equal 1, CqlMeasure.all.count
      measure = CqlMeasure.all.first
      assert_equal "Test 158", measure.title

      assert_equal 1, CqlMeasurePackage.all.count
      measure_package = CqlMeasurePackage.all.first
      assert_equal measure.id, measure_package.measure_id

      Dir.mktmpdir do |dir|
        # Write the package to a temp directory
        File.open(File.join(dir, measure.measure_id + '.zip'), 'wb') do |zip_file|
          # Write the package binary to a zip file.
          zip_file.write(measure_package.file.data)
          Zip::ZipFile.open(zip_file.path) do |file|
            cql_files = file.glob(File.join('**','**.cql')).select {|x| !x.name.starts_with?('__MACOSX') }
            xml_files = file.glob(File.join('**','**.xml')).select {|x| !x.name.starts_with?('__MACOSX') }
            json_files = file.glob(File.join('**','**.json')).select {|x| !x.name.starts_with?('__MACOSX') }

            assert_equal 1, cql_files.count
            assert_equal 2, xml_files.count
            assert_equal 1, json_files.count
          end
        end
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bonnie_bundler-2.0.3 test/unit/storing_mat_export_package_test.rb
bonnie_bundler-2.0.2 test/unit/storing_mat_export_package_test.rb
bonnie_bundler-2.0.1 test/unit/storing_mat_export_package_test.rb
bonnie_bundler-2.0.0 test/unit/storing_mat_export_package_test.rb