summaryrefslogtreecommitdiff
path: root/test/toxbank-investigation-xls.rb
blob: 486003e6de55cc1c1a72bb3c7f4d753acfb94b09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require_relative "toxbank-setup.rb"

class ExcelUploadTest < MiniTest::Test

  def setup
    @tmpdir = File.join(File.dirname(__FILE__),"tmp")
    FileUtils.mkdir_p @tmpdir
    FileUtils.rm_r Dir[File.join @tmpdir, '*']
  end

  def test_01_invalid_xls_upload 
    # upload
    OpenTox::RestClientWrapper.subjectid = $pi[:subjectid]
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/invalid/isa_TB_ACCUTOX.xls"
    response = `curl -Lk -X POST -i -F file="@#{file};type=application/vnd.ms-excel" -H "subjectid:#{$pi[:subjectid]}" #{$investigation[:uri]}`.chomp
    assert_match /202/, response
    uri = response.split("\n")[-1]
    t = OpenTox::Task.new(uri)
    t.wait
    puts t.uri
    assert_match t.hasStatus, "Error"
  end
  
  def test_02_valid_xls_upload
    # upload
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid/BII-I-1-tb2.xls"
    response = `curl -Lk -X POST -i -F file="@#{file};type=application/vnd.ms-excel" -H "subjectid:#{$pi[:subjectid]}" #{$investigation[:uri]}`.chomp
    assert_match /202/, response
    uri = response.split("\n")[-1]
    t = OpenTox::Task.new(uri)
    t.wait
    puts t.uri
    assert_match t.hasStatus, "Error"
  end
end