Index: openacs-4/packages/rss-support/rss-support.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rss-support/rss-support.info,v diff -u -r1.21.2.6 -r1.21.2.7 --- openacs-4/packages/rss-support/rss-support.info 16 Sep 2021 08:27:20 -0000 1.21.2.6 +++ openacs-4/packages/rss-support/rss-support.info 16 Mar 2023 14:25:41 -0000 1.21.2.7 @@ -8,7 +8,7 @@ <singleton-p>t</singleton-p> <auto-mount>rss-support</auto-mount> - <version name="0.5d2" url="http://openacs.org/repository/download/apm/rss-support-0.5d2.apm"> + <version name="0.5d3" url="http://openacs.org/repository/download/apm/rss-support-0.5d3.apm"> <owner url="mailto:aegrumet@alum.mit.edu">Andrew Grumet</owner> <owner url="mailto:jerry@theashergroup.com">Jerry Asher</owner> <owner url="mailto:dave@thedesignexperience.org">Dave Bauer</owner> @@ -34,7 +34,7 @@ </description> <maturity>2</maturity> - <provides url="rss-support" version="0.5d2"/> + <provides url="rss-support" version="0.5d3"/> <requires url="acs-kernel" version="5.10.0"/> <requires url="acs-tcl" version="5.10.0"/> Index: openacs-4/packages/rss-support/tcl/test/rss-generation-service-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/rss-support/tcl/test/rss-generation-service-procs.tcl,v diff -u -r1.1.2.3 -r1.1.2.4 --- openacs-4/packages/rss-support/tcl/test/rss-generation-service-procs.tcl 21 Oct 2021 11:55:53 -0000 1.1.2.3 +++ openacs-4/packages/rss-support/tcl/test/rss-generation-service-procs.tcl 16 Mar 2023 14:25:41 -0000 1.1.2.4 @@ -2,13 +2,93 @@ Tests for procs concerning RSS generation } +namespace eval rss {} +namespace eval rss::test {} + +ad_proc -private rss::test::datasource { + summary_context_id +} { + A dummy datasource implementation for testing purposes. +} { + set pretty_folder_url /test/afolder + + lappend items \ + [list \ + link "anitem" \ + title "A Title" \ + description "A description" \ + timestamp "2023-03-16 14:58:00" \ + enclosure_url "${pretty_folder_url}anitem" \ + enclosure_type file \ + enclosure_length 42] \ + [list \ + link "anitem2" \ + title "A Title 2" \ + description "A description 2" \ + timestamp "2023-03-16 14:58:00" \ + enclosure_url "${pretty_folder_url}anitem2" \ + enclosure_type file \ + enclosure_length 42] + + return [list \ + channel_title "Test title" \ + channel_description "Test description" \ + version 2.0 \ + channel_link $pretty_folder_url \ + image "" \ + channel_lastBuildDate 2023-03-16 \ + items $items \ + channel_language "" \ + channel_copyright "" \ + channel_managingEditor "" \ + channel_webMaster "" \ + channel_rating "" \ + channel_skipDays "" \ + channel_skipHours "" \ + ] +} + +ad_proc -private rss::test::lastUpdated { + summary_context_id +} { + @return a timestamp for testing purposes +} { + return "2023-03-16 14:58:00" +} + +ad_proc -private rss::test::require_impl_id {} { + Requires the dummy SC implementation. +} { + set impl_id [acs_sc::impl::get_id \ + -owner "rss-support" \ + -name "test_rss" \ + -contract "RssGenerationSubscriber"] + if {$impl_id eq ""} { + set impl_id [acs_sc::impl::new_from_spec -spec { + contract_name "RssGenerationSubscriber" + name "test_rss" + owner "rss-support" + aliases { + datasource rss::test::datasource + lastUpdated rss::test::lastUpdated + } + }] + } + + return $impl_id +} + +rss::test::require_impl_id + aa_register_case \ -cats {api smoke} \ -procs { rss_gen_report_file rss_gen_report rss_support::get_subscr_id rss_support::subscription_exists + rss_support::add_subscription + rss_support::del_subscription rss_gen rss_gen_091 rss_gen_100 @@ -17,48 +97,64 @@ rss__gen_report { Test rss_gen_report and other api } { - if {![db_0or1row get_data { - select summary_context_id, - impl_owner_name, - impl_name - from rss_gen_subscrs r, - acs_sc_impls i - where r.impl_id = i.impl_id - and i.impl_contract_name = 'RssGenerationSubscriber' - order by summary_context_id asc - fetch first 1 rows only - }]} { - aa_log "No RSS subscription found, exiting..." - return - } + aa_run_with_teardown -rollback -test_code { + set impl_id [rss::test::require_impl_id] - aa_true "rss_support::subscription_exists tells that a subscription exists" \ - [rss_support::subscription_exists \ - -summary_context_id $summary_context_id \ - -impl_name $impl_name] + set summary_context_id [db_string any_object_without_subscription { + select max(object_id) from acs_objects o + where not exists (select 1 from rss_gen_subscrs + where summary_context_id = o.object_id) + }] - set report_file [rss_gen_report_file \ - -summary_context_id $summary_context_id \ - -impl_name $impl_name] + set impl_owner_name rss-support + set impl_name test_rss - aa_log "Deleting '$report_file'" - file delete -- $report_file - aa_false "File '$report_file' does not exist" [file exists $report_file] + set subscription_id [rss_support::add_subscription \ + -summary_context_id $summary_context_id \ + -impl_name $impl_name \ + -owner $impl_owner_name] - aa_log "Generating the report" - set subscr_id [rss_support::get_subscr_id \ - -summary_context_id $summary_context_id \ - -impl_name $impl_name \ - -owner $impl_owner_name] - rss_gen_report $subscr_id + aa_true "rss_support::subscription_exists tells that a subscription exists" \ + [rss_support::subscription_exists \ + -summary_context_id $summary_context_id \ + -impl_name $impl_name] - aa_true "File '$report_file' was created as expected" [file exists $report_file] + aa_equals "API retrieves the subscription" \ + [rss_support::get_subscr_id \ + -summary_context_id $summary_context_id \ + -impl_name $impl_name \ + -owner $impl_owner_name] \ + $subscription_id - set rfd [open $report_file r] - set xml [read $rfd] - close $rfd + set report_file [rss_gen_report_file \ + -summary_context_id $summary_context_id \ + -impl_name $impl_name] - aa_false "File '$report_file' contains valid XML" [catch { - dom parse $xml doc - }] + aa_log "Deleting '$report_file'" + file delete -- $report_file + aa_false "File '$report_file' does not exist" [file exists $report_file] + + aa_log "Generating the report" + rss_gen_report $subscription_id + + aa_true "File '$report_file' was created as expected" [file exists $report_file] + + set rfd [open $report_file r] + set xml [read $rfd] + close $rfd + + aa_false "File '$report_file' contains valid XML" [catch { + dom parse $xml doc + }] + + rss_support::del_subscription \ + -summary_context_id $summary_context_id \ + -impl_name $impl_name \ + -owner $impl_owner_name + + aa_false "Subscription was deleted" [db_0or1row check { + select 1 from rss_gen_subscrs + where subscr_id = :subscription_id + }] + } }