gds-api-adapters 69.3.0 → 71.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,45 +0,0 @@
1
- module GdsApi
2
- module TestHelpers
3
- module PerformancePlatform
4
- module DataIn
5
- PP_DATA_IN_ENDPOINT = "http://www.performance.dev.gov.uk".freeze
6
-
7
- def stub_service_feedback_day_aggregate_submission(slug, request_body = nil)
8
- post_stub = stub_http_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/#{slug}/customer-satisfaction")
9
- post_stub.with(body: request_body) unless request_body.nil?
10
- post_stub.to_return(status: 200)
11
- end
12
-
13
- def stub_corporate_content_problem_report_count_submission(submissions = nil)
14
- post_stub = stub_http_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/gov-uk-content/feedback-count")
15
- post_stub.with(body: submissions.to_json) unless submissions.nil?
16
- post_stub.to_return(status: 200)
17
- end
18
-
19
- def stub_corporate_content_urls_with_the_most_problem_reports_submission(submissions = nil)
20
- post_stub = stub_http_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/gov-uk-content/top-urls")
21
- post_stub.with(body: submissions.to_json) unless submissions.nil?
22
- post_stub.to_return(status: 200)
23
- end
24
-
25
- def stub_problem_report_daily_totals_submission(submissions = nil)
26
- post_stub = stub_http_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/govuk-info/page-contacts")
27
- post_stub.with(body: submissions.to_json) unless submissions.nil?
28
- post_stub.to_return(status: 200)
29
- end
30
-
31
- def stub_service_feedback_bucket_unavailable_for(slug)
32
- stub_request(:post, "#{PP_DATA_IN_ENDPOINT}/data/#{slug}/customer-satisfaction").to_return(status: 404)
33
- end
34
-
35
- def stub_pp_isnt_available
36
- stub_request(:post, /#{PP_DATA_IN_ENDPOINT}\/.*/).to_return(status: 503)
37
- end
38
-
39
- def stub_pp_dataset_unavailable
40
- stub_request(:any, /#{PP_DATA_IN_ENDPOINT}/).to_return(status: 404)
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,98 +0,0 @@
1
- module GdsApi
2
- module TestHelpers
3
- module PerformancePlatform
4
- module DataOut
5
- PP_DATA_OUT_ENDPOINT = "https://www.performance.service.gov.uk".freeze
6
-
7
- def stub_service_feedback(slug, response_body = {})
8
- stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction")
9
- .to_return(status: 200, body: response_body.to_json)
10
- end
11
-
12
- def stub_data_set_not_available(slug)
13
- stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/#{slug}/customer-satisfaction")
14
- .to_return(status: 404)
15
- end
16
-
17
- def stub_service_not_available
18
- stub_request(:any, /#{PP_DATA_OUT_ENDPOINT}\/.*/).to_return(status: 503)
19
- end
20
-
21
- def stub_search_terms(slug, response_body = {})
22
- options = {
23
- slug: slug,
24
- transaction: "search-terms",
25
- group_by: "searchKeyword",
26
- collect: "searchUniques:sum",
27
- }
28
- stub_statistics(options, false, response_body)
29
- end
30
-
31
- def stub_searches(slug, is_multipart, response_body = {})
32
- options = {
33
- slug: slug,
34
- transaction: "search-terms",
35
- group_by: "pagePath",
36
- collect: "searchUniques:sum",
37
- }
38
- stub_statistics(options, is_multipart, response_body)
39
- end
40
-
41
- def stub_page_views(slug, is_multipart, response_body = {})
42
- options = {
43
- slug: slug,
44
- transaction: "page-statistics",
45
- group_by: "pagePath",
46
- collect: "uniquePageviews:sum",
47
- }
48
- stub_statistics(options, is_multipart, response_body)
49
- end
50
-
51
- def stub_problem_reports(slug, is_multipart, response_body = {})
52
- options = {
53
- slug: slug,
54
- transaction: "page-contacts",
55
- group_by: "pagePath",
56
- collect: "total:sum",
57
- }
58
- stub_statistics(options, is_multipart, response_body)
59
- end
60
-
61
- def stub_statistics(options, is_multipart, response_body = {})
62
- params = {
63
- group_by: options[:group_by],
64
- collect: options[:collect],
65
- duration: 42,
66
- period: "day",
67
- end_at: Date.today.to_time.getutc.iso8601,
68
- }
69
-
70
- filter_param = is_multipart ? :filter_by_prefix : :filter_by
71
- params[filter_param] = "pagePath:" + options[:slug]
72
-
73
- stub_http_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/#{options[:transaction]}")
74
- .with(query: params)
75
- .to_return(status: 200, body: response_body.to_json)
76
- end
77
-
78
- def stub_search_404(slug)
79
- stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/search-terms")
80
- .with(query: hash_including(filter_by: slug))
81
- .to_return(status: 404, headers: { content_type: "application/json" })
82
- end
83
-
84
- def stub_page_views_404(slug)
85
- stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-statistics")
86
- .with(query: hash_including(filter_by: slug))
87
- .to_return(status: 404, headers: { content_type: "application/json" })
88
- end
89
-
90
- def stub_problem_reports_404(slug)
91
- stub_request(:get, "#{PP_DATA_OUT_ENDPOINT}/data/govuk-info/page-contacts")
92
- .with(query: hash_including(filter_by: slug))
93
- .to_return(status: 404, headers: { content_type: "application/json" })
94
- end
95
- end
96
- end
97
- end
98
- end