Module: GdsApi::TestHelpers::PerformancePlatform::DataOut
- Defined in:
- lib/gds_api/test_helpers/performance_platform/data_out.rb
Constant Summary collapse
- PP_DATA_OUT_ENDPOINT =
"https://www.performance.service.gov.uk".freeze
Instance Method Summary collapse
- #stub_data_set_not_available(slug) ⇒ Object
- #stub_page_views(slug, is_multipart, response_body = {}) ⇒ Object
- #stub_page_views_404(slug) ⇒ Object
- #stub_problem_reports(slug, is_multipart, response_body = {}) ⇒ Object
- #stub_problem_reports_404(slug) ⇒ Object
- #stub_search_404(slug) ⇒ Object
- #stub_search_terms(slug, response_body = {}) ⇒ Object
- #stub_searches(slug, is_multipart, response_body = {}) ⇒ Object
- #stub_service_feedback(slug, response_body = {}) ⇒ Object
- #stub_service_not_available ⇒ Object
- #stub_statistics(options, is_multipart, response_body = {}) ⇒ Object
Instance Method Details
#stub_data_set_not_available(slug) ⇒ Object
12 13 14 15 |
# File 'lib/gds_api/test_helpers/performance_platform/data_out.rb', line 12 def stub_data_set_not_available(slug) stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction") .to_return(status: 404) end |
#stub_page_views(slug, is_multipart, response_body = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/gds_api/test_helpers/performance_platform/data_out.rb', line 41 def stub_page_views(slug, is_multipart, response_body = {}) = { slug: slug, transaction: "page-statistics", group_by: "pagePath", collect: "uniquePageviews:sum", } stub_statistics(, is_multipart, response_body) end |
#stub_page_views_404(slug) ⇒ Object
84 85 86 87 88 |
# File 'lib/gds_api/test_helpers/performance_platform/data_out.rb', line 84 def stub_page_views_404(slug) stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-statistics") .with(query: hash_including(filter_by: slug)) .to_return(status: 404, headers: { content_type: "application/json" }) end |
#stub_problem_reports(slug, is_multipart, response_body = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/gds_api/test_helpers/performance_platform/data_out.rb', line 51 def stub_problem_reports(slug, is_multipart, response_body = {}) = { slug: slug, transaction: "page-contacts", group_by: "pagePath", collect: "total:sum", } stub_statistics(, is_multipart, response_body) end |
#stub_problem_reports_404(slug) ⇒ Object
90 91 92 93 94 |
# File 'lib/gds_api/test_helpers/performance_platform/data_out.rb', line 90 def stub_problem_reports_404(slug) stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-contacts") .with(query: hash_including(filter_by: slug)) .to_return(status: 404, headers: { content_type: "application/json" }) end |
#stub_search_404(slug) ⇒ Object
78 79 80 81 82 |
# File 'lib/gds_api/test_helpers/performance_platform/data_out.rb', line 78 def stub_search_404(slug) stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/search-terms") .with(query: hash_including(filter_by: slug)) .to_return(status: 404, headers: { content_type: "application/json" }) end |
#stub_search_terms(slug, response_body = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/gds_api/test_helpers/performance_platform/data_out.rb', line 21 def stub_search_terms(slug, response_body = {}) = { slug: slug, transaction: "search-terms", group_by: "searchKeyword", collect: "searchUniques:sum", } stub_statistics(, false, response_body) end |
#stub_searches(slug, is_multipart, response_body = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/gds_api/test_helpers/performance_platform/data_out.rb', line 31 def stub_searches(slug, is_multipart, response_body = {}) = { slug: slug, transaction: "search-terms", group_by: "pagePath", collect: "searchUniques:sum", } stub_statistics(, is_multipart, response_body) end |
#stub_service_feedback(slug, response_body = {}) ⇒ Object
7 8 9 10 |
# File 'lib/gds_api/test_helpers/performance_platform/data_out.rb', line 7 def stub_service_feedback(slug, response_body = {}) stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction") .to_return(status: 200, body: response_body.to_json) end |
#stub_service_not_available ⇒ Object
17 18 19 |
# File 'lib/gds_api/test_helpers/performance_platform/data_out.rb', line 17 def stub_service_not_available stub_request(:any, /#{PP_DATA_OUT_ENDPOINT}\/.*/).to_return(status: 503) end |
#stub_statistics(options, is_multipart, response_body = {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/gds_api/test_helpers/performance_platform/data_out.rb', line 61 def stub_statistics(, is_multipart, response_body = {}) params = { group_by: [:group_by], collect: [:collect], duration: 42, period: "day", end_at: Date.today.to_time.getutc.iso8601, } filter_param = is_multipart ? :filter_by_prefix : :filter_by params[filter_param] = "pagePath:" + [:slug] stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/#{[:transaction]}") .with(query: params) .to_return(status: 200, body: response_body.to_json) end |