TestRail-API-mockOnly.t 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. use strict;
  2. use warnings;
  3. use FindBin;
  4. use lib "$FindBin::Bin/lib";
  5. #Test things we can only mock, because the API doesn't support them.
  6. use Test::More 'tests' => 14;
  7. use TestRail::API;
  8. use Test::LWP::UserAgent::TestRailMock;
  9. use Scalar::Util qw{reftype};
  10. my $browser = $Test::LWP::UserAgent::TestRailMock::mockObject;
  11. my $tr = TestRail::API->new('http://hokum.bogus','fake','fake',undef,1);
  12. $tr->{'browser'} = $browser;
  13. $tr->{'debug'} = 0;
  14. #Have to mock anything requiring configs
  15. my $project = $tr->getProjectByName('TestProject');
  16. my $plan = $tr->getPlanByName($project->{'id'},'HooHaaPlan');
  17. my $runs = $tr->getChildRuns($plan);
  18. is(reftype($runs),'ARRAY',"getChildRuns returns array");
  19. is(scalar(@$runs),4,"getChildRuns with multi-configs in the same group returns correct # of runs");
  20. my $summary = $tr->getPlanSummary($plan->{'id'});
  21. is($summary->{'plan'},1094,"Plan ID makes it through in summary method");
  22. is($summary->{'totals'}->{'Untested'},4,"Gets total number of tests correctly");
  23. is($summary->{'percentages'}->{'Untested'},'100.00%',"Gets total percentages correctly");
  24. #Also have to mock anything requiring test result fields (all are custom)
  25. my $projResType = $tr->getTestResultFieldByName('step_results');
  26. is($projResType->{'id'},6,"Can get result field by name");
  27. $projResType = $tr->getTestResultFieldByName('step_results',$project->{'id'});
  28. is($projResType->{'id'},6,"Can get result field by name, AND filter by project ID");
  29. $projResType = $tr->getTestResultFieldByName('moo_results');
  30. is($projResType,0,"Bad name returns no result field");
  31. $projResType = $tr->getTestResultFieldByName('step_results',66669);
  32. is($projResType,-3,"Bad project returns no result field");
  33. # I can't delete closed plans, so...test closePlan et cetera
  34. is(reftype($tr->closeRun(666)),'HASH',"Can close run that exists");
  35. is($tr->closeRun(90210),-404,"Can't close run that doesn't exist");
  36. is(reftype($tr->closePlan(23)),'HASH',"Can close plan that exists");
  37. is($tr->closePlan(75020),-404,"Can't close plan that doesn't exist");
  38. # Test case type method
  39. my $ct = $tr->getCaseTypeByName("Automated");
  40. is($ct->{'id'},1,"Can get case type by name");