Class: TestOddbApp

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
FlexMock::TestCase
Defined in:
test/test_util/oddbapp.rb

Defined Under Namespace

Classes: StubAtcClass, StubAtcClassFactory, StubCompany, StubGalenicForm, StubGalenicGroup, StubIndication, StubRegistration, StubRegistration2, StubSequence, StubSession, StubSession2, StubSubstance

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) same?(o1, o2)

Returns:

  • (Boolean)


1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
# File 'test/test_util/oddbapp.rb', line 1057

def same?(o1, o2)
=begin
  #result1.atc_classes   == result2.atc_classes   and\
  result1.atc_classes.size == result2.atc_classes.size  and\
  result1.search_type      == result2.search_type   and\
  result1.display_limit    == result2.display_limit and\
  result1.relevance        == result2.relevance     and\
  result1.search_query     == result2.search_query
=end


  h1 = {}
  h2 = {}
=begin
  p o1
  p o2
  gets
=end


  if o1.instance_variables.sort == o2.instance_variables.sort
    o1.instance_variables.each do |v|
      if v.to_s == '@atc_classes' # actually atc_classes should also be checked
        h1[v.to_sym] = o1.atc_classes.size
        h2[v.to_sym] = o2.atc_classes.size
      else
        h1[v.to_sym] = o1.instance_variable_get(v)
        h2[v.to_sym] = o2.instance_variable_get(v)
      end
    end
  else
    return false
  end
  return (h1 == h2)
end

- (Object) setup



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'test/test_util/oddbapp.rb', line 176

def setup
  ODDB::GalenicGroup.reset_oids
  ODBA.storage.reset_id
  dir = File.expand_path('../data/prevalence', File.dirname(__FILE__))
  @app = ODDB::App.new

  @session = flexmock('session') do |ses|
    ses.should_receive(:grant).once.with('name', 'key', 'item', 'expires')\
      .and_return('session')
    ses.should_receive(:entity_allowed?).once.with('email', 'action', 'key')\
      .and_return('session')
    ses.should_receive(:create_entity).once.with('email', 'pass')\
      .and_return('session')
    ses.should_receive(:get_entity_preference).once.with('name', 'key')\
      .and_return('session')
    ses.should_receive(:get_entity_preference).once.with('name', 'association')\
      .and_return('odba_id')
    ses.should_receive(:get_entity_preferences).once.with('name', 'keys')\
      .and_return('session')
    ses.should_receive(:get_entity_preferences).once.with('error', 'error')\
      .and_raise(Yus::YusError)
    ses.should_receive(:reset_entity_password).once.with('name', 'token', 'password')\
      .and_return('session')
    ses.should_receive(:set_entity_preference).once.with('name', 'key', 'value', 'domain')\
      .and_return('session')
  end
  flexmock(ODDB::App::YUS_SERVER) do |yus|
    yus.should_receive(:autosession).and_yield(@session)
  end
  flexstub(ODBA.storage) do |sto|
    sto.should_receive(:remove_dictionary)
    sto.should_receive(:generate_dictionary).once.with('language', 'locale', String)\
      .and_return('generate_dictionary')
    sto.should_receive(:generate_dictionary).once.with('french', 'fr_FR@euro', String)\
      .and_return('french_dictionary')
    sto.should_receive(:generate_dictionary).once.with('german', 'de_DE@euro', String)\
      .and_return('german_dictionary')
  end
end

- (Object) setup_assign_effective_forms



1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
# File 'test/test_util/oddbapp.rb', line 1352

def setup_assign_effective_forms
  sequence = flexmock('sequence') do |seq|
    seq.should_receive(:delete_active_agent)
    seq.should_receive(:"active_agents.odba_isolated_store")
  end
  @substance = flexmock('substance') do |sub|
    sub.should_receive(:has_effective_form?).and_return(false)
    sub.should_receive(:name).and_return('name')
    sub.should_receive(:to_s).and_return('name')
    sub.should_receive(:effective_form=)
    sub.should_receive(:odba_store)
    sub.should_receive(:odba_delete)
    sub.should_receive(:sequences).and_return([sequence])
  end
  @app.substances = [@substance]
end

- (Object) setup_create_commercial_forms



1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
# File 'test/test_util/oddbapp.rb', line 1184

def setup_create_commercial_forms
  flexstub(@app) do |app|
    app.should_receive(:system).and_return(@app.instance_eval('@system'))
  end
  flexstub(@app.system) do |sys|
    sys.should_receive(:update)
  end
  package = flexmock('package') do |pac|
    pac.should_receive(:comform).and_return('possibility')
    pac.should_receive(:commercial_form=)
    pac.should_receive(:odba_store)
  end
  @registration = flexmock('registration') do |reg|
    reg.should_receive(:each_package).and_yield(package)
  end
  @app.registrations = {'12345' => @registration}
end

- (Object) teardown



215
216
217
# File 'test/test_util/oddbapp.rb', line 215

def teardown
  ODBA.storage = nil
end

- (Object) test__admin



1890
1891
1892
# File 'test/test_util/oddbapp.rb', line 1890

def test__admin
  assert_kind_of(Thread, @app._admin('"src"', 'result'))
end

- (Object) test__admin__str200



1893
1894
1895
# File 'test/test_util/oddbapp.rb', line 1893

def test__admin__str200
  assert_kind_of(Thread, @app._admin('"a"*201', 'result'))
end

- (Object) test__clean_odba_stubs_array



1575
1576
1577
1578
1579
1580
# File 'test/test_util/oddbapp.rb', line 1575

def test__clean_odba_stubs_array
  value = flexmock('val') do |val|
    val.should_receive(:"odba_instance.nil?").and_return(true)
  end
  assert_equal([], @app._clean_odba_stubs_array([value]))
end

- (Object) test__clean_odba_stubs_hash



1569
1570
1571
1572
1573
1574
# File 'test/test_util/oddbapp.rb', line 1569

def test__clean_odba_stubs_hash
  value = flexmock('val') do |val|
    val.should_receive(:"odba_instance.nil?").and_return(true)
  end
  assert_equal({}, @app._clean_odba_stubs_hash({'value' => value}))
end

- (Object) test__search_exact_classified_result



1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
# File 'test/test_util/oddbapp.rb', line 1693

def test__search_exact_classified_result
  sequence = flexmock('sequence') do |seq|
    seq.should_receive(:atc_class)
  end
  expected = ODDB::SearchResult.new
  expected.atc_classes = ['atc']
  expected.search_type = :unknown
  #assert_equal(expected, @app._search_exact_classified_result([sequence]))
  assert(same?(expected, @app._search_exact_classified_result([sequence])))
end

- (Object) test_accept_orphaned



1457
1458
1459
1460
1461
1462
1463
1464
1465
# File 'test/test_util/oddbapp.rb', line 1457

def test_accept_orphaned
  flexstub(@app) do |app|
    app.should_receive(:system).and_return(@app.instance_eval('@system'))
  end
  flexstub(@app.system) do |sys|
    sys.should_receive(:execute_command)
  end
  assert_equal(nil, @app.accept_orphaned('orphan', 'pointer', :symbol))
end

- (Object) test_active_fachinfos



922
923
924
925
926
927
928
929
930
# File 'test/test_util/oddbapp.rb', line 922

def test_active_fachinfos
  registration = flexmock('registration') do |reg|
    reg.should_receive(:active?).and_return(true)
    reg.should_receive(:fachinfo).and_return(true)
    reg.should_receive(:pointer).and_return('registration')
  end
  @app.registrations = {'registration' => registration}
  assert_equal({'registration' => 1}, @app.active_fachinfos)
end

- (Object) test_active_pdf_patinfos



931
932
933
934
935
936
937
938
939
940
# File 'test/test_util/oddbapp.rb', line 931

def test_active_pdf_patinfos
  sequence = flexmock('sequence') do |seq|
    seq.should_receive(:active_patinfo).and_return('active_patinfo')
  end
  registration = flexmock('registration') do |reg|
    reg.should_receive(:each_sequence).and_yield(sequence)
  end
  @app.registrations = {'1' => registration}
  assert_equal({"active_patinfo"=>1}, @app.active_pdf_patinfos)
end

- (Object) test_address_suggestion



941
942
943
# File 'test/test_util/oddbapp.rb', line 941

def test_address_suggestion
  assert_equal(nil, @app.address_suggestion('12345'))
end

- (Object) test_admin



1469
1470
1471
1472
# File 'test/test_util/oddbapp.rb', line 1469

def test_admin
  @app.users = {123 => 'user'}
  assert_equal('user', @app.admin('123'))
end

- (Object) test_admin_subsystem



1817
1818
1819
1820
1821
1822
# File 'test/test_util/oddbapp.rb', line 1817

def test_admin_subsystem
  flexstub(ODDB::Admin::Subsystem) do |sys|
    sys.should_receive(:new).and_return('admin_subsystem')
  end
  assert_equal('admin_subsystem', @app.admin_subsystem)
end

- (Object) test_analysis_count



1163
1164
1165
# File 'test/test_util/oddbapp.rb', line 1163

def test_analysis_count
  assert_equal(0, @app.analysis_count)
end

- (Object) test_analysis_group



944
945
946
# File 'test/test_util/oddbapp.rb', line 944

def test_analysis_group
  assert_equal(nil, @app.analysis_group(0))
end

- (Object) test_analysis_positions



947
948
949
# File 'test/test_util/oddbapp.rb', line 947

def test_analysis_positions
  assert_equal([], @app.analysis_positions)
end

- (Object) test_assign_effective_forms__d



1396
1397
1398
1399
1400
1401
1402
# File 'test/test_util/oddbapp.rb', line 1396

def test_assign_effective_forms__d
  def $stdin.readline
    'd'
  end
  setup_assign_effective_forms
  assert_equal(nil, @app.assign_effective_forms)
end

- (Object) test_assign_effective_forms__else



1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
# File 'test/test_util/oddbapp.rb', line 1417

def test_assign_effective_forms__else
  def $stdin.readline
    'abc'
  end
  setup_assign_effective_forms
  flexstub(@app) do |app|
    app.should_receive(:system).and_return(@app.instance_eval('@system'))
  end
  flexstub(@app.system) do |sys|
    sys.should_receive(:substance).and_return(@substance)
  end
  assert_equal(nil, @app.assign_effective_forms)
end

- (Object) test_assign_effective_forms__n



1368
1369
1370
1371
1372
1373
1374
# File 'test/test_util/oddbapp.rb', line 1368

def test_assign_effective_forms__n
  def $stdin.readline
    'n'
  end
  setup_assign_effective_forms
  assert_equal(nil, @app.assign_effective_forms)
end

- (Object) test_assign_effective_forms__other_name



1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
# File 'test/test_util/oddbapp.rb', line 1403

def test_assign_effective_forms__other_name
  setup_assign_effective_forms
  flexstub(@app) do |app|
    app.should_receive(:system).and_return(@app.instance_eval('@system'))
  end
  flexstub(@app.system) do |sys|
    sys.should_receive(:update).and_return(@substance)
  end

  def $stdin.readline
    'c abc'
  end
  assert_equal(nil, @app.assign_effective_forms)
end

- (Object) test_assign_effective_forms__q



1389
1390
1391
1392
1393
1394
1395
# File 'test/test_util/oddbapp.rb', line 1389

def test_assign_effective_forms__q
  def $stdin.readline
    'q'
  end
  setup_assign_effective_forms
  assert_equal(nil, @app.assign_effective_forms)
end

- (Object) test_assign_effective_forms__s



1382
1383
1384
1385
1386
1387
1388
# File 'test/test_util/oddbapp.rb', line 1382

def test_assign_effective_forms__s
  def $stdin.readline
    's'
  end
  setup_assign_effective_forms
  assert_equal(nil, @app.assign_effective_forms)
end

- (Object) test_assign_effective_forms__S



1375
1376
1377
1378
1379
1380
1381
# File 'test/test_util/oddbapp.rb', line 1375

def test_assign_effective_forms__S
  def $stdin.readline
    'S'
  end
  setup_assign_effective_forms
  assert_equal(nil, @app.assign_effective_forms)
end

- (Object) test_async



764
765
766
767
768
769
770
771
772
773
# File 'test/test_util/oddbapp.rb', line 764

def test_async
  foo = "bar"
  @app.async {
    sleep 0.5
    foo = "baz"
  }
  assert_equal("bar", foo)
  sleep 1
  assert_equal("baz", foo)
end

- (Object) test_atc_ddd_count



1142
1143
1144
# File 'test/test_util/oddbapp.rb', line 1142

def test_atc_ddd_count
  assert_equal(0, @app.atc_ddd_count)
end

- (Object) test_clean



1466
1467
1468
# File 'test/test_util/oddbapp.rb', line 1466

def test_clean
  assert_equal(nil, @app.clean)
end

- (Object) test_clean_invoices



1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
# File 'test/test_util/oddbapp.rb', line 1915

def test_clean_invoices
  flexstub(@app) do |app|
    app.should_receive(:system).and_return(@app.instance_eval('@system'))
  end
  flexstub(@app.system) do |sys|
    sys.should_receive(:delete)
  end
  invoice = flexmock('invoice') do |inv|
    inv.should_receive(:odba_instance_nil?)
    inv.should_receive(:deletable?).and_return(true)
    inv.should_receive(:pointer)
  end
  @app.invoices = {'oid' => invoice}
  assert_equal(nil, @app.clean_invoices)
end

- (Object) test_clean_odba_stubs



1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
# File 'test/test_util/oddbapp.rb', line 1581

def test_clean_odba_stubs
  sequence = flexmock('sequence') do |seq|
    seq.should_receive(:packages).and_return({})
    seq.should_receive(:active_agents).and_return([])
  end
  registration = flexmock('registration') do |reg|
    reg.should_receive(:sequences).and_return({'key' => sequence})
  end
  @app.registrations = {'key' => registration}
  assert_equal({'key' => registration}, @app.clean_odba_stubs)
end

- (Object) test_commercial_form



1845
1846
1847
1848
# File 'test/test_util/oddbapp.rb', line 1845

def test_commercial_form
  @app.commercial_forms = {123 => 'commercial_form'}
  assert_equal('commercial_form', @app.commercial_form('123'))
end

- (Object) test_commercial_form_by_name



1849
1850
1851
# File 'test/test_util/oddbapp.rb', line 1849

def test_commercial_form_by_name
  assert_equal(nil, @app.commercial_form_by_name('name'))
end

- (Object) test_company



388
389
390
391
392
393
# File 'test/test_util/oddbapp.rb', line 388

def test_company
  company = ODDB::Company.new
  @app.companies = {company.oid => company}
  oid = @app.companies.keys.first
  assert_equal(company, @app.company(oid))
end

- (Object) test_company_by_name1



400
401
402
403
404
405
406
407
408
409
410
# File 'test/test_util/oddbapp.rb', line 400

def test_company_by_name1
  company1 = ODDB::Company.new
  company2 = ODDB::Company.new
  company1.name = 'ywesee'
  company2.name = 'hal'
  @app.companies = {
    company1.oid => company1,
    company2.oid => company2,
  }
  assert_equal(company1, @app.company_by_name('ywesee'))
end

- (Object) test_company_by_name2



411
412
413
414
415
416
417
418
419
420
421
# File 'test/test_util/oddbapp.rb', line 411

def test_company_by_name2
  company1 = ODDB::Company.new
  company2 = ODDB::Company.new
  company1.name = 'ywesee'
  company2.name = 'hal'
  @app.companies = {
    company1.oid => company1,
    company2.oid => company2,
  }
  assert_equal(company2, @app.company_by_name('hal'))
end

- (Object) test_company_by_name3



422
423
424
425
426
427
428
429
430
431
432
# File 'test/test_util/oddbapp.rb', line 422

def test_company_by_name3
  company1 = ODDB::Company.new
  company2 = ODDB::Company.new
  company1.name = 'ywesee'
  company2.name = 'hal'
  @app.companies = {
    company1.oid => company1,
    company2.oid => company2,
  }
  assert_equal(nil, @app.company_by_name('pear'))
end

- (Object) test_company_count



1157
1158
1159
# File 'test/test_util/oddbapp.rb', line 1157

def test_company_count
  assert_equal(0, @app.company_count)
end

- (Object) test_config



1852
1853
1854
1855
1856
1857
# File 'test/test_util/oddbapp.rb', line 1852

def test_config
  expected = ODDB::Config.new
  expected.pointer = ODDB::Persistence::Pointer.new(:config)
  #assert(same?(expected ,@app.config))
  assert_equal(expected.class, @app.config('arg').class) # actually the instances should be compared
end

- (Object) test_count_atc_ddd



1135
1136
1137
1138
1139
1140
1141
# File 'test/test_util/oddbapp.rb', line 1135

def test_count_atc_ddd
  atc = flexmock('atc') do |atc|
    atc.should_receive(:has_ddd?).and_return(true)
  end
  @app.atc_classes = {'key' => atc}
  assert_equal(1, @app.count_atc_ddd)
end

- (Object) test_count_limitation_text_count



1145
1146
1147
# File 'test/test_util/oddbapp.rb', line 1145

def test_count_limitation_text_count
  assert_equal(0, @app.limitation_text_count)
end

- (Object) test_count_limitation_texts



1858
1859
1860
1861
1862
1863
1864
# File 'test/test_util/oddbapp.rb', line 1858

def test_count_limitation_texts
  registration = flexmock('registration') do |reg|
    reg.should_receive(:limitation_text_count).and_return(123)
  end
  @app.registrations = {'key' => registration}
  assert_equal(123, @app.count_limitation_texts)
end

- (Object) test_count_recent_registrations



1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
# File 'test/test_util/oddbapp.rb', line 1896

def test_count_recent_registrations
  flags = [:new]
  log = flexmock('log') do |log|
    log.should_receive(:change_flags).and_return({'ptr' => flags})
  end
  group = flexmock('group') do |grp|
    grp.should_receive(:latest).and_return(log)
  end
  @app.log_groups = {:swissmedic => group}
  assert_equal(1, @app.count_recent_registrations)
end

- (Object) test_count_vaccines



1160
1161
1162
1163
1164
1165
1166
1167
# File 'test/test_util/oddbapp.rb', line 1160

def test_count_vaccines
  registration = flexmock('registration') do |reg|
    reg.should_receive(:vaccine).and_return(true)
    reg.should_receive(:active_package_count).and_return(123)
  end
  @app.registrations = {'key' => registration}
  assert_equal(123, @app.count_vaccines)
end

- (Object) test_create_address_suggestion



1003
1004
1005
1006
1007
1008
1009
1010
1011
# File 'test/test_util/oddbapp.rb', line 1003

def test_create_address_suggestion
  address_suggestion = flexmock('address_suggestion') do |ads|
    ads.should_receive(:oid)
  end
  flexmock(ODDB::AddressSuggestion) do |ads|
    ads.should_receive(:new).and_return(address_suggestion)
  end
  assert_equal(address_suggestion, @app.create_address_suggestion)
end

- (Object) test_create_analysis_group



950
951
952
953
954
955
956
# File 'test/test_util/oddbapp.rb', line 950

def test_create_analysis_group
  group = flexmock('group')
  flexmock(ODDB::Analysis::Group) do |grp|
    grp.should_receive(:new).and_return(group)
  end
  assert_equal(group, @app.create_analysis_group(0))
end

- (Object) test_create_atc_class



381
382
383
384
385
386
387
# File 'test/test_util/oddbapp.rb', line 381

def test_create_atc_class
  @app.atc_classes = {}
  pointer = ODDB::Persistence::Pointer.new(['atc_class', 'N02BA01'])
  atc = @app.create(pointer)
  assert_equal(ODDB::AtcClass, @app.atc_class('N02BA01').class)
  assert_equal(atc, @app.atc_class('N02BA01'))
end

- (Object) test_create_commercial_form



957
958
959
960
961
962
963
964
965
# File 'test/test_util/oddbapp.rb', line 957

def test_create_commercial_form
  form = flexmock('form') do |frm|
    frm.should_receive(:oid)
  end
  flexmock(ODDB::CommercialForm) do |frm|
    frm.should_receive(:new).and_return(form)
  end
  assert_equal(form, @app.create_commercial_form)
end

- (Object) test_create_commercial_forms



1201
1202
1203
1204
# File 'test/test_util/oddbapp.rb', line 1201

def test_create_commercial_forms
  setup_create_commercial_forms
  assert_equal({'12345' => @registration}, @app.create_commercial_forms)
end

- (Object) test_create_commercial_forms__commercial_form



1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
# File 'test/test_util/oddbapp.rb', line 1205

def test_create_commercial_forms__commercial_form
  setup_create_commercial_forms
  flexstub(ODDB::CommercialForm) do |frm|
    frm.should_receive(:find_by_name).and_return('commercial_form')
  end
  @app.registrations = {'12345' => @registration}
  galenicform = flexmock('galenicform') do |gf|
    gf.should_receive(:description)
    gf.should_receive(:synonyms)
  end
  galenicgroup = flexmock('galenicgroup') do |gg|
    gg.should_receive(:get_galenic_form).and_return(galenicform)
  end
  @app.galenic_groups = {'12345'=> galenicgroup}
  assert_equal({'12345' => @registration}, @app.create_commercial_forms)
end

- (Object) test_create_company



433
434
435
436
437
438
439
440
# File 'test/test_util/oddbapp.rb', line 433

def test_create_company
    @app.companies = {}
    @app.create_company
  oid = @app.companies.keys.first
  company = @app.companies.values.first
  assert_equal(ODDB::Company, @app.company(oid).class)
  assert_equal(company, @app.company(oid))
end

- (Object) test_create_cyp450



474
475
476
477
478
479
480
481
482
483
484
# File 'test/test_util/oddbapp.rb', line 474

def test_create_cyp450
  @app.cyp450s.clear
  cyp450 = '1A2'
  assert_nil(@app.cyp450(cyp450))
  pointer = ODDB::Persistence::Pointer.new(['cyp450', '1A2'])
  created = @app.create(pointer)
  assert_equal(1, @app.cyp450s.size)
  assert_equal(ODDB::CyP450, created.class)
  result = @app.cyp450(cyp450)
  assert_equal(ODDB::CyP450, result.class)
end

- (Object) test_create_cyp450inducer



527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
# File 'test/test_util/oddbapp.rb', line 527

def test_create_cyp450inducer
  pointer = ODDB::Persistence::Pointer.new(['cyp450', '1A2'])
  cyp450 = @app.create(pointer)
  pointer += ['cyp450inducer', 'foo_name']
  inh = @app.create(pointer)
  values = {
    :links   => 'foo-links',
    :category  => 'bar-category',
  }
  @app.update(inh.pointer, values)
  assert_equal('foo-links', inh.links)
  assert_equal('bar-category', inh.category)
  assert_equal('foo_name', inh.substance_name)
  assert_equal(1, cyp450.inducers.size)
  assert_equal(['foo_name'], cyp450.inducers.keys)
end

- (Object) test_create_cyp450inhibitor



502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
# File 'test/test_util/oddbapp.rb', line 502

def test_create_cyp450inhibitor
  pointer = ODDB::Persistence::Pointer.new(['cyp450', '1A2'])
  cyp450 = @app.create(pointer)
  pointer += ['cyp450inhibitor', 'foo_name']
  inh = @app.create(pointer)
  values = {
    :links   => 'foo-links',
    :category  => 'bar-category',
  }
  @app.update(inh.pointer, values)
  assert_equal('foo-links', inh.links)
  assert_equal('bar-category', inh.category)
  assert_equal('foo_name', inh.substance_name)
  assert_equal(1, cyp450.inhibitors.size)
  assert_equal(['foo_name'], cyp450.inhibitors.keys)
end

- (Object) test_create_cyp450substrate



552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
# File 'test/test_util/oddbapp.rb', line 552

def test_create_cyp450substrate
  pointer = ODDB::Persistence::Pointer.new('substance')
  substance = @app.create(pointer)
              substance.descriptions['lt'] = 'subst_name'
  pointer += [ :cyp450substrate, "cyp_id" ]
  inh = @app.create(pointer)
  values = {
    :links   => ['foo-links'],
    :category  => 'bar-category',
  }
  @app.update(inh.pointer, values)
  assert_equal(['foo-links'], inh.links)
  assert_equal('bar-category', inh.category)
  assert_equal(1, substance.substrate_connections.size)
end

- (Object) test_create_doctor



441
442
443
444
445
446
447
448
449
# File 'test/test_util/oddbapp.rb', line 441

def test_create_doctor
    @app.doctors = {}
    @app.create_doctor
  oid = @app.doctors.keys.first
  doctor = @app.doctors.values.first
  puts @app.doctors.inspect
  assert_equal(ODDB::Doctor, @app.doctor(oid).class)
  assert_equal(doctor, @app.doctor(oid))
end

- (Object) test_create_fachinfo



975
976
977
978
979
980
981
982
983
984
# File 'test/test_util/oddbapp.rb', line 975

def test_create_fachinfo
  fachinfo = flexmock('fachinfo') do |fi|
    fi.should_receive(:oid)
  end
  flexmock(ODDB::Fachinfo) do |fi|
    fi.should_receive(:new).and_return(fachinfo)
  end
  assert_equal(fachinfo, @app.create_fachinfo)

end

- (Object) test_create_feedback



985
986
987
988
989
990
991
992
993
# File 'test/test_util/oddbapp.rb', line 985

def test_create_feedback
   = flexmock('feedback') do |fb|
    fb.should_receive(:oid)
  end
  flexmock(ODDB::) do |fb|
    fb.should_receive(:new).and_return()
  end
  assert_equal(, @app.create_feedback)
end

- (Object) test_create_galenic_group



343
344
345
346
347
348
349
# File 'test/test_util/oddbapp.rb', line 343

def test_create_galenic_group
  @app.galenic_groups = {}
  pointer = ODDB::Persistence::Pointer.new([:galenic_group])
  galgroup = @app.create(pointer)
  assert_equal(galgroup.oid, @app.galenic_group(galgroup.oid).oid)
  assert_equal(1, @app.galenic_groups.size)
end

- (Object) test_create_generic_group



595
596
597
598
599
600
601
602
603
604
605
606
607
608
# File 'test/test_util/oddbapp.rb', line 595

def test_create_generic_group
  pointer = ODDB::Persistence::Pointer.new(['registration', '12345'])
  reg = @app.create(pointer)
  pointer += ['sequence', '01']
  seq = @app.create(pointer)
  seq.packages = {}
  pointer += ['package', '032']
  package = @app.create(pointer)
  @app.generic_groups = {}
  group_pointer = ODDB::Persistence::Pointer.new(['generic_group', pointer])
  generic_group = @app.create(group_pointer)
  assert_equal(generic_group, @app.generic_groups[pointer])
  assert_equal(group_pointer, generic_group.pointer)
end

- (Object) test_create_hospital



966
967
968
969
970
971
972
973
974
# File 'test/test_util/oddbapp.rb', line 966

def test_create_hospital
  hospital = flexmock('hospital') do |hos|
    hos.should_receive(:oid)
  end
  flexmock(ODDB::Hospital) do |hos|
    hos.should_receive(:new).and_return(hospital)
  end
  assert_equal(hospital, @app.create_hospital(0))
end

- (Object) test_create_index_therapeuticus_code



1048
1049
1050
1051
1052
1053
1054
1055
1056
# File 'test/test_util/oddbapp.rb', line 1048

def test_create_index_therapeuticus_code
    index_therapeuticus = flexmock('index_therapeuticus') do |int|
      int.should_receive(:code)
    end
    flexmock(ODDB::IndexTherapeuticus) do |int|
      int.should_receive(:new).and_return(index_therapeuticus)
    end
    assert_equal(index_therapeuticus, @app.create_index_therapeuticus('code'))
end

- (Object) test_create_indication



609
610
611
612
613
614
615
616
617
# File 'test/test_util/oddbapp.rb', line 609

def test_create_indication
  @app.indications = {}
  pointer = ODDB::Persistence::Pointer.new(:indication)
  result = @app.create(pointer)
  assert_instance_of(ODDB::Indication, result)
  assert_equal(1, @app.indications.size)
  oid = result.oid
  assert_equal(result, @app.indication(oid))
end

- (Object) test_create_invoice



994
995
996
997
998
999
1000
1001
1002
# File 'test/test_util/oddbapp.rb', line 994

def test_create_invoice
  invoice = flexmock('invoice') do |inv|
    inv.should_receive(:oid)
  end
  flexmock(ODDB::Invoice) do |inv|
    inv.should_receive(:new).and_return(invoice)
  end
  assert_equal(invoice, @app.create_invoice)
end

- (Object) test_create_log_group



655
656
657
658
659
660
661
662
663
664
665
# File 'test/test_util/oddbapp.rb', line 655

def test_create_log_group
  @app.log_groups = {}
  pointer = ODDB::Persistence::Pointer.new([:log_group, :swissmedic_journal])
  group = @app.create(pointer)
  assert_instance_of(ODDB::LogGroup, group)
  assert_equal({:swissmedic_journal=>group}, @app.log_groups)
  assert_equal(pointer, group.pointer)
  group1 = @app.create(pointer)
  assert_equal(group, group1)
  assert_equal({:swissmedic_journal=>group}, @app.log_groups)
end

- (Object) test_create_migel_group



835
836
837
838
839
840
841
842
# File 'test/test_util/oddbapp.rb', line 835

def test_create_migel_group
  group = @app.create_migel_group('03')
  assert_instance_of(ODDB::Migel::Group, group)
  assert_equal(@app.migel_groups["03"], group)
  assert_equal({'03' => group}, @app.migel_groups)
  ## getter-test
  assert_equal(group, @app.migel_group('03'))
end

- (Object) test_create_minifi



1012
1013
1014
1015
1016
1017
1018
1019
1020
# File 'test/test_util/oddbapp.rb', line 1012

def test_create_minifi
  minifi = flexmock('minifi') do |mfi|
    mfi.should_receive(:oid)
  end
  flexmock(ODDB::MiniFi) do |mfi|
    mfi.should_receive(:new).and_return(minifi)
  end
  assert_equal(minifi, @app.create_minifi)
end

- (Object) test_create_narcotic



1021
1022
1023
1024
1025
1026
1027
1028
1029
# File 'test/test_util/oddbapp.rb', line 1021

def test_create_narcotic
  narcotic = flexmock('narcotic') do |nar|
    nar.should_receive(:oid)
  end
  flexmock(ODDB::Narcotic) do |nar|
    nar.should_receive(:new).and_return(narcotic)
  end
  assert_equal(narcotic, @app.create_narcotic)
end

- (Object) test_create_orphaned_fachinfo



779
780
781
782
783
784
785
# File 'test/test_util/oddbapp.rb', line 779

def test_create_orphaned_fachinfo
        pointer = ODDB::Persistence::Pointer.new([:orphaned_fachinfo])
        assert_equal({}, @app.orphaned_fachinfos)
        orph = @app.create(pointer)
        assert_instance_of(ODDB::OrphanedTextInfo, orph)
        assert_equal({orph.oid => orph}, @app.orphaned_fachinfos)
end

- (Object) test_create_orphaned_patinfo



786
787
788
789
790
791
792
# File 'test/test_util/oddbapp.rb', line 786

def test_create_orphaned_patinfo
  pointer = ODDB::Persistence::Pointer.new([:orphaned_patinfo])
  assert_equal({}, @app.orphaned_patinfos)
  orph = @app.create(pointer)
  assert_instance_of(ODDB::OrphanedTextInfo, orph)
  assert_equal({orph.oid => orph}, @app.orphaned_patinfos)
end

- (Object) test_create_package



291
292
293
294
295
296
297
298
299
300
301
302
# File 'test/test_util/oddbapp.rb', line 291

def test_create_package
  pointer = ODDB::Persistence::Pointer.new(['registration', '12345'])
  reg = @app.create(pointer)
  pointer += ['sequence', '01']
  seq = @app.create(pointer)
  seq.packages = {}
  pointer += ['package', '032']
  result = @app.create(pointer)
  assert_equal(ODDB::Package, result.class)
  package = seq.packages['032']
  assert_equal(package, seq.package('032'))
end

- (Object) test_create_patinfo



303
304
305
306
307
308
309
# File 'test/test_util/oddbapp.rb', line 303

def test_create_patinfo
  pointer = ODDB::Persistence::Pointer.new(:patinfo)
  result = @app.create(pointer)
  assert_instance_of(ODDB::Patinfo, result)
  expected = {result.oid => result}
  assert_equal(expected, @app.patinfos)
end

- (Object) test_create_patinfo2



310
311
312
313
314
315
316
317
318
# File 'test/test_util/oddbapp.rb', line 310

def test_create_patinfo2
  pat1 = @app.create_patinfo
  pat2 = @app.create_patinfo
  expected = {pat1.oid=>pat1,
        pat2.oid=>pat2,
            }
  assert_equal(expected,@app.patinfos)
  assert_equal(pat1.oid+1,pat2.oid)
end

- (Object) test_create_poweruser



1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
# File 'test/test_util/oddbapp.rb', line 1532

def test_create_poweruser
  poweruser = flexmock('poweruser') do |pusr|
    pusr.should_receive(:oid)
  end
  flexstub(ODDB::PowerUser) do |usr|
    usr.should_receive(:new).and_return(poweruser)
  end
  @app.users = {}
  assert_equal(poweruser, @app.create_poweruser)
end

- (Object) test_create_registration



233
234
235
236
237
238
239
240
241
# File 'test/test_util/oddbapp.rb', line 233

def test_create_registration
  @app.registrations = {}
  pointer = ODDB::Persistence::Pointer.new(['registration', '12345'])
  result = @app.create(pointer)
  assert_equal(ODDB::Registration, result.class)
  assert_equal(1, @app.registrations.size)
  assert_equal(ODDB::Registration, @app.registrations['12345'].class)
  assert_equal(pointer, @app.registrations['12345'].pointer)
end

- (Object) test_create_sequence



252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'test/test_util/oddbapp.rb', line 252

def test_create_sequence
  pointer = ODDB::Persistence::Pointer.new(['registration', '12345'])
  reg = @app.create(pointer)
  reg.sequences = {}
  pointer += ['sequence', '01']
  expected = [
    ['registration', '12345']
  ]
  assert_equal(expected, reg.pointer.directions)
  result = @app.create(pointer)
  assert_equal(expected, reg.pointer.directions)
  assert_equal(ODDB::Sequence, result.class)
  expected = [
    ['registration', '12345'],
    ['sequence', '01'],
  ]
  result.pointer.directions
  seq = reg.sequence('01')
  assert_equal(seq, reg.sequence('01'))
end

- (Object) test_create_slate_name



1030
1031
1032
1033
1034
1035
1036
1037
1038
# File 'test/test_util/oddbapp.rb', line 1030

def test_create_slate_name
  slate = flexmock('slate') do |sla|
    sla.should_receive(:oid)
  end
  flexmock(ODDB::Slate) do |sla|
    sla.should_receive(:new).and_return(slate)
  end
  assert_equal(slate, @app.create_slate(name))
end

- (Object) test_create_sponsor_flavor



1039
1040
1041
1042
1043
1044
1045
1046
1047
# File 'test/test_util/oddbapp.rb', line 1039

def test_create_sponsor_flavor
   = flexmock('sponsor') do |spo|
    spo.should_receive(:oid)
  end
  flexmock(ODDB::) do |spo|
    spo.should_receive(:new).and_return()
  end
  assert_equal(, @app.create_sponsor('flavor'))
end

- (Object) test_create_substance



350
351
352
353
354
355
356
357
358
359
360
361
# File 'test/test_util/oddbapp.rb', line 350

def test_create_substance
  @app.substances = {}
  substance = 'ACIDUM ACETYLSALICYLICUM'
  assert_nil(@app.substance(substance))
  pointer = ODDB::Persistence::Pointer.new(['substance', 'ACIDUM ACETYLSALICYLICUM'])
  created = @app.create(pointer)
  assert_equal(1, @app.substances.size)
  assert_equal(ODDB::Substance, created.class)
  result = @app.substance(created.oid)
  assert_equal(ODDB::Substance, result.class)
  assert_equal('Acidum Acetylsalicylicum', result.name)
end

- (Object) test_create_user



1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
# File 'test/test_util/oddbapp.rb', line 1542

def test_create_user
  companyuser = flexmock('companyuser') do |usr|
    usr.should_receive(:oid)
  end
  flexstub(ODDB::CompanyUser) do |usr|
    usr.should_receive(:new).and_return(companyuser)
  end
  @app.users = {}
  assert_equal(companyuser, @app.create_user)
end

- (Object) test_currencies



1473
1474
1475
# File 'test/test_util/oddbapp.rb', line 1473

def test_currencies
  assert_equal([], @app.currencies)
end

- (Object) test_cyp450



493
494
495
496
497
498
499
500
501
# File 'test/test_util/oddbapp.rb', line 493

def test_cyp450
  @app.cyp450s.clear
  cyp450 = '1A2'
  assert_nil(@app.cyp450(cyp450))
  pointer = ODDB::Persistence::Pointer.new(['cyp450', '1A2'])
  created = @app.create(pointer)
  result = @app.cyp450(cyp450)
  assert_equal(created, result)
end

- (Object) test_delete_address_suggestion



1332
1333
1334
1335
# File 'test/test_util/oddbapp.rb', line 1332

def test_delete_address_suggestion
  @app.address_suggestions = {'oid' => 'address_suggestion'}
  assert_equal('address_suggestion', @app.delete_address_suggestion('oid'))
end

- (Object) test_delete_atc_class



1328
1329
1330
1331
# File 'test/test_util/oddbapp.rb', line 1328

def test_delete_atc_class
  @app.atc_classes = {'oid' => 'atc_class'}
  assert_equal('atc_class', @app.delete_atc_class('oid'))
end

- (Object) test_delete_commercial_form



1324
1325
1326
1327
# File 'test/test_util/oddbapp.rb', line 1324

def test_delete_commercial_form
  @app.commercial_forms = {'oid' => 'commercial_form'}
  assert_equal('commercial_form', @app.delete_commercial_form('oid'))
end

- (Object) test_delete_company



450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'test/test_util/oddbapp.rb', line 450

def test_delete_company
  company3 = @app.create_company
  @app.companies = {company3.oid => company3}
  company2 = @app.create_company
  company2.name = 'ywesee'
  company3.name = 'ehz'
  expected1 = {company2.oid => company2, company3.oid => company3}
  puts expected1.inspect
  assert_equal(expected1, @app.companies)
  @app.delete_company(company2.oid)
  expected2 = {company3.oid => company3}
  assert_equal(expected2, @app.companies)
end

- (Object) test_delete_cyp450



485
486
487
488
489
490
491
492
# File 'test/test_util/oddbapp.rb', line 485

def test_delete_cyp450
  @app.cyp450s.clear
  pointer = ODDB::Persistence::Pointer.new(['cyp450', '1A2'])
  created = @app.create(pointer)
  assert_equal(1, @app.cyp450s.size)
  @app.delete(pointer)
  assert_equal(0, @app.cyp450s.size)
end

- (Object) test_delete_cyp450inducer



543
544
545
546
547
548
549
550
551
# File 'test/test_util/oddbapp.rb', line 543

def test_delete_cyp450inducer
  pointer = ODDB::Persistence::Pointer.new(['cyp450', '1A2'])
  cyp450 = @app.create(pointer)
  pointer += ['cyp450inducer', 'foo_name']
  inh = @app.create(pointer)
  assert_equal(1, cyp450.inducers.size)
  @app.delete(pointer)
  assert_equal(0, cyp450.inducers.size)
end

- (Object) test_delete_cyp450inhibitor



518
519
520
521
522
523
524
525
526
# File 'test/test_util/oddbapp.rb', line 518

def test_delete_cyp450inhibitor
  pointer = ODDB::Persistence::Pointer.new(['cyp450', '1A2'])
  cyp450 = @app.create(pointer)
  pointer += ['cyp450inhibitor', 'foo_name']
  inh = @app.create(pointer)
  assert_equal(1, cyp450.inhibitors.size)
  @app.delete(pointer)
  assert_equal(0, cyp450.inhibitors.size)
end

- (Object) test_delete_cyp450substrate



567
568
569
570
571
572
573
574
575
576
# File 'test/test_util/oddbapp.rb', line 567

def test_delete_cyp450substrate
  pointer = ODDB::Persistence::Pointer.new('substance')
  substance = @app.create(pointer)
              substance.descriptions['lt'] = 'subst_name'
  pointer += [ :cyp450substrate, "cyp_id" ]
  substr = @app.create(pointer)
  assert_equal(1, substance.substrate_connections.size)
  @app.delete(substr.pointer)
  assert_equal(0, substance.substrate_connections.size)
end

- (Object) test_delete_doctor



463
464
465
466
467
468
469
470
471
472
473
# File 'test/test_util/oddbapp.rb', line 463

def test_delete_doctor
  doctor2 = @app.create_doctor
  doctor3 = @app.create_doctor
  doctor2.name = 'foobar'
  doctor3.name = 'foobaz'
  expected1 = {doctor2.oid => doctor2, doctor3.oid => doctor3}
  assert_equal(expected1, @app.doctors)
  @app.delete_doctor(doctor2.oid)
  expected2 = {doctor3.oid => doctor3}
  assert_equal(expected2, @app.doctors)
end

- (Object) test_delete_fachinfo



1296
1297
1298
1299
# File 'test/test_util/oddbapp.rb', line 1296

def test_delete_fachinfo
  @app.fachinfos = {'oid' => 'fachinfo'}
  assert_equal('fachinfo', @app.delete_fachinfo('oid'))
end

- (Object) test_delete_galenic_group



577
578
579
580
581
582
583
584
585
586
587
# File 'test/test_util/oddbapp.rb', line 577

def test_delete_galenic_group
  group = StubGalenicGroup.new
  @app.galenic_groups = {
    12345  => group,
  }
  group.galenic_form = StubGalenicForm.new('Tabletten')
  assert_equal(false, group.empty?)
  assert_raises(RuntimeError) { @app.delete_galenic_group('12345') }
  group.galenic_form = nil
  assert_nothing_raised {@app.delete_galenic_group('12345')}
end

- (Object) test_delete_index_therapeuticus



1304
1305
1306
1307
# File 'test/test_util/oddbapp.rb', line 1304

def test_delete_index_therapeuticus
  @app.indices_therapeutici = {'oid' => 'index_therapeuticus'}
  assert_equal('index_therapeuticus', @app.delete_index_therapeuticus('oid'))
end

- (Object) test_delete_indication



1300
1301
1302
1303
# File 'test/test_util/oddbapp.rb', line 1300

def test_delete_indication
  @app.indications = {'oid' => 'indication'}
  assert_equal('indication', @app.delete_indication('oid'))
end

- (Object) test_delete_invoice



1308
1309
1310
1311
# File 'test/test_util/oddbapp.rb', line 1308

def test_delete_invoice
  @app.invoices = {'oid' => 'invoice'}
  assert_equal('invoice', @app.delete_invoice('oid'))
end

- (Object) test_delete_migel_group



1312
1313
1314
1315
# File 'test/test_util/oddbapp.rb', line 1312

def test_delete_migel_group
  @app.migel_groups = {'code' => 'migel_group'}
  assert_equal('migel_group', @app.delete_migel_group('code'))
end

- (Object) test_delete_minifi



1340
1341
1342
1343
# File 'test/test_util/oddbapp.rb', line 1340

def test_delete_minifi
  @app.minifis = {123 => 'minifis'}
  assert_equal('minifis', @app.delete_minifi('123'))
end

- (Object) test_delete_orphan_patinfo



793
794
795
796
797
798
# File 'test/test_util/oddbapp.rb', line 793

def test_delete_orphan_patinfo
  @app.orphaned_patinfos = { 1 => "foo" }
  pointer = ODDB::Persistence::Pointer.new([:orphaned_patinfo, 1])
  @app.delete(pointer)
  assert_equal({}, @app.orphaned_patinfos)
end

- (Object) test_delete_orphaned_fachinfo



1336
1337
1338
1339
# File 'test/test_util/oddbapp.rb', line 1336

def test_delete_orphaned_fachinfo
  @app.orphaned_fachinfos = {123 => 'orphaned_fachinfos'}
  assert_equal('orphaned_fachinfos', @app.delete_orphaned_fachinfo('123'))
end

- (Object) test_delete_patinfo



1316
1317
1318
1319
# File 'test/test_util/oddbapp.rb', line 1316

def test_delete_patinfo
  @app.patinfos = {'oid' => 'patinfo'}
  assert_equal('patinfo', @app.delete_patinfo('oid'))
end

- (Object) test_delete_registration



