aboutsummaryrefslogtreecommitdiffstats
path: root/t/open311/endpoint/spark.t
diff options
context:
space:
mode:
authorHakim Cassimally <hakim@mysociety.org>2014-03-13 16:56:02 +0000
committerHakim Cassimally <hakim@mysociety.org>2014-10-16 16:56:26 +0000
commitd1fee928f02dbc30d3a38b746155ce5b12be4a1b (patch)
tree5e8bdccbd69863e69098b9aa900c1e71745f8eb5 /t/open311/endpoint/spark.t
parent592f4c0ba0f822b55bb242cb12768ce771599d09 (diff)
Open311 Endpoint
Subsystems include * ::Spark encoding conventions for xml/json * ::Schema using Rx to validate form of inputs and outputs, including validation for, e.g., dates and CSV as part of Open311 Handles following paths: * Open311 attributes for Service Definition http://wiki.open311.org/GeoReport_v2#GET_Service_Definition * POST service request * GET Service Requests * GET Service Request Objects: * ::Service * ::Service::Request
Diffstat (limited to 't/open311/endpoint/spark.t')
-rw-r--r--t/open311/endpoint/spark.t64
1 files changed, 64 insertions, 0 deletions
diff --git a/t/open311/endpoint/spark.t b/t/open311/endpoint/spark.t
new file mode 100644
index 000000000..589f39baf
--- /dev/null
+++ b/t/open311/endpoint/spark.t
@@ -0,0 +1,64 @@
+use strict; use warnings;
+
+use Test::More;
+
+use Open311::Endpoint;
+use Data::Dumper;
+use JSON;
+
+my $endpoint = Open311::Endpoint->new;
+my $json = JSON->new;
+
+subtest "Spark test" => sub {
+ my $spark = $endpoint->spark;
+ my $struct = {
+ foo => {
+ service_requests => [ 1,2,3 ],
+ quxes => [
+ {
+ values => [1,2],
+ },
+ {
+ values => [3,4],
+ },
+ ],
+ },
+ };
+ is_deeply $spark->process_for_json($struct),
+ {
+ service_requests => [ 1,2,3 ],
+ quxes => [
+ {
+ values => [1,2],
+ },
+ {
+ values => [3,4],
+ },
+ ],
+ };
+
+ my $xml_struct = $spark->process_for_xml($struct);
+ is_deeply $xml_struct,
+ {
+ foo => {
+ service_requests => { request => [ 1,2,3 ] },
+ quxes => {
+ quxe => [
+ {
+ values => {
+ value => [1,2],
+ },
+ },
+ {
+ values => {
+ value => [3,4],
+ },
+ },
+ ]
+ },
+ }
+ }
+ or warn Dumper($xml_struct);
+};
+
+done_testing;