From: Jason Stephenson Date: Fri, 22 Apr 2016 03:29:42 +0000 (-0400) Subject: LP#1573372: Opt-in test broken because it uses bail-out. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bb2b028a7d54e2663590ffc939e4bda71c8eedb4;p=evergreen%2Ftadl.git LP#1573372: Opt-in test broken because it uses bail-out. Use skip instead! Signed-off-by: Jason Stephenson Signed-off-by: Ben Shum --- diff --git a/Open-ILS/src/perlmods/live_t/12-lp1533329-opt-in.t b/Open-ILS/src/perlmods/live_t/12-lp1533329-opt-in.t index 31b69ab246..53337c611f 100644 --- a/Open-ILS/src/perlmods/live_t/12-lp1533329-opt-in.t +++ b/Open-ILS/src/perlmods/live_t/12-lp1533329-opt-in.t @@ -53,122 +53,121 @@ sub opt_in_check { return $resp; } -unless(opt_in_enabled()) { - BAIL_OUT('cannot test opt-in unless enabled in opensrf.xml'); -} +SKIP: { + skip 'cannot test opt-in unless enabled in opensrf.xml', 12 unless(opt_in_enabled()); + + #---------------------------------------------------------------- + # 1. Login, register workstation, get authtoken. + #---------------------------------------------------------------- + $script->authenticate({ + username => 'admin', + password => 'demo123', + type => 'staff'}); + ok( + $script->authtoken, + 'Have an authtoken' + ); + my $ws = $script->register_workstation(WORKSTATION_NAME,WORKSTATION_LIB); + ok( + ! ref $ws, + 'Registered a new workstation' + ); + $script->logout(); + $script->authenticate({ + username => 'admin', + password => 'demo123', + type => 'staff', + workstation => WORKSTATION_NAME}); + ok( + $script->authtoken, + 'Have an authtoken associated with the workstation' + ); + + #---------------------------------------------------------------- + # 2. Set org.patron_opt_boundary for SYS2, so that BR1 is outside + # the boundary. + #---------------------------------------------------------------- + $e->xact_begin; + my $boundary = new_org_setting(PATRON_SYS, 'org.patron_opt_boundary', SYS_DEPTH); + my $boundary_stat = $e->create_actor_org_unit_setting($boundary); + ok($boundary_stat, 'Opt boundary setting created successfully'); + $e->xact_commit; + + #---------------------------------------------------------------- + # 3. Check opt-in for test patron. It should return 0. + #---------------------------------------------------------------- + my $patron = $U->fetch_user_by_barcode(PATRON_BARCODE); + is( + opt_in_check($script->authtoken, $patron->id), + '0', + 'Opt-in check for non-opted-in patron correctly returned 0' + ); -#---------------------------------------------------------------- -# 1. Login, register workstation, get authtoken. -#---------------------------------------------------------------- -$script->authenticate({ - username => 'admin', - password => 'demo123', - type => 'staff'}); -ok( - $script->authtoken, - 'Have an authtoken' -); -my $ws = $script->register_workstation(WORKSTATION_NAME,WORKSTATION_LIB); -ok( - ! ref $ws, - 'Registered a new workstation' -); -$script->logout(); -$script->authenticate({ - username => 'admin', - password => 'demo123', - type => 'staff', - workstation => WORKSTATION_NAME}); -ok( - $script->authtoken, - 'Have an authtoken associated with the workstation' -); - -#---------------------------------------------------------------- -# 2. Set org.patron_opt_boundary for SYS2, so that BR1 is outside -# the boundary. -#---------------------------------------------------------------- -$e->xact_begin; -my $boundary = new_org_setting(PATRON_SYS, 'org.patron_opt_boundary', SYS_DEPTH); -my $boundary_stat = $e->create_actor_org_unit_setting($boundary); -ok($boundary_stat, 'Opt boundary setting created successfully'); -$e->xact_commit; - -#---------------------------------------------------------------- -# 3. Check opt-in for test patron. It should return 0. -#---------------------------------------------------------------- -my $patron = $U->fetch_user_by_barcode(PATRON_BARCODE); -is( - opt_in_check($script->authtoken, $patron->id), - '0', - 'Opt-in check for non-opted-in patron correctly returned 0' -); - -#---------------------------------------------------------------- -# 4. Set org.restrict_opt_to_depth at SYS2, so that BR1 is -# outside SYS2's section of the tree at the specified depth (thus -# preventing opt-in). -#---------------------------------------------------------------- -$e->xact_begin; -my $restrict = new_org_setting(PATRON_SYS, 'org.restrict_opt_to_depth', SYS_DEPTH); -my $restrict_stat = $e->create_actor_org_unit_setting($restrict); -ok($restrict_stat, 'Opt restrict depth setting created successfully'); -$e->xact_commit; - -#---------------------------------------------------------------- -# 5. Check opt-in for test patron. It should return 2. -#---------------------------------------------------------------- -is( - opt_in_check($script->authtoken, $patron->id), - '2', - 'Opt-in check for patron at restricted opt-in library correctly returned 2' -); - -#---------------------------------------------------------------- -# 6. Remove the org.restrict_opt_to_depth setting for SYS2. -#---------------------------------------------------------------- -$e->xact_begin; -my $delete_restrict_stat = $e->delete_actor_org_unit_setting($restrict); -ok($delete_restrict_stat, 'Opt restrict depth setting deleted successfully'); -$e->xact_commit; - -#---------------------------------------------------------------- -# 7. Create opt-in for test patron. -#---------------------------------------------------------------- -my $opt_id = $U->simplereq( - 'open-ils.actor', - 'open-ils.actor.user.org_unit_opt_in.create', - $script->authtoken, $patron->id, WORKSTATION_LIB); -ok($opt_id, 'Patron successfully opted in'); - -#---------------------------------------------------------------- -# 8. Check opt-in for test patron. It should return 1. -#---------------------------------------------------------------- -is( - opt_in_check($script->authtoken, $patron->id), - '1', - 'Opt-in check for opted-in patron correctly returned 1' -); - -#---------------------------------------------------------------- -# 9. Delete opt-in. -#---------------------------------------------------------------- -my $opt = $U->simplereq( - 'open-ils.cstore', - 'open-ils.cstore.direct.actor.usr_org_unit_opt_in.retrieve', - $opt_id -); -$e->xact_begin; -my $delete_opt_stat = $e->delete_actor_usr_org_unit_opt_in($opt); -ok($delete_opt_stat, 'Opt-in deleted successfully'); -$e->xact_commit; - -#---------------------------------------------------------------- -# 10. Remove opt boundary setting. -#---------------------------------------------------------------- -$e->xact_begin; -my $delete_setting_stat = $e->delete_actor_org_unit_setting($boundary); -ok($delete_setting_stat, 'Opt boundary setting deleted successfully'); -$e->xact_commit; + #---------------------------------------------------------------- + # 4. Set org.restrict_opt_to_depth at SYS2, so that BR1 is + # outside SYS2's section of the tree at the specified depth (thus + # preventing opt-in). + #---------------------------------------------------------------- + $e->xact_begin; + my $restrict = new_org_setting(PATRON_SYS, 'org.restrict_opt_to_depth', SYS_DEPTH); + my $restrict_stat = $e->create_actor_org_unit_setting($restrict); + ok($restrict_stat, 'Opt restrict depth setting created successfully'); + $e->xact_commit; + + #---------------------------------------------------------------- + # 5. Check opt-in for test patron. It should return 2. + #---------------------------------------------------------------- + is( + opt_in_check($script->authtoken, $patron->id), + '2', + 'Opt-in check for patron at restricted opt-in library correctly returned 2' + ); + + #---------------------------------------------------------------- + # 6. Remove the org.restrict_opt_to_depth setting for SYS2. + #---------------------------------------------------------------- + $e->xact_begin; + my $delete_restrict_stat = $e->delete_actor_org_unit_setting($restrict); + ok($delete_restrict_stat, 'Opt restrict depth setting deleted successfully'); + $e->xact_commit; + + #---------------------------------------------------------------- + # 7. Create opt-in for test patron. + #---------------------------------------------------------------- + my $opt_id = $U->simplereq( + 'open-ils.actor', + 'open-ils.actor.user.org_unit_opt_in.create', + $script->authtoken, $patron->id, WORKSTATION_LIB); + ok($opt_id, 'Patron successfully opted in'); + + #---------------------------------------------------------------- + # 8. Check opt-in for test patron. It should return 1. + #---------------------------------------------------------------- + is( + opt_in_check($script->authtoken, $patron->id), + '1', + 'Opt-in check for opted-in patron correctly returned 1' + ); + #---------------------------------------------------------------- + # 9. Delete opt-in. + #---------------------------------------------------------------- + my $opt = $U->simplereq( + 'open-ils.cstore', + 'open-ils.cstore.direct.actor.usr_org_unit_opt_in.retrieve', + $opt_id + ); + $e->xact_begin; + my $delete_opt_stat = $e->delete_actor_usr_org_unit_opt_in($opt); + ok($delete_opt_stat, 'Opt-in deleted successfully'); + $e->xact_commit; + + #---------------------------------------------------------------- + # 10. Remove opt boundary setting. + #---------------------------------------------------------------- + $e->xact_begin; + my $delete_setting_stat = $e->delete_actor_org_unit_setting($boundary); + ok($delete_setting_stat, 'Opt boundary setting deleted successfully'); + $e->xact_commit; +}