1320
1321
1322
1323
# File 'test/test_util/oddbapp.rb', line 1320

def test_delete_registration
  @app.registrations = {'oid' => 'registration'}
  assert_equal('registration', @app.delete_registration('oid'))
end

- (Object) test_delete_substance



1344
1345
1346
1347
# File 'test/test_util/oddbapp.rb', line 1344

def test_delete_substance
  @app.substances = {123 => 'substance'}
  assert_equal('substance', @app.delete_substance('123'))
end

- (Object) test_delete_substance__downcase



1348
1349
1350
1351
# File 'test/test_util/oddbapp.rb', line 1348

def test_delete_substance__downcase
  @app.substances = {'abc' => 'substance'}
  assert_equal('substance', @app.delete_substance('abc'))
end

- (Object) test_doctor



394
395
396
397
398
399
# File 'test/test_util/oddbapp.rb', line 394

def test_doctor
  doctor = ODDB::Company.new
  @app.doctors = {doctor.oid => doctor}
  oid = @app.doctors.keys.first
  assert_equal(doctor, @app.doctor(oid))
end

- (Object) test_doctor_by_origin



812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
# File 'test/test_util/oddbapp.rb', line 812

def test_doctor_by_origin
  docs = FlexMock.new('DoctorHash')
  doc1 = FlexMock.new('Doctor1')
  doc2 = FlexMock.new('Doctor2')
  doc3 = FlexMock.new('Doctor3')
  @app.doctors = docs
  docs.should_receive(:values).and_return {
    [ doc1, doc2, doc3, ]
  }
  doc1.should_receive(:record_match?).and_return { |db, id|
    puts "record-match doc 1"
    false
  }
  doc2.should_receive(:record_match?).and_return { |db, id|
    puts "record-match doc 2"
    true
  }
  assert_equal(doc2, @app.doctor_by_origin(:doc, 4567))
end

- (Object) test_doctor_by_origin__nil



831
832
833
834
# File 'test/test_util/oddbapp.rb', line 831

def test_doctor_by_origin__nil
  @app.doctors = {}
  assert_equal(nil, @app.doctor_by_origin(:doc, 4567))
end

- (Object) test_doctor_count



1169
1170
1171
# File 'test/test_util/oddbapp.rb', line 1169

def test_doctor_count
  assert_equal(0, @app.doctor_count)
end

- (Object) test_each_atc_class



1479
1480
1481
# File 'test/test_util/oddbapp.rb', line 1479

def test_each_atc_class
  assert_equal({}, @app.each_atc_class)
end

- (Object) test_each_galenic_form



709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
# File 'test/test_util/oddbapp.rb', line 709

def test_each_galenic_form
  galgroup1 = StubGalenicGroup.new
  galgroup2 = StubGalenicGroup.new
  galgroup3 = StubGalenicGroup.new
  galgroup1.galenic_form=1
  galgroup2.galenic_form=2
  galgroup3.galenic_form=3
  @app.galenic_groups = {
    1 => galgroup1,
    2 => galgroup2,
    3 => galgroup3,
  }
  @app.each_galenic_form { |arg|
    arg*2
  }
  assert_equal(2,galgroup1.block_result)
  assert_equal(4,galgroup2.block_result)
  assert_equal(6,galgroup3.block_result)
end

- (Object) test_each_migel_product



1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
# File 'test/test_util/oddbapp.rb', line 1482

def test_each_migel_product
  subgroup = flexmock('subgroup') do |grp|
    grp.should_receive(:products).and_return({'product' => 'product'})
  end
  group = flexmock('group') do |grp|
    grp.should_receive(:subgroups).and_return({'subgroup' => subgroup})
  end
  @app.migel_groups = {'group' => group}
  assert_equal({'group' => group}, @app.each_migel_product{})
end

- (Object) test_each_package



693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
# File 'test/test_util/oddbapp.rb', line 693

def test_each_package
  reg1 = StubRegistration.new(1)
  reg2 = StubRegistration.new(2)
  reg3 = StubRegistration.new(3)
  @app.registrations = {
    1 => reg1,
    2 => reg2,
    3 => reg3,
  }
  @app.each_package { |arg|
    arg*2
  }
  assert_equal(2,reg1.block_result)
  assert_equal(4,reg2.block_result)
  assert_equal(6,reg3.block_result)
end

- (Object) test_each_sequence



1552
1553
1554
1555
1556
1557
1558
# File 'test/test_util/oddbapp.rb', line 1552

def test_each_sequence
  registration = flexmock('registration') do |reg|
    reg.should_receive(:each_sequence).and_yield
  end
  @app.registrations = {'1' => registration}
  assert_equal({'1' => registration}, @app.each_sequence{})
end

- (Object) test_fachinfo



774
775
776
777
778
# File 'test/test_util/oddbapp.rb', line 774

def test_fachinfo
    @app.fachinfos = { 1 => "foo", "1" => "bar"}
    assert_equal("foo", @app.fachinfo("1"))
    assert_equal("foo", @app.fachinfo(1))
end

- (Object) test_fachinfo_count



1172
1173
1174
# File 'test/test_util/oddbapp.rb', line 1172

def test_fachinfo_count
  assert_equal(0, @app.fachinfo_count)
end

- (Object) test_fachinfos_by_name



1559
1560
1561
# File 'test/test_util/oddbapp.rb', line 1559

def test_fachinfos_by_name
  assert_equal([], @app.fachinfos_by_name('name', 'lang'))
end

- (Object) test_feedback



1520
1521
1522
1523
# File 'test/test_util/oddbapp.rb', line 1520

def test_feedback
  @app.feedbacks = {123 => 'feedback'}
  assert_equal('feedback', @app.('123'))
end

- (Object) test_galenic_form



336
337
338
339
340
341
342
# File 'test/test_util/oddbapp.rb', line 336

def test_galenic_form
  galenic_form = StubGalenicForm.new('Tabletten')
  group = StubGalenicGroup.new
  group.galenic_form = galenic_form
  @app.galenic_groups = { 2 => group }
  assert_equal(galenic_form, @app.galenic_form('Tabletten'))
end

- (Object) test_galenic_group_initialized



218
219
220
221
222
# File 'test/test_util/oddbapp.rb', line 218

def test_galenic_group_initialized
  expected_pointer = ODDB::Persistence::Pointer.new([:galenic_group, 1])
  assert_equal(expected_pointer, @app.galenic_groups.values.first.pointer)
  assert_equal('Unbekannt', expected_pointer.resolve(@app).description)
end

- (Object) test_generate_dictionaries



1814
1815
1816
# File 'test/test_util/oddbapp.rb', line 1814

def test_generate_dictionaries
  assert_equal('german_dictionary', @app.generate_dictionaries)
end

- (Object) test_generate_dictionary



1805
1806
1807
# File 'test/test_util/oddbapp.rb', line 1805

def test_generate_dictionary
  assert_equal('generate_dictionary', @app.generate_dictionary('language', 'locale'))
end

- (Object) test_generate_french_dictionary



1808
1809
1810
# File 'test/test_util/oddbapp.rb', line 1808

def test_generate_french_dictionary
  assert_equal('french_dictionary', @app.generate_french_dictionary)
end

- (Object) test_generate_german_dictionary



1811
1812
1813
# File 'test/test_util/oddbapp.rb', line 1811

def test_generate_german_dictionary
  assert_equal('german_dictionary', @app.generate_german_dictionary)
end

- (Object) test_generic_group



588
589
590
591
592
593
594
# File 'test/test_util/oddbapp.rb', line 588

def test_generic_group
  pointer = ODDB::Persistence::Pointer.new(['registration', '12345'],
    ['sequence', '01'], ['package', '032'])
  generic_group = ODDB::GenericGroup.new
  @app.generic_groups = { pointer => generic_group }
  assert_equal(generic_group, @app.generic_group(pointer))
end

- (Object) test_grant_download



1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
# File 'test/test_util/oddbapp.rb', line 1767

def test_grant_download
  flexstub(@app) do |app|
    app.should_receive(:system).and_return(@app.instance_eval('@system'))
  end
  itp = flexmock('itp') do |itp|
    itp.should_receive(:+).and_return(itp)
    itp.should_receive(:creator)
  end
  inv = flexmock('inv') do |inv|
    inv.should_receive(:pointer).and_return(itp)
    inv.should_receive(:payment_received!)
    inv.should_receive(:odba_store)
    inv.should_receive(:oid).and_return('oid')
  end
  flexstub(@app.system) do |sys|
    sys.should_receive(:update).and_return(inv)
  end
  expected = "http://#{ODDB::SERVER_NAME}/de/gcc/download/invoice/oid/email/email/filename/filename"
  assert_equal(expected, @app.grant_download('email', 'filename', 'price'))
end

- (Object) test_hospital



1476
1477
1478
# File 'test/test_util/oddbapp.rb', line 1476

def test_hospital
  assert_equal(nil, @app.hospital('ean13'))
end

- (Object) test_hospital_count



1166
1167
1168
# File 'test/test_util/oddbapp.rb', line 1166

def test_hospital_count
  assert_equal(0, @app.hospital_count)
end

- (Object) test_index_therapeuticus



1516
1517
1518
1519
# File 'test/test_util/oddbapp.rb', line 1516

def test_index_therapeuticus
  @app.indices_therapeutici = {'code' => 'index'}
  assert_equal('index', @app.index_therapeuticus('code'))
end

- (Object) test_inject_poweruser



1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
# File 'test/test_util/oddbapp.rb', line 1430

def test_inject_poweruser
  flexstub(@app) do |app|
    app.should_receive(:system).and_return(@app.instance_eval('@system'))
  end
  pointer = flexmock('pointer') do |poi|
    poi.should_receive(:creator)
  end
  flexstub(pointer) do |poi|
    poi.should_receive(:"+").and_return(pointer)
  end
  flexstub(@app.system) do |sys|
    sys.should_receive(:update).and_return(flexmock('user_or_invoice') do |ui|
      ui.should_receive(:pointer).and_return(pointer)
      ui.should_receive(:payment_received!)
      ui.should_receive(:add_invoice)
      ui.should_receive(:odba_isolated_store).and_return('odba_isolated_store')
    end)
  end
  assert_equal('odba_isolated_store', @app.inject_poweruser('email', 'pass', 10.0))
end

- (Object) test_invoice



1524
1525
1526
1527
# File 'test/test_util/oddbapp.rb', line 1524

def test_invoice
  @app.invoices = {123 => 'invoice'}
  assert_equal('invoice', @app.invoice('123'))
end

- (Object) test_ipn



913
914
915
916
917
918
# File 'test/test_util/oddbapp.rb', line 913

def test_ipn
  flexmock(ODDB::Util::Ipn) do |ipn|
    ipn.should_receive(:process).once.with('notification', ODDB::App)
  end
  assert_equal(nil, @app.ipn('notification'))
end

- (Object) test_last_medication_update

def test_patinfo_count

                @app.registrations = {
                        'reg1'  =>      StubRegistration.new,
                        'reg2'  =>      StubRegistration.new,
                        'reg3'  =>      StubRegistration.new,
                }
                @app.instance_variable_get('@system').instance_variable_set('@patinfo_count', nil)
                count = @app.patinfo_count
                assert_equal(9,count)
        end


750
751
752
753
754
755
756
# File 'test/test_util/oddbapp.rb', line 750

def test_last_medication_update
  @app.last_medication_update = Date.new(1977-07-07)
  @app.create(ODDB::Persistence::Pointer.new([:atc_class, 'A']))
  expected = Date.today
  result = @app.last_medication_update
  assert_equal(expected, result)
end

- (Object) test_last_medication_update2



757
758
759
760
761
762
763
# File 'test/test_util/oddbapp.rb', line 757

def test_last_medication_update2
  @app.last_medication_update = Date.new(1977-07-07)
  @app.create(ODDB::Persistence::Pointer.new([:generic_group, 'GNGRP']))
  expected = Date.new(1977-07-07)
  result = @app.last_medication_update
  assert_equal(expected, result)
end

- (Object) test_login



870
871
872
873
874
875
876
877
878
879
880
# File 'test/test_util/oddbapp.rb', line 870

def 
  @yus ||= flexmock('yus')
  flexmock(ODDB::App::YUS_SERVER) do |yus|
    yus.should_receive(:login)
    yus.should_receive(:login_token)
  end
  flexmock(ODDB::YusUser) do |yus|
    yus.should_receive(:new).and_return(@yus)
  end
  assert_equal(@yus, @app.('email','pass'))
end

- (Object) test_login_token



881
882
883
884
885
886
887
888
889
890
891
# File 'test/test_util/oddbapp.rb', line 881

def 
  @yus ||= flexmock('yus')
  flexmock(ODDB::App::YUS_SERVER) do |yus|
    yus.should_receive(:login)
    yus.should_receive(:login_token)
  end
  flexmock(ODDB::YusUser) do |yus|
    yus.should_receive(:new).and_return(@yus)
  end
  assert_equal(@yus.class, @app.('email', 'token').class)
end

- (Object) test_logout



892
893
894
895
896
897
# File 'test/test_util/oddbapp.rb', line 892

def test_logout
  flexmock(ODDB::App::YUS_SERVER) do |yus|
    yus.should_receive(:logout).and_return('logout')
  end
  assert_equal('logout', @app.logout('session'))
end

- (Object) test_merge_commercial_forms



1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
# File 'test/test_util/oddbapp.rb', line 1221

def test_merge_commercial_forms
  source = flexmock('source') do |sou|
    sou.should_receive(:pointer)
  end
  target = flexmock('target') do |tar|
    tar.should_receive(:pointer)
  end
  command = flexmock('command') do |com|
      com.should_receive(:execute)
  end
  flexstub(ODDB::MergeCommand) do |klass|
    klass.should_receive(:new).and_return(command)
  end
  assert_equal(nil, @app.merge_commercial_forms(source, target))
end

- (Object) test_merge_companies



1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
# File 'test/test_util/oddbapp.rb', line 1236

def test_merge_companies
  source = flexmock('source') do |sou|
    sou.should_receive(:pointer)
  end
  target = flexmock('target') do |tar|
    tar.should_receive(:pointer)
  end
  command = flexmock('command') do |com|
    com.should_receive(:execute)
  end
  flexstub(ODDB::MergeCommand) do |klass|
    klass.should_receive(:new).and_return(command)
  end
  assert_equal(nil, @app.merge_companies(source, target))
end

- (Object) test_merge_galenic_forms



1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
# File 'test/test_util/oddbapp.rb', line 1251

def test_merge_galenic_forms
  source = flexmock('source') do |sou|
    sou.should_receive(:pointer)
  end
  target = flexmock('target') do |tar|
    tar.should_receive(:pointer)
  end
  command = flexmock('command') do |com|
    com.should_receive(:execute)
  end
  flexstub(ODDB::MergeCommand) do |klass|
    klass.should_receive(:new).and_return(command)
  end
  assert_equal(nil, @app.merge_galenic_forms(source, target))
end

- (Object) test_merge_indications



1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
# File 'test/test_util/oddbapp.rb', line 1266

def test_merge_indications
source = flexmock('source') do |sou|
  sou.should_receive(:pointer)
end
target = flexmock('target') do |tar|
  tar.should_receive(:pointer)
end
command = flexmock('command') do |com|
  com.should_receive(:execute)
end
flexstub(ODDB::MergeCommand) do |klass|
  klass.should_receive(:new).and_return(command)
end
assert_equal(nil, @app.merge_indications(source, target))
end

- (Object) test_merge_substances



1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
# File 'test/test_util/oddbapp.rb', line 1281

def test_merge_substances
  source = flexmock('source') do |sou|
    sou.should_receive(:pointer)
  end
  target = flexmock('target') do |tar|
    tar.should_receive(:pointer)
  end
  command = flexmock('command') do |com|
    com.should_receive(:execute)
  end
  flexstub(ODDB::MergeCommand) do |klass|
    klass.should_receive(:new).and_return(command)
  end
  assert_equal(nil, @app.merge_substances(source, target))
end

- (Object) test_migel_count



1148
1149
1150
# File 'test/test_util/oddbapp.rb', line 1148

def test_migel_count
  assert_equal(0, @app.migel_count)
end

- (Object) test_migel_product



1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
# File 'test/test_util/oddbapp.rb', line 1502

def test_migel_product
  subgroup = flexmock('subgroup') do |sub|
    sub.should_receive(:product).and_return('product')
  end
  group = flexmock('group') do |grp|
    grp.should_receive(:subgroup).and_return(subgroup)
  end
  @app.migel_groups = {'1' => group}
  assert_equal('product', @app.migel_product('1.2.3'))
end

- (Object) test_migel_product__error



1512
1513
1514
1515
# File 'test/test_util/oddbapp.rb', line 1512

def test_migel_product__error
  @app.migel_groups = {'1' => 'group'}
  assert_equal(nil, @app.migel_product('1.2.3'))
end

- (Object) test_migel_products



1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
# File 'test/test_util/oddbapp.rb', line 1492

def test_migel_products
  subgroup = flexmock('subgroup') do |grp|
    grp.should_receive(:products).and_return({'product' => 'product'})
  end
  group = flexmock('group') do |grp|
    grp.should_receive(:subgroups).and_return({'subgroup' => subgroup})
  end
  @app.migel_groups = {'group' => group}
  assert_equal(['product'], @app.migel_products)
end

- (Object) test_multilinguify_analysis



1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
# File 'test/test_util/oddbapp.rb', line 1628

def test_multilinguify_analysis
  flexstub(@app) do |app|
    app.should_receive(:system).and_return(@app.instance_eval('@system'))
  end
  flexstub(@app.system) do |sys|
    sys.should_receive(:update)
  end
  pointer = flexmock('pointer') do |ptr|
    ptr.should_receive(:creator)
  end
  flexstub(pointer) do |ptr|
    ptr.should_receive(:+).and_return(pointer)
  end
  position = flexmock('position') do |pos|
    pos.should_receive(:description).and_return('description')
    pos.should_receive(:pointer).and_return(pointer)
    pos.should_receive(:footnote).and_return('footnote')
    pos.should_receive(:list_title).and_return('list_title')
    pos.should_receive(:taxnote).and_return('taxnote')
    pos.should_receive(:permissions).and_return('permissions')
    pos.should_receive(:odba_store).and_return('odba_store')
  end
  position.instance_variable_set('@limitation', 'limitation')
  group = flexmock('group') do |grp|
    grp.should_receive(:positions).and_return({'key'=>position})
  end
  @app.analysis_groups = {'key'=>group}
  assert_equal([position], @app.multilinguify_analysis)
end

- (Object) test_narcotic



1528
1529
1530
1531
# File 'test/test_util/oddbapp.rb', line 1528

def test_narcotic
  @app.narcotics = {123 => 'narcotics'}
  assert_equal('narcotics', @app.narcotic('123'))
end

- (Object) test_narcotic_by_casrn



843
844
845
846
847
848
849
850
851
# File 'test/test_util/oddbapp.rb', line 843

def test_narcotic_by_casrn
  narc1 = FlexMock.new
  narc1.should_receive(:casrn).and_return { 'foo-bar' }
  narc2 = FlexMock.new
  narc2.should_receive(:casrn).and_return {  }
  @app.narcotics.update({ 1 => narc1, 2 => narc2 })
  assert_equal(narc1, @app.narcotic_by_casrn('foo-bar'))
  assert_nil(@app.narcotic_by_casrn('x-bar'))
end

- (Object) test_narcotic_by_smcd



852
853
854
855
856
857
858
859
860
# File 'test/test_util/oddbapp.rb', line 852

def test_narcotic_by_smcd
  narc1 = FlexMock.new
  narc1.should_receive(:swissmedic_codes).and_return { ['foo-bar'] }
  narc2 = FlexMock.new
  narc2.should_receive(:swissmedic_codes).and_return { [] }
  @app.narcotics.update({ 1 => narc1, 2 => narc2 })
  assert_equal(narc1, @app.narcotic_by_smcd('foo-bar'))
  assert_nil(@app.narcotic_by_smcd('x-bar'))
end

- (Object) test_narcotics_count



1175
1176
1177
# File 'test/test_util/oddbapp.rb', line 1175

def test_narcotics_count
  assert_equal(0, @app.narcotics_count)
end

- (Object) test_package_by_ikskey



1562
1563
1564
1565
1566
1567
1568
# File 'test/test_util/oddbapp.rb', line 1562

def test_package_by_ikskey
  registration = flexmock('registration') do |reg|
    reg.should_receive(:package).and_return('package')
  end
  @app.registrations = {'12345' => registration}
  assert_equal('package', @app.package_by_ikskey('12345678'))
end

- (Object) test_package_count



728
729
730
731
732
733
734
735
736
737
# File 'test/test_util/oddbapp.rb', line 728

def test_package_count
  @app.registrations = {
    'reg1' =>  StubRegistration.new,
    'reg2' =>  StubRegistration.new,
    'reg3' =>  StubRegistration.new,
  }
  @app.instance_variable_get('@system').instance_variable_set('@package_count', nil)
  count = @app.package_count
  assert_equal(9,count)
end

- (Object) test_patinfo_count



1151
1152
1153
# File 'test/test_util/oddbapp.rb', line 1151

def test_patinfo_count
  assert_equal(0, @app.patinfo_count)
end

- (Object) test_peer_cache



901
902
903
904
905
906
# File 'test/test_util/oddbapp.rb', line 901

def test_peer_cache
  flexmock(ODBA) do |odba|
    odba.should_receive(:peer).once.with('cache').and_return('peer')
  end
  assert_equal('peer', @app.peer_cache('cache'))
end

- (Object) test_rebuild_indices



1450
1451
1452
1453
1454
1455
1456
# File 'test/test_util/oddbapp.rb', line 1450

def test_rebuild_indices
  flexstub(ODBA.cache) do |cache|
    cache.should_receive(:indices).and_return([])
    cache.should_receive(:create_index)
  end
  assert_equal(nil, @app.rebuild_indices)
end

- (Object) test_recent_registration_count



1154
1155
1156
# File 'test/test_util/oddbapp.rb', line 1154

def test_recent_registration_count
  assert_equal(0, @app.recent_registration_count)
end

- (Object) test_refactor_addresses



1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
# File 'test/test_util/oddbapp.rb', line 1835

def test_refactor_addresses
  company = hospital = doctor = flexmock('mock') do |mock|
    mock.should_receive(:refactor_addresses)
    mock.should_receive(:odba_store)
  end
  @app.doctors   = {'key' => doctor}
  @app.hospitals = {'key' => hospital}
  @app.companies = {'key' => company}
  assert_equal($stdout.flush, @app.refactor_addresses)
end

- (Object) test_registration



226
227
228
229
230
231
232
# File 'test/test_util/oddbapp.rb', line 226

def test_registration
  reg = StubRegistration.new('12345')
  @app.registrations = {'12345'=>reg}
  assert_equal(reg, @app.registration('12345'))
  assert_equal('12345', @app.registration('12345').iksnr)
  assert_nil(@app.registration('54321'))
end

- (Object) test_replace_fachinfo



1802
1803
1804
# File 'test/test_util/oddbapp.rb', line 1802

def test_replace_fachinfo
  assert_equal(nil, @app.replace_fachinfo('iksnr', 'pointer'))
end

- (Object) test_reset



898
899
900
# File 'test/test_util/oddbapp.rb', line 898

def test_reset
  assert_equal({}, @app.reset)
end

- (Object) test_resolve



1829
1830
1831
1832
1833
1834
# File 'test/test_util/oddbapp.rb', line 1829

def test_resolve
  pointer = flexmock('pointer') do |ptr|
    ptr.should_receive(:resolve).and_return('resolve')
  end
  assert_equal('resolve', @app.resolve(pointer))
end

- (Object) test_run_random_updater



1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
# File 'test/test_util/oddbapp.rb', line 1752

def test_run_random_updater 
  # this test-case is meaningless at the moment
  flexstub(ODDB::Updater) do |klass|
    klass.should_receive(:new).and_return(flexmock('updater') do |up|
      up.should_receive(:run_random)
    end)
  end
  flexstub(@app) do |app|
    app.should_receive(:sleep)
  end
  thread = @app.run_random_updater
  sleep(0.5)
  thread.kill
  assert(true)
end

- (Object) test_search_analysis



1823
1824
1825
# File 'test/test_util/oddbapp.rb', line 1823

def test_search_analysis
  assert_equal([], @app.search_analysis('key', 'en'))
end

- (Object) test_search_analysis_alphabetical



1826
1827
1828
# File 'test/test_util/oddbapp.rb', line 1826

def test_search_analysis_alphabetical
  assert_equal([], @app.search_analysis_alphabetical('query', 'en'))
end

- (Object) test_search_companies



1660
1661
1662
# File 'test/test_util/oddbapp.rb', line 1660

def test_search_companies
  assert_equal([], @app.search_companies('key'))
end

- (Object) test_search_doctors



1657
1658
1659
# File 'test/test_util/oddbapp.rb', line 1657

def test_search_doctors
  assert_equal([], @app.search_doctors('key'))
end

- (Object) test_search_exact_company



1663
1664
1665
1666
1667
1668
1669
# File 'test/test_util/oddbapp.rb', line 1663

def test_search_exact_company
  expected = ODDB::SearchResult.new
  expected.atc_classes = []
  expected.search_type = :company
  #assert_equal(expected, @app.search_exact_company('query'))
  assert(same?(expected, @app.search_exact_company('query')))
end

- (Object) test_search_exact_indication



1670
1671
1672
1673
1674
1675
1676
1677
# File 'test/test_util/oddbapp.rb', line 1670

def test_search_exact_indication
  expected = ODDB::SearchResult.new
  expected.atc_classes = []
  expected.search_type = :indication
  expected.exact = true
  #assert_equal(expected, @app.search_exact_indication('query', 'lang'))
  assert(same?(expected, @app.search_exact_indication('query', 'lang')))
end

- (Object) test_search_exact_sequence



1706
1707
1708
1709
1710
1711
1712
# File 'test/test_util/oddbapp.rb', line 1706

def test_search_exact_sequence
  expected = ODDB::SearchResult.new
  expected.atc_classes = []
  expected.search_type = :sequence
  #assert_equal(expected, @app.search_exact_sequence('query'))
  assert(same?(expected, @app.search_exact_sequence('query')))
end

- (Object) test_search_exact_substance



1713
1714
1715
1716
1717
1718
1719
# File 'test/test_util/oddbapp.rb', line 1713

def test_search_exact_substance
  expected = ODDB::SearchResult.new
  expected.atc_classes = []
  expected.search_type = :substance
  #assert_equal(expected, @app.search_exact_substance('query'))
  assert(same?(expected, @app.search_exact_substance('query')))
end

- (Object) test_search_hospitals



1720
1721
1722
# File 'test/test_util/oddbapp.rb', line 1720

def test_search_hospitals
  assert_equal([], @app.search_hospitals('key'))
end

- (Object) test_search_indications



1723
1724
1725
# File 'test/test_util/oddbapp.rb', line 1723

def test_search_indications
  assert_equal([], @app.search_indications('query'))
end

- (Object) test_search_interactions



1726
1727
1728
# File 'test/test_util/oddbapp.rb', line 1726

def test_search_interactions
  assert_equal([], @app.search_interactions('query'))
end

- (Object) test_search_migel_alphabetical



1678
1679
1680
# File 'test/test_util/oddbapp.rb', line 1678

def test_search_migel_alphabetical
  assert_equal([], @app.search_migel_alphabetical('query', 'lang'))
end

- (Object) test_search_migel_products



1681
1682
1683
# File 'test/test_util/oddbapp.rb', line 1681

def test_search_migel_products
  assert_equal([], @app.search_migel_products('query', 'lang'))
end

- (Object) test_search_narcotics



1684
1685
1686
# File 'test/test_util/oddbapp.rb', line 1684

def test_search_narcotics
  assert_equal([], @app.search_narcotics('query', 'lang'))
end

- (Object) test_search_oddb



1088
1089
1090
1091
1092
1093
1094
# File 'test/test_util/oddbapp.rb', line 1088

def test_search_oddb
  expected = ODDB::SearchResult.new
  expected.atc_classes = []
  expected.search_type=:unwanted_effect
  #assert_equal(expected, @app.search_oddb('query', 'lang'))
  assert(same?(expected, @app.search_oddb('query', 'lang')))
end

- (Object) test_search_oddb__atc_class



1095
1096
1097
1098
1099
1100
1101
1102
1103
# File 'test/test_util/oddbapp.rb', line 1095

def test_search_oddb__atc_class
  expected = ODDB::SearchResult.new
  expected.atc_classes = ['atc']
  expected.search_type=:atcless
  expected.search_query = 'atcless'
  expected.exact = true
  #assert_equal(expected, @app.search_oddb('atcless', 'lang'))
  assert(same?(expected, @app.search_oddb('atcless', 'lang')))
end

- (Object) test_search_oddb__iksnr



1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
# File 'test/test_util/oddbapp.rb', line 1104

def test_search_oddb__iksnr
  reg = flexmock('registration') do |reg|
    reg.should_receive(:sequences).and_return({})
  end
  @app.registrations = {'12345'=>reg}
  expected = ODDB::SearchResult.new
  expected.atc_classes = ['atc']
  expected.search_type=:iksnr
  expected.search_query = '12345'
  expected.exact = true
  #assert_equal(expected, @app.search_oddb('12345', 'lang'))
  assert(same?(expected, @app.search_oddb('12345', 'lang')))
end

- (Object) test_search_oddb__pharmacode



1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
# File 'test/test_util/oddbapp.rb', line 1117

def test_search_oddb__pharmacode
  package = flexmock('package') do |pac|
    pac.should_receive(:"sequence.seqnr")
    pac.should_receive(:registration)
    pac.should_receive(:ikscd)
  end
  flexstub(ODDB::Package) do |pac|
    pac.should_receive(:find_by_pharmacode).and_return(package)
  end
  expected = ODDB::SearchResult.new
  expected.atc_classes = ['atc']
  expected.search_type=:pharmacode
  expected.search_query = '123456'
  expected.exact = true

  #assert_equal(expected, @app.search_oddb('123456', 'lang'))
  assert(same?(expected, @app.search_oddb('123456', 'lang')))
end

- (Object) test_search_patinfos



1687
1688
1689
# File 'test/test_util/oddbapp.rb', line 1687

def test_search_patinfos
  assert_equal([], @app.search_patinfos('query'))
end

- (Object) test_search_sequences



1703
1704
1705
# File 'test/test_util/oddbapp.rb', line 1703

def test_search_sequences
  assert_equal([], @app.search_sequences('query'))
end

- (Object) test_search_substances



1729
1730
1731
# File 'test/test_util/oddbapp.rb', line 1729

def test_search_substances
  assert_equal([], @app.search_substances('query'))
end

- (Object) test_search_vaccines



1690
1691
1692
# File 'test/test_util/oddbapp.rb', line 1690

def test_search_vaccines
  assert_equal([], @app.search_vaccines('query'))
end

- (Object) test_sequences



1732
1733
1734
1735
1736
1737
1738
# File 'test/test_util/oddbapp.rb', line 1732

def test_sequences
  registration = flexmock('registration') do |reg|
    reg.should_receive(:sequences).and_return({'key' => 'sequence'})
  end
  @app.registrations = {'key' => registration}
  assert_equal(['sequence'], @app.sequences)
end

- (Object) test_slate



1739
1740
1741
1742
# File 'test/test_util/oddbapp.rb', line 1739

def test_slate
  @app.slates = {'name' => 'slate'}
  assert_equal('slate', @app.slate('name'))
end

- (Object) test_sorted_fachinfos



1743
1744
1745
# File 'test/test_util/oddbapp.rb', line 1743

def test_sorted_fachinfos
  assert_equal([], @app.sorted_fachinfos)
end

- (Object) test_sorted_feedbacks



1746
1747
1748
# File 'test/test_util/oddbapp.rb', line 1746

def test_sorted_feedbacks
  assert_equal([], @app.sorted_feedbacks)
end

- (Object) test_sorted_minifis



1749
1750
1751
# File 'test/test_util/oddbapp.rb', line 1749

def test_sorted_minifis
  assert_equal([], @app.sorted_minifis)
end

- (Object) test_sorted_patented_registrations



1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
# File 'test/test_util/oddbapp.rb', line 1865

def test_sorted_patented_registrations
  patent = flexmock('patent') do |pat|
    pat.should_receive(:expiry_date).and_return(true)
  end
  registration = flexmock('registration') do |reg|
    reg.should_receive(:patent).and_return(patent)
  end
  @app.registrations = {'key' => registration}
  assert_equal([registration], @app.sorted_patented_registrations)
end

- (Object) test_sponsor



1875
1876
1877
1878
# File 'test/test_util/oddbapp.rb', line 1875

def test_sponsor
  @app.sponsors = {'flavor' => 'sponsor'}
  assert_equal('sponsor', @app.('flavor'))
end

- (Object) test_substance



666
667
668
669
670
671
# File 'test/test_util/oddbapp.rb', line 666

def test_substance
  substance = ODDB::Substance.new
  substance.descriptions[:de] = 'ACIDUM ACETYLSALICYLICUM'
  @app.substances = {substance.name.downcase => substance}
  assert_equal(substance, @app.substance('ACIDUM ACETYLSALICYLICUM') )
end

- (Object) test_substance2



672
673
674
675
676
# File 'test/test_util/oddbapp.rb', line 672

def test_substance2
  substance = ODDB::Substance.new
  @app.substances = {substance.oid => substance}
  assert_equal(substance, @app.substance(substance.oid) )
end

- (Object) test_substance_by_connection_key



677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
# File 'test/test_util/oddbapp.rb', line 677

def test_substance_by_connection_key
  substance = FlexMock.new('substance')
  @app.substances = { 'connection key' => substance }
  substance.should_receive(:has_connection_key?).with('valid key')\
              .times(1).and_return {
    true
  }
  result = @app.substance_by_connection_key('valid key')
  assert_equal(substance, result)
  substance.should_receive(:has_connection_key?).with('invalid key')\
              .times(1).and_return {
    false
  }
  result = @app.substance_by_connection_key('invalid key')
  assert_equal(nil, result)
end

- (Object) test_substance_by_smcd



861
862
863
864
865
866
867
868
869
# File 'test/test_util/oddbapp.rb', line 861

def test_substance_by_smcd
  sub1 = FlexMock.new
  sub1.should_receive(:swissmedic_code).and_return { 'SMCD' }
  sub2 = FlexMock.new
  sub2.should_receive(:swissmedic_code).and_return {  }
  @app.substances = { 1 => sub1, 2 => sub2 }
  assert_equal(sub1, @app.substance_by_smcd('SMCD'))
  assert_nil(@app.substance_by_smcd('unknown'))
end

- (Object) test_substance_count



1178
1179
1180
# File 'test/test_util/oddbapp.rb', line 1178

def test_substance_count
  assert_equal(0, @app.substance_count)
end

- (Object) test_unique_atc_class



639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
# File 'test/test_util/oddbapp.rb', line 639

def test_unique_atc_class
  atc_array = []
  ODBA.cache.retrieve_from_index = atc_array
  assert_nil(@app.unique_atc_class('substance'))

  atc1 = FlexMock.new('ATC1')
  atc_array = [atc1]
  ODBA.cache.retrieve_from_index = atc_array
  assert_equal(atc1, @app.unique_atc_class('substance'))

  atc2 = FlexMock.new('ATC2')
  atc_array = [atc1]
  ODBA.cache.retrieve_from_index = atc_array
  assert_equal(atc1, @app.unique_atc_class('substance'))
  ODBA.cache.retrieve_from_index = nil
end

- (Object) test_unknown_user



223
224
225
# File 'test/test_util/oddbapp.rb', line 223

def test_unknown_user
  assert_instance_of(ODDB::UnknownUser, @app.unknown_user)
end

- (Object) test_unpeer_cache



907
908
909
910
911
912
# File 'test/test_util/oddbapp.rb', line 907

def test_unpeer_cache
  flexmock(ODBA) do |odba|
    odba.should_receive(:unpeer).once.with('cache').and_return('unpeer')
  end
  assert_equal('unpeer', @app.unpeer_cache('cache'))
end

- (Object) test_update_feedback_rss_feed



1787
1788
1789
1790
1791
1792
# File 'test/test_util/oddbapp.rb', line 1787

def test_update_feedback_rss_feed
  flexstub(@app) do |app|
    app.should_receive(:async).and_yield
  end
  assert_equal(nil, @app.update_feedback_rss_feed)
end

- (Object) test_update_feedback_rss_feed__error



1793
1794
1795
1796
1797
1798
1799
1800
1801
# File 'test/test_util/oddbapp.rb', line 1793

def test_update_feedback_rss_feed__error
  flexstub(@app) do |app|
    app.should_receive(:async).and_yield
  end
  flexstub(ODDB::Plugin) do |plg|
    plg.should_receive(:new).and_raise(StandardError)
  end
  assert_equal(nil, @app.update_feedback_rss_feed)
end

- (Object) test_update_indication



618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
# File 'test/test_util/oddbapp.rb', line 618

def test_update_indication
  @app.indications = {}
  pointer = ODDB::Persistence::Pointer.new(:indication)
  result = @app.create(pointer)
  values = {
    :la  => "Hypertonicum",
  }
  @app.update(result.pointer, values)
  assert_equal('Hypertonicum', result.la)
  assert_equal(result, @app.indication_by_text('Hypertonicum'))
  #assert_equal([result], @app.indication_index.fetch('hypertonicum'))
  values = {
    :la => "Coagulantium",
  }
  @app.update(result.pointer, values)
  assert_equal('Coagulantium', result.la)
  assert_equal(nil, @app.indication_by_text('Hypertonicum'))
  #assert_equal([], @app.indication_index.fetch('hypertonicum'))
  assert_equal(result, @app.indication_by_text('Coagulantium'))
  #assert_equal([result], @app.indication_index.fetch('coagulantium'))
end

- (Object) test_update_orphan_patinfo



799
800
801
802
803
804
805
806
807
808
809
810
811
# File 'test/test_util/oddbapp.rb', line 799

def test_update_orphan_patinfo
  update_hash = {
    'key'    => '12345',
    'de'      => 'iksnr',
  }
  orph = ODDB::OrphanedTextInfo.new
  @app.orphaned_patinfos = { 1 => orph }
  pointer = ODDB::Persistence::Pointer.new([:orphaned_patinfo, 1])
  orph.pointer = pointer
  @app.update(pointer, update_hash)
  assert_equal('12345', orph.key)
  assert_equal({'de' => 'iksnr'}, orph.descriptions)
end

- (Object) test_update_package



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'test/test_util/oddbapp.rb', line 319

def test_update_package
  pointer = ODDB::Persistence::Pointer.new(['registration', '12345'])
  reg = @app.create(pointer)
  pointer += ['sequence', '01']
  seq = @app.create(pointer)
  seq.packages = {}
  pointer += ['package', '032']
  result = @app.create(pointer)
  values = {
    'descr'          => nil,
    'ikscat'       => 'A',
  }
  @app.update(pointer, values)
  package = @app.registration('12345').package(32)
  assert_equal(nil, package.descr)
  assert_equal('A', package.ikscat)
end

- (Object) test_update_registration



242
243
244
245
246
247
248
249
250
251
# File 'test/test_util/oddbapp.rb', line 242

def test_update_registration
  pointer = ODDB::Persistence::Pointer.new(['registration', '12345'])
  @app.create(pointer)
  values = {
    :registration_date =>  '12.04.2002',
  }
  @app.update(pointer, values)
  reg = @app.registrations['12345']
  assert_equal(Date.new(2002,4,12), reg.registration_date)
end

- (Object) test_update_sequence



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'test/test_util/oddbapp.rb', line 272

def test_update_sequence
  pointer = ODDB::Persistence::Pointer.new(['registration', '12345'])
  reg = @app.create(pointer)
  pointer += ['sequence', '01']
  seq = @app.create(pointer)
  @app.atc_classes = { 'N02BA01' => ODDB::AtcClass.new('N02BA01') }
  grouppointer = ODDB::Persistence::Pointer.new(:galenic_group)
  galgroup = @app.create(grouppointer)
  galpointer = galgroup.pointer + [:galenic_form]
  @app.update(galpointer.creator, {:de => 'Tabletten'})
  values = {
    :name          => "Aspirin Cardio",
    :atc_class   => 'N02BA01',
  }
  @app.update(pointer, values)
  seq = @app.registration('12345').sequence('01')
  assert_equal('Aspirin Cardio', seq.name)
  assert_equal(@app.atc_class('N02BA01'), seq.atc_class)
end

- (Object) test_update_substance



362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'test/test_util/oddbapp.rb', line 362

def test_update_substance
  @app.substances = {}
  pointer = ODDB::Persistence::Pointer.new(:substance)
  descr = {
    'en'     =>  'first_name',
    :connection_keys =>  ['connection_key'],
  }
  subs = @app.update(pointer.creator, descr)
  values = {
    :en  => 'en_name',
    :de  => 'de_name',
  }
  @app.update(subs.pointer, values)
  assert_equal('En_name', subs.en)
  assert_equal(['connectionkey', 'firstname', 'enname', 'dename'].sort,
    subs.connection_keys.sort)
  assert_equal('De_name', subs.de)
  assert_equal({subs.oid, subs}, @app.substances)
end

- (Object) test_user



1879
1880
1881
1882
# File 'test/test_util/oddbapp.rb', line 1879

def test_user
  @app.users = {'oid' => 'user'}
  assert_equal('user', @app.user('oid'))
end

- (Object) test_user_by_email



1883
1884
1885
1886
1887
1888
1889
# File 'test/test_util/oddbapp.rb', line 1883

def test_user_by_email
  user = flexmock('user') do |usr|
    usr.should_receive(:unique_email).and_return('email')
  end
  @app.users = {'oid' => user}
  assert_equal(user, @app.user_by_email('email'))
end

- (Object) test_vaccine_count



1181
1182
1183
# File 'test/test_util/oddbapp.rb', line 1181

def test_vaccine_count
  assert_equal(0, @app.vaccine_count)
end

- (Boolean) test_yus_allowed?

Returns:

  • (Boolean)


919
920
921
# File 'test/test_util/oddbapp.rb', line 919

def test_yus_allowed?
  assert_equal('session', @app.yus_allowed?('email', 'action', 'key'))
end

- (Object) test_yus_create_user



1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
# File 'test/test_util/oddbapp.rb', line 1592

def test_yus_create_user
  @yus ||= flexmock('yus')
  flexmock(ODDB::App::YUS_SERVER) do |yus|
    yus.should_receive(:login)
    yus.should_receive(:login_token)
  end
  flexmock(ODDB::YusUser) do |yus|
    yus.should_receive(:new).and_return(@yus)
  end
  #assert_equal(@yus, @app.yus_create_user('email', 'pass'))
  assert_equal(@yus.class, @app.yus_create_user('email', 'pass').class)
end

- (Object) test_yus_get_preference



1607
1608
1609
# File 'test/test_util/oddbapp.rb', line 1607

def test_yus_get_preference
  assert_equal('session', @app.yus_get_preference('name', 'key'))
end

- (Object) test_yus_get_preferences



1610
1611
1612
# File 'test/test_util/oddbapp.rb', line 1610

def test_yus_get_preferences
  assert_equal('session', @app.yus_get_preferences('name', 'keys'))
end

- (Object) test_yus_get_preferences__error



1613
1614
1615
# File 'test/test_util/oddbapp.rb', line 1613

def test_yus_get_preferences__error
  assert_equal({}, @app.yus_get_preferences('error', 'error'))
end

- (Object) test_yus_grant



1604
1605
1606
# File 'test/test_util/oddbapp.rb', line 1604

def test_yus_grant
  assert_equal('session', @app.yus_grant('name', 'key', 'item', 'expires'))
end

- (Object) test_yus_model



1616
1617
1618
1619
1620
1621
# File 'test/test_util/oddbapp.rb', line 1616

def test_yus_model
  flexstub(ODBA.cache) do |cache|
    cache.should_receive(:fetch).once.with('odba_id', nil).and_return('yus_model')
  end
  assert_equal('yus_model', @app.yus_model('name'))
end

- (Object) test_yus_reset_password



1622
1623
1624
# File 'test/test_util/oddbapp.rb', line 1622

def test_yus_reset_password
  assert_equal('session', @app.yus_reset_password('name', 'token', 'password'))
end

- (Object) test_yus_set_preference



1625
1626
1627
# File 'test/test_util/oddbapp.rb', line 1625

def test_yus_set_preference
  assert_equal('session', @app.yus_set_preference('name', 'key', 'value', 'domain'))
end