[Bps-public-commit] SD branch, master, updated. b73e9d019515a7dc3c10b63a28e5d1fa898ebbae

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue Jun 2 06:35:03 EDT 2009


The branch, master has been updated
       via  b73e9d019515a7dc3c10b63a28e5d1fa898ebbae (commit)
       via  ba1029e36f1703653ec7733a61d8269461fd8cda (commit)
       via  e9f3a571d13c08f41f5c1094831649c30aca5c66 (commit)
      from  57aca1c12806ad1ce8e1b1a6d65ed8cb6a6c7769 (commit)

Summary of changes:
 lib/App/SD/Replica/trac/PullEncoder.pm |   10 +------
 t/sd-trac/basic.t                      |   45 ++++++++++++++++++++++++++++---
 t/sd-trac/setup_trac.pl                |    3 ++
 3 files changed, 44 insertions(+), 14 deletions(-)

- Log -----------------------------------------------------------------
commit e9f3a571d13c08f41f5c1094831649c30aca5c66
Author: sunnavy <sunnavy at gmail.com>
Date:   Tue Jun 2 17:50:46 2009 +0800

    remove the uesless translate_status sub of trac

diff --git a/lib/App/SD/Replica/trac/PullEncoder.pm b/lib/App/SD/Replica/trac/PullEncoder.pm
index 551a43a..a2fd2f1 100644
--- a/lib/App/SD/Replica/trac/PullEncoder.pm
+++ b/lib/App/SD/Replica/trac/PullEncoder.pm
@@ -37,7 +37,7 @@ sub translate_ticket_state {
         type => ($ticket_object->type || undef),
         created     => ( $ticket_object->created->ymd . " " . $ticket_object->created->hms ),
         reporter    => ( $ticket_object->reporter || undef ),
-        status      => $self->translate_status( $ticket_object->status ),
+        status      => ( $ticket_object->status  || undef ),
         summary     => ( $ticket_object->summary || undef ),
         description => ( $content||undef),
         tags        => ( $ticket_object->keywords || undef ),
@@ -327,14 +327,6 @@ sub _recode_attachment_create {
     $args{'changeset'}->add_change( { change => $change } );
 }
 
-sub translate_status {
-    my $self   = shift;
-    my $status = shift;
-
-    $status =~ s/^resolved$/closed/;
-    return $status;
-}
-
 my %PROP_MAP;
 sub translate_prop_names {
     my $self      = shift;

commit ba1029e36f1703653ec7733a61d8269461fd8cda
Author: sunnavy <sunnavy at gmail.com>
Date:   Tue Jun 2 17:57:16 2009 +0800

    attachment test for trac

diff --git a/t/sd-trac/basic.t b/t/sd-trac/basic.t
index f1c5d42..df405e4 100644
--- a/t/sd-trac/basic.t
+++ b/t/sd-trac/basic.t
@@ -14,7 +14,7 @@ unless (`which trac-admin`) { plan skip_all => 'You need trac installed to run t
 unless ( eval { require Net::Trac } ) {
     plan skip_all => 'You need Net::Trac installed to run the tests';
 }
-plan tests => 39;
+plan tests => 43;
 
 use_ok('Net::Trac::Connection');
 use_ok('Net::Trac::Ticket');
@@ -59,17 +59,23 @@ can_ok( $ticket, 'load' );
 ok( $ticket->load(1) );
 like( $ticket->state->{'summary'}, qr/pony/ );
 like( $ticket->summary, qr/moose/, "The summary looks like a moose" );
-ok( $ticket->update( summary => 'The product does not contain a pony' ), "updated!" );
+ok( $ticket->update( summary => 'The product does not contain a pony' ),
+    "updated!" );
 unlike( $ticket->summary, qr/moose/, "The summary does not look like a moose" );
 
+my ($fh, $filename) = File::Temp::tempfile(SUFFIX => '.txt');
+print $fh "TIMTOWTDI\n";
+close $fh;
+sleep 2; # to make trac happy
+ok($ticket->attach( file => $filename ), "Attaching file.");
+
 my $history = $ticket->history;
 ok( $history, "The ticket has some history" );
 my @entries = @{ $history->entries };
-is( scalar @entries, 2, "There are 2 txns");
+is( scalar @entries, 3, "There are 3 txns");
 my $first   = shift @entries;
 is( $first->category, 'Ticket' );
 
-
 # 
 # Clone from trac
 #
@@ -88,7 +94,6 @@ my $pony_id;
 # Check our clone from trac
 #
 
-
 run_output_matches(
     'sd',
     [ 'ticket', 'list', '--regex', '.' ],
@@ -97,6 +102,20 @@ run_output_matches(
 
 ok( $pony_id, "I got the ID of a pony - It's $pony_id" );
 
+my ( $att_id, $att_name );
+run_output_matches(
+    'sd',
+    [ 'attachment', 'list', ],
+    [qr!(\d+)(?{ $att_id = $1 }) (\S+)(?{$att_name=$2}) text/plain!]
+);
+
+like( $filename, qr/$att_name/, 'filename of attachment' );
+
+run_output_matches(
+    'sd',
+    [ 'attachment', 'content', $att_id ],
+    [qr/TIMTOWTDI/]
+);
 
 # 
 # Modify the ticket we pulled from trac

commit b73e9d019515a7dc3c10b63a28e5d1fa898ebbae
Author: sunnavy <sunnavy at gmail.com>
Date:   Tue Jun 2 18:25:30 2009 +0800

    add settings mirror test for trac

diff --git a/t/sd-trac/basic.t b/t/sd-trac/basic.t
index df405e4..bc4f1d8 100644
--- a/t/sd-trac/basic.t
+++ b/t/sd-trac/basic.t
@@ -14,7 +14,7 @@ unless (`which trac-admin`) { plan skip_all => 'You need trac installed to run t
 unless ( eval { require Net::Trac } ) {
     plan skip_all => 'You need Net::Trac installed to run the tests';
 }
-plan tests => 43;
+plan tests => 46;
 
 use_ok('Net::Trac::Connection');
 use_ok('Net::Trac::Ticket');
@@ -59,6 +59,8 @@ can_ok( $ticket, 'load' );
 ok( $ticket->load(1) );
 like( $ticket->state->{'summary'}, qr/pony/ );
 like( $ticket->summary, qr/moose/, "The summary looks like a moose" );
+
+sleep 2; # to make trac happy
 ok( $ticket->update( summary => 'The product does not contain a pony' ),
     "updated!" );
 unlike( $ticket->summary, qr/moose/, "The summary does not look like a moose" );
@@ -117,6 +119,20 @@ run_output_matches(
     [qr/TIMTOWTDI/]
 );
 
+run_ok( 'sd', [ 'settings', '-s' ] );
+my $settings = last_script_stdout();
+like(
+    $settings,
+    qr/active_statuses: \["new","accepted","assigned","reopened"\]/,
+    'active statuses setting'
+);
+
+like( $settings,
+qr/statuses: \["new","accepted","assigned","reopened","closed","fixed","invalid","wontfix","duplicate","worksforme","test_resolution"\]/,
+'statuses setting'
+);
+
+
 # 
 # Modify the ticket we pulled from trac
 
diff --git a/t/sd-trac/setup_trac.pl b/t/sd-trac/setup_trac.pl
index 5facace..7cf9b43 100644
--- a/t/sd-trac/setup_trac.pl
+++ b/t/sd-trac/setup_trac.pl
@@ -81,6 +81,9 @@ sub init {
     $url =~ s/8000/$port/;
     $self->url($url);
 
+    # add a test_resolution value
+    system("trac-admin $dir/trac resolution add test_resolution");
+
     $self->_grant_hiro();
 
 }

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list