summaryrefslogtreecommitdiff
path: root/toxcreate.rb
blob: 5a995e202eebc535e5ff676ec60bb96d4a94fa89 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
require 'rubygems'
require "rubygems"
require 'opentox-ruby'
require 'test/unit'
require 'watir-webdriver'

class ToxCreateTest < Test::Unit::TestCase
  def setup
    @browser = Watir::Browser.new :firefox
    @user = "test_ch"
    @password = "test_ch"
  end
  
=begin
  def test_login
    @browser.goto File.join(CONFIG[:services]["opentox-toxcreate"], "login")
    @browser.button(:value, "Login").click
    puts "Login without credentials"    
    assert @browser.text.include? "Please enter username and password."
    @browser.text_field(:id, "username").set(@user)
    @browser.text_field(:id, "password").set(@password + "nonsense")
    @browser.button(:value, "Login").click
    puts "Login with wrong password"
    assert @browser.text.include? "Login failed. Please try again." 
    @browser.text_field(:id, "username").set(@user)
    @browser.text_field(:id, "password").set(@password)
    @browser.button(:value, "Login").click
    puts "Login as user #{@user}"
    assert @browser.text.include? "Welcome #{@user}!"
    @browser.goto File.join(CONFIG[:services]["opentox-toxcreate"], "login")
    @browser.button(:value, "Login as guest").click
    puts "Login as user guest"    
    assert @browser.text.include? "Welcome guest!"
    @browser.close    
  end


  def teardown
    @browser.close
  end


  def test_toxcreate
    login(@browser, @user, @password)
    @browser.goto CONFIG[:services]["opentox-toxcreate"]
    @browser.file_field(:id, "file").set(`pwd`.chomp+"/data/hamster_carcinogenicity.csv")
    @browser.button(:value, "Create model").click
    # wait until validation is completed
    # check results (links, reports, results)
    puts @browser.url
  end
=end
=begin
  def test_multi_cell_call
    login(@browser, @user, @password)
    @browser.goto CONFIG[:services]["opentox-toxcreate"]
    @browser.file_field(:id, "file").set(`pwd`.chomp+"/data/multi_cell_call.csv")
    @browser.button(:value, "Create model").click
    # wait until validation is completed
    # check results (links, reports, results)
    puts @browser.url
  end

  def test_kazius
    login(@browser, @user, @password)
    @browser.goto CONFIG[:services]["opentox-toxcreate"]
    @browser.file_field(:id, "file").set(`pwd`.chomp+"/data/kazius.csv")
    @browser.button(:value, "Create model").click
    # wait until validation is completed
    # check results (links, reports, results)
    puts @browser.url
  end

  def test_parallel_models
    login(@browser, @user, @password)
    10.times do
      @browser.goto CONFIG[:services]["opentox-toxcreate"]
      @browser.file_field(:id, "file").set(`pwd`.chomp+"/data/hamster_carcinogenicity.csv")
      @browser.button(:value, "Create model").click
    end
    #@browser.close
  end
=end
end

def login(browser, user, password)
  browser.goto File.join(CONFIG[:services]["opentox-toxcreate"], "login")
  browser.text_field(:id, "username").set(user)
  browser.text_field(:id, "password").set(password)
  browser.button(:value, "Login").click
end