Mailinglist Archive: opensuse-buildservice (306 mails)

< Previous Next >
[opensuse-buildservice] [Patch] API Test Suite - Remove hardcoded timezone from assert
  • From: "Srinidhi B" <srinidhi@xxxxxxxxxx>
  • Date: Sun, 27 Jun 2010 13:00:38 -0600
  • Message-id: <4C27ED2E02000055000597AA@xxxxxxxxxxxxxxxxxxxxx>
Hi,

I was running the API test suite and found 2 failures:

1) Failure:
test_latest_added(StatisticsControllerTest)
[/test/functional/statistics_controller_test.rb:28]:
expected tag, but no tag found matching {:tag=>"project",
:attributes=>{:created=>"2008-04-28T05:05:05+02:00", :name=>"kde4"}} in:
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<latest_added>\n <project
created=\"2010-06-27T19:05:28+05:30\" name=\"deleted\"/>\n <project
created=\"2010-06-27T19:05:28+05:30\" name=\"home:coolo\"/>\n <project
created=\"2010-06-27T19:05:28+05:30\" name=\"home:coolo:test\"/>\n <project
created=\"2010-06-27T19:05:28+05:30\" name=\"home:tom\"/>\n <project
created=\"2008-04-28T05:05:05+05:30\" name=\"kde4\"/>\n <package
project=\"BaseDistro:Update\" created=\"2007-05-16T14:19:18+05:30\"
name=\"pack2\"/>\n <package project=\"BaseDistro\"
created=\"2007-05-16T14:19:18+05:30\" name=\"pack2\"/>\n <package
project=\"BaseDistro\" created=\"2007-05-16T14:19:18+05:30\" name=\"pack1\"/>\n
<package project=\"HiddenProject\" created=\"2007-05-16T14:19:18+05:30\"
name=\"pack\"/>\n <package project=\"home:tscholz\"
created=\"2007-05-16T14:19:18+05:30\" name=\"TestPack\"/>\n</latest_added>\n".


<nil> is not true.



2) Failure:
test_latest_updated(StatisticsControllerTest)
[/test/functional/statistics_controller_test.rb:40]:
expected tag, but no tag found matching {:tag=>"project",
:attributes=>{:updated=>"2008-04-28T06:06:06+02:00", :name=>"kde4"}} in:
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<latest_updated>\n <project
updated=\"2010-06-27T19:05:28+05:30\" name=\"deleted\"/>\n <project
updated=\"2010-06-27T19:05:28+05:30\" name=\"home:coolo\"/>\n <project
updated=\"2010-06-27T19:05:28+05:30\" name=\"home:coolo:test\"/>\n <project
updated=\"2010-06-27T19:05:28+05:30\" name=\"home:tom\"/>\n <project
updated=\"2008-04-28T06:06:06+05:30\" name=\"kde4\"/>\n <package
updated=\"2007-05-16T14:19:18+05:30\" project=\"BaseDistro:Update\"
name=\"pack2\"/>\n <package updated=\"2007-05-16T14:19:18+05:30\"
project=\"BaseDistro\" name=\"pack2\"/>\n <package
updated=\"2007-05-16T14:19:18+05:30\" project=\"BaseDistro\" name=\"pack1\"/>\n
<package updated=\"2007-05-16T14:19:18+05:30\" project=\"HiddenProject\"
name=\"pack\"/>\n <package updated=\"2007-05-16T14:19:18+05:30\"
project=\"home:tscholz\" name=\"TestPack\"/>\n</latest_updated>\n".


<nil> is not true.

The failure was due to the timezone being hardcoded to "+02:00". Attached is a
trivial patch that uses Ruby's Time class to use local timezone in assert
statement.

Srinidhi.

----

diff --git a/src/api/test/functional/statistics_controller_test.rb
b/src/api/test/functional/statistics_controller_test.rb
index 32fee23..157ea14 100644
--- a/src/api/test/functional/statistics_controller_test.rb
+++ b/src/api/test/functional/statistics_controller_test.rb
@@ -1,5 +1,6 @@
require File.dirname(__FILE__) + '/../test_helper'
require 'statistics_controller'
+require 'time'

# Re-raise errors caught by the controller.
class StatisticsController; def rescue_action(e) raise e end; end
@@ -24,7 +25,7 @@ class StatisticsControllerTest <
ActionController::IntegrationTest
assert_tag :tag => 'latest_added', :child => { :tag => 'project' }
assert_tag :tag => 'project', :attributes => {
:name => "kde4",
- :created => "2008-04-28T05:05:05+02:00",
+ :created => Time.local(2008, 04, 28, 05, 05, 05).xmlschema
}
end

@@ -36,7 +37,7 @@ class StatisticsControllerTest <
ActionController::IntegrationTest
assert_tag :tag => 'latest_updated', :child => { :tag => 'project' }
assert_tag :tag => 'project', :attributes => {
:name => "kde4",
- :updated => "2008-04-28T06:06:06+02:00",
+ :updated => Time.local(2008, 04, 28, 06, 06, 06).xmlschema,
}
end


--
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-buildservice+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups