aboutsummaryrefslogtreecommitdiff
path: root/t/steps
diff options
context:
space:
mode:
Diffstat (limited to 't/steps')
-rw-r--r--t/steps/rest-splitlang.t103
-rw-r--r--t/steps/rest-xml.t156
2 files changed, 0 insertions, 259 deletions
diff --git a/t/steps/rest-splitlang.t b/t/steps/rest-splitlang.t
deleted file mode 100644
index 10283b4..0000000
--- a/t/steps/rest-splitlang.t
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/bin/perl
-use strict;
-use warnings;
-use Path::Class;
-use Test::More 'no_plan';
-use Test::Differences;
-use WebCoso::Resource;
-
-BEGIN {use_ok('WebCoso::Step::ReST::SplitLang')}
-my $step=WebCoso::Step::ReST::SplitLang->new();
-
-sub make_res {
- my ($rst_doc,$key)=@_;
- $key||='datastream';
- my $resource=WebCoso::Resource->new();
- open my $rst_fh,'<',\$rst_doc;
- $resource->set_property({filename=>'mydoc.rest.txt'},$key=>$rst_fh);
-
- return $resource;
-}
-
-my $resource=make_res(<<'END_REST');
-riga comune
-.. lang::
-ancora comune
-.. lang:: it
-italiano
-.. lang:: en
-inglese
- .. lang::
- any nested
-.. lang:: it
-italiano ancora
-.. lang::
-comune (con spazi)
-END_REST
-
-
-$step->process($resource,'gen');
-is_deeply([$resource->get_axes()],
- ['filename'],
- 'no action on second pass');
-
-$step->process($resource,'meta');
-
-is_deeply([sort $resource->get_axes()],
- ['filename','language'],
- 'action on first pass');
-is_deeply([sort $resource->get_axis_values('language')],
- ['en','it'],
- 'lingue giuste');
-eq_or_diff($resource->get_property_string({language=>'it'},'rstdoc'),<<'END_REST_IT','italiano');
-riga comune
-ancora comune
-italiano
- any nested
-italiano ancora
-comune (con spazi)
-END_REST_IT
-
-eq_or_diff($resource->get_property_string({language=>'en'},'rstdoc'),<<'END_REST_EN','inglese');
-riga comune
-ancora comune
-inglese
- any nested
-comune (con spazi)
-END_REST_EN
-
-my $rst_doc=<<'END_REST';
-tutto a comune
-monolingua
-END_REST
-
-$resource=make_res($rst_doc);
-
-$step->process($resource,'meta');
-is_deeply([$resource->get_axes()],
- ['filename'],
- 'monolingua');
-eq_or_diff($resource->get_property_string('rstdoc'),$rst_doc,'monolingua cat');
-
-$rst_doc=<<'END_REST';
-.. lang::
-tutto a comune
-monolingua
-END_REST
-
-$resource=make_res($rst_doc);
-
-$step->process($resource,'meta');
-is_deeply([$resource->get_axes()],
- ['filename'],
- 'monolingua 2');
-eq_or_diff($resource->get_property_string('rstdoc'),$rst_doc,'monolingua 2 cat');
-
-# test per le chiavi arbitrarie
-$step=WebCoso::Step::ReST::SplitLang->new({from=>'source',to=>'dest'});
-$rst_doc=<<'END_REST';
-dati vari
-END_REST
-$resource=make_res($rst_doc,'source');
-$step->process($resource,'meta');
-eq_or_diff($resource->get_property_string('dest'),$rst_doc,'chiavi arbitrarie');
diff --git a/t/steps/rest-xml.t b/t/steps/rest-xml.t
deleted file mode 100644
index 1d9f956..0000000
--- a/t/steps/rest-xml.t
+++ /dev/null
@@ -1,156 +0,0 @@
-#!/usr/bin/perl
-use utf8;
-use strict;
-use warnings;
-use Path::Class;
-use Test::More 'no_plan';
-use Test::Differences;
-use Encode;
-use WebCoso::Resource;
-
-BEGIN {use_ok('WebCoso::Step::ReST::ToXml')}
-my $step=WebCoso::Step::ReST::ToXml->new();
-
-my $srckey='rstdoc';
-sub make_res {
- my $resource=WebCoso::Resource->new();
- # serve solo per il path
- $resource->set_property({filename=>'/tmp/mydoc.rest.txt'},datastream=>undef);
- if (@_==1) { # monolingua
- $resource->set_property($srckey=>$_[0]);
- }
- else { # multilingua
- my %rst_doc=@_;
- while (my ($lang,$str)=each %rst_doc) {
- $resource->set_property(
- {language=>$lang},
- $srckey=>$str
- );
- }
- }
-
- return $resource;
-}
-
-my $resource=make_res(<<'END_REST');
-Documento
-=========
-
-paragrafo àè
-END_REST
-
-$step->process($resource,'gen');
-ok(!defined $resource->get_property('xmldom'),'no action on second pass');
-
-$step->process($resource,'meta');
-my $dom=$resource->get_property('xmldom');
-isa_ok($dom,'XML::LibXML::Document','parsed ok on first pass');
-
-is($dom->findvalue('/document/@source'),
- '/tmp/mydoc.rest.txt',
- 'source path');
-is($dom->findvalue('/document/title'),
- 'Documento',
- 'title');
-is($dom->findvalue('count(/document/paragraph)'),
- 1,
- '1 paragraph');
-is($dom->findvalue('/document/paragraph'),
- 'paragrafo àè',
- 'paragraph content (unicode)');
-
-$resource=make_res(it=><<'END_REST_IT',en=><<'END_REST_EN');
-Documento
-=========
-
-paragrafo
-END_REST_IT
-Document
-========
-
-paragraph
-END_REST_EN
-
-$step->process($resource,'meta');
-$dom=$resource->get_property({language=>'it'},'xmldom');
-isa_ok($dom,'XML::LibXML::Document','parsed it');
-
-is($dom->findvalue('/document/@source'),
- '/tmp/mydoc.rest.txt',
- 'source path');
-is($dom->findvalue('/document/title'),
- 'Documento',
- 'title');
-is($dom->findvalue('/document/paragraph'),
- 'paragrafo',
- 'paragraph content');
-
-$dom=$resource->get_property({language=>'en'},'xmldom');
-isa_ok($dom,'XML::LibXML::Document','parsed en');
-
-is($dom->findvalue('/document/@source'),
- '/tmp/mydoc.rest.txt',
- 'source path');
-is($dom->findvalue('/document/title'),
- 'Document',
- 'title');
-is($dom->findvalue('/document/paragraph'),
- 'paragraph',
- 'paragraph content');
-
-# test per chiavi arbitrarie
-$step=WebCoso::Step::ReST::ToXml->new({from=>'rest',to=>'xml'});
-$srckey='rest';
-$resource=make_res(<<'END_REST');
-testo
-END_REST
-$step->process($resource,'meta');
-$dom=$resource->get_property('xml');
-isa_ok($dom,'XML::LibXML::Document','chiavi arbitrarie');
-
-# test dei metadati
-$step=WebCoso::Step::ReST::ToXml->new();
-$srckey='rstdoc';
-$resource=make_res(<<'END_REST');
-========
- Titolo
-========
-
-sottotitolo
-===========
-
-:Authors: - dakkar
- - doraemon
-:Version: 12
-:Status: draft
-:Date: 2006-02-07
-:CreationDate: 2006-01-30
-:Collections: - uno
- - due
- - tre
-
-testo
-
-END_REST
-$step->process($resource,'meta');
-my %meta_fields=(
- author => ['dakkar','doraemon'],
- title => 'Titolo',
- subtitle => 'sottotitolo',
- version => 12,
- status => 'draft',
- date => '2006-02-07',
- creation_date => '2006-01-30',
-);
-while (my ($f,$v)=each %meta_fields) {
- if (ref $v) {
- is_deeply([sort @{$resource->get_property($f)}],
- $v,
- "meta: $f");
- }
- else {
- is($resource->get_property($f),
- $v,
- "meta: $f");
- }
-}