Agent-TCLI

 view release on metacpan or  search on metacpan

lib/Agent/TCLI/Testee.pm  view on Meta::CPAN

	$self->last_request(
		$self->test_master->build_test($self, 'like-code',
		$_[0], $_[1], '', $_[2] )
	);
	return( $self->last_request);
}

sub like_codes {
	my $self = shift;
	$self->last_request(
		$self->test_master->build_test($self, 'are_like-code',
		$_[0], $_[1], '', $_[2] )
	);
	return( $self->last_request);
}

=item unlike_code

  unlike_code ( 'some request', qr(CODE) , <test_name> );

unlike_code() works as like_code above except it passes if response
does not match the regex.

=cut

sub unlike_code {
	my $self = shift;
	$self->last_request(
		$self->test_master->build_test($self, 'unlike-code',
		$_[0], $_[1], '', $_[2] )
	);
	return( $self->last_request);
}

sub unlike_codes {
	my $self = shift;
	$self->last_request(
		$self->test_master->build_test($self, 'are_unlike-code',
		$_[0], $_[1], '', $_[2] )
	);
	return( $self->last_request);
}

=item get_param ( <param>, [ <id>, <timeout> ] )

B<get_param> will parse the textual responses from a request and attempt
to extract a value. It requires a param argument that is the parameter
to try and obtain a value for. It takes an optional request id
from a prior request. If not supplied, it will use the last request made.
It also takes an optional timeout value, which will be passed to B<done_id>
to wait for all responses to that request to come in.

B<get_param> attempts to parse the text in the responses to find the value
for the parameter being requested. It expects that the response is
formatted appropriately to extract the parameter.
Valid formats to receive the parameter are:
	 param=something
	 param something
	 param="a quoted string with something"
	 param "a quoted string with something"
	 param: a string yaml-ish style, no comments, to the end of the line
	 param: "a quoted string, just what's in quotes"
It returns the value of the parameter requested, or undefined if it
cannot be found.

=cut

sub get_param {
	my ($self, $param, $id, $timeout) = @_;

	$id = $self->last_request->id  unless  ( defined($id) && $id );

	return(
		$self->test_master->get_param(
		$param, $id, $timeout )
	);
}

=item get_responses ( [ <id>, <timeout> ] )

B<get_responses> will retrieve textual responses for a request.
It takes an optional request id from a prior request. If not
supplied, it will use the last request made. It also takes an optional
timeout value.
It returns the text from all available responses, each separated by a pair
of newlines.
Calling <get_responses> forces the completion of all outstanding tests for that
request. That is, the tests will fail if no-reponses have been received
before the timeout is reached.

=cut

sub get_responses {
	my ($self, $id, $timeout) = @_;

	$id = $self->last_request->id  unless ( defined($id) && $id );

	return(
		$self->test_master->get_responses(
		$id, $timeout )
	);
}

sub _preinit :PreInit {
	my ($self,$args) = @_;

	$args->{'do_verbose'} = sub { diag( @_ ) } unless defined($args->{'do_verbose'});

}


sub _init :Init {
	my ($self, $args) = @_;

	$self->test_master->load_testee($self);
}

1;

#__END__
=back



( run in 0.426 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )