[Rt-commit] [svn] r894 - in RT-Client: . lib/RT lib/RT/Client t

autrijus at pallas.eruditorum.org autrijus at pallas.eruditorum.org
Fri May 14 12:36:41 EDT 2004


Author: autrijus
Date: Fri May 14 12:36:41 2004
New Revision: 894

Modified:
   RT-Client/   (props changed)
   RT-Client/lib/RT/Client.pm
   RT-Client/lib/RT/Client/Container.pm
   RT-Client/t/1-procedural.t
Log:
 ----------------------------------------------------------------------
 r4880 at not:  autrijus | 2004-05-14T16:36:42.367894Z
 
 * All CF tests passed.
 * Successful requests now set errstr to undef.
 ----------------------------------------------------------------------


Modified: RT-Client/lib/RT/Client.pm
==============================================================================
--- RT-Client/lib/RT/Client.pm	(original)
+++ RT-Client/lib/RT/Client.pm	Fri May 14 12:36:41 2004
@@ -171,6 +171,9 @@
         $self->errstr($res->content);
         return;
     }
+    else {
+        $self->errstr(undef);
+    }
 
     return $res;
 }

Modified: RT-Client/lib/RT/Client/Container.pm
==============================================================================
--- RT-Client/lib/RT/Client/Container.pm	(original)
+++ RT-Client/lib/RT/Client/Container.pm	Fri May 14 12:36:41 2004
@@ -18,7 +18,15 @@
 sub add {
     my $uri = $self->_action('add');
     my $res = $self->client->_request($uri, @_, method => 'POST') or return undef;
-    return $self->client->describe($res->header('Location'));
+
+    $uri = $res->header('Location');
+    return $self->client->describe($res->header('Location')) if $uri;
+
+    return 1 if $res->code == 204;
+
+    $self->status(500);
+    $self->errstr($res->content);
+    return undef;
 }
 
 sub _init_entries {

Modified: RT-Client/t/1-procedural.t
==============================================================================
--- RT-Client/t/1-procedural.t	(original)
+++ RT-Client/t/1-procedural.t	Fri May 14 12:36:41 2004
@@ -2,7 +2,7 @@
 
 use FindBin;
 use lib "$FindBin::Bin/../lib";
-use Test::More tests => 51;
+use Test::More 'no_plan'; #tests => 51;
 
 $SIG{__WARN__} = sub { use Carp; Carp::cluck(@_) };
 $SIG{__DIE__} = sub { use Carp; Carp::confess(@_) };
@@ -53,7 +53,9 @@
 
 my $queue = $rt->get("$uri.QueueObj");
 isa_ok($queue, 'RT::Client::Object', '->QueueObj');
-is($rt->get($queue->uri.".Id"), 1, '->QueueObj has an Id');
+my $queue_uri = $queue->uri;
+isnt($queue_uri, undef, '->QueueObj has a URI: '.$queue_uri);
+is($rt->get("$queue_uri.Id"), 1, '->QueueObj has an Id');
 
 # 1.1 Independent of CLI login credentials, need ability to specify
 # "requestor" field so that replies are sent to the requestor.
@@ -85,12 +87,32 @@
 is(length($rt->get("$uri.Subject")), 4, 'retrieved with GBK encoding');
 $rt->encoding('UTF-8');
 
-=begin TODO
-
 # 1.4 Ability to set values in n existing custom fields.
+
+my $cf = $rt->add("$queue_uri/CustomFields", Name => rand(), Type => 'SelectSingle');
+isa_ok($cf, 'RT::Client::Object');
+my $cf_uri = $cf->uri;
+isnt($cf_uri, undef, 'New CF has a URI: '.$cfv_uri);
+my $cf_id = $rt->get("$cf_uri.Id");
+
+$rt->add("$cf_uri/Values", Name => 'Value1', Description => 'Description1');
+is($rt->errstr, undef, 'CFV created');
+$rt->add("$cf_uri/Values", Name => 'Value2', Description => 'Description2');
+is($rt->errstr, undef, 'CFV created');
+
 # 1.5 Ability to set values in "Select One Value" and "Enter One Value"
 
-=cut
+$rt->add("$uri/CustomFieldValues", Field => $cf_id, Value => 'Value1');
+is($rt->errstr, undef, 'TCFV set');
+
+is($rt->get("$uri/CustomFieldValues.Count"), 1, "TCFV is added");
+is($rt->get("$uri/CustomFieldValues/*0.Content"), 'Value1', "TCFV is set correctly");
+
+$rt->add("$uri/CustomFieldValues", Field => $cf_id, Value => 'Value2');
+is($rt->errstr, undef, 'TCFV set');
+
+is($rt->get("$uri/CustomFieldValues.Count"), 1, "TCFV is replaced");
+is($rt->get("$uri/CustomFieldValues/*0.Content"), 'Value2', "TCFV is set correctly");
 
 # 1.6 For modifications, need to identify ticket number. We'd prefer to
 # identify modifying user as well if possible.


More information about the Rt-commit mailing list