[Rt-commit] [svn] r831 - in RT-Client: . t

autrijus at pallas.eruditorum.org autrijus at pallas.eruditorum.org
Wed May 5 13:53:24 EDT 2004


Author: autrijus
Date: Wed May  5 13:53:23 2004
New Revision: 831

Modified:
   RT-Client/   (props changed)
   RT-Client/t/spec.t
Log:
 ----------------------------------------------------------------------
 r4467 at not:  autrijus | 2004-05-05T07:56:56.134219Z
 
 * Finished unit tests based on the spec.
 ----------------------------------------------------------------------


Modified: RT-Client/t/spec.t
==============================================================================
--- RT-Client/t/spec.t	(original)
+++ RT-Client/t/spec.t	Wed May  5 13:53:23 2004
@@ -1,9 +1,11 @@
+#!/usr/bin/perl
+
 use FindBin;
 use lib "$FindBin::Bin/../lib";
 use Test::More 'no_plan';
 
 use_ok('RT::Client');
-my $rt = RT::Client->new;
+my $rt = RT::Client->new('http://root:password@localhost');
 isa_ok($rt, 'RT::Client');
 
 # Requirements:
@@ -59,33 +61,75 @@
 
 # 1.2 Ability to post a ticket to a specific queue.
 
-$queue->Tickets->add( ... )
+$ticket = $queue->Tickets->add( Subject => 'Testing' );
+isa_ok($ticket, 'RT::Client::Object');
+is($ticket->Subject, 'Testing');
 
 # 1.3 Ability to specify message body. May contain utf8 OR localized
 # charset.
 
+$ticket->encoding('hz');
+is($ticket->encoding, $rt->encoding, '->encoding is global');
+$ticket->setSubject('~{1jLb~}');
+$ticket->encoding('gbk');
+is(length($ticket->Subject), 4);
+$ticket->encoding('utf-8');
+
 # 1.4 Ability to set values in n existing custom fields.
 
+my $cf = $queue->CustomFields->add(
+    Name => 'CFTest',
+    Type => 'SelectSingle',
+);
+
+$cf->addValues( Name => 'foo', Description 'Foo Option' );
+
 # 1.5 Ability to set values in "Select One Value" and "Enter One Value"
 # -type custom fields
 
+# RT-Tickets/5/CustomFieldValues/9/1.Content
+# RT-Tickets/5/CustomFieldValues/9/1.Content
+$ticket->CustomFieldValues($cf)->set( Content => 'foo');
+
+is($ticket->CustomFieldsValues($cf)->_count, 1);
+is($ticket->CustomFieldsValues($cf)->_first->Content, 'foo');
+
 # 1.6 For modifications, need to identify ticket number. We'd prefer to
 # identify modifying user as well if possible.
 
+my $id = $ticket->Id;
+$rt->current_user('Nobody');
+is($ticket->current_user, $rt->current_user, '->current_user is global');
+$rt->Tickets($id)->comment( Content => "Hello!" );
+$rt->current_user($rt->username);
 
 # 2. Ability to Close a Ticket via an External Interface
 
+$ticket->setStatus('resolved');
+
 # 2.1 Ability to close a ticket based on ticket number. We'd prefer to
 # identify closing user as well if possible.
 
+$ticket->current_user('Nobody');
+$ticket->comment( Content => 'reopen!' );
+is($ticket->Status, 'open');
+$ticket->setStatus('resolved');
+$ticket->current_user($rt->username);
+
 # 3. General CLI Requirements
 
 # 3.1 Error Responses: CLI must return status and error responses
-# instead of end-user help text. As this application will be called
-# programmatically, we should be able to easily interpret error responses
-# in scripts as well as log them. The full help text should only appear
-# if a "help" command is entered. Bascially, this should work no
-# differently than any other CLI app in a Unix or Linux environment.
+# instead of end-user help text.
+
+$ticket->setStatus('open');
+is($rt->_status, 200);
+is($ticket->_status, 200);
+$ticket->setOwner('no_such_user' . rand());
+is($rt->_status, 200);
+is($ticket->_status, 400);
+isnt($ticket->_errstr, undef);
 
 # 3.2 Environment: Support perl 5.6.1.
 
+cmp_ok($], '>=', 5.006001);
+


More information about the Rt-commit mailing list