Mailinglist Archive: yast-commit (2114 mails)

< Previous Next >
[yast-commit] <rest-service> resource-restful : remove obsolete things from time after ntp move out, fix various problems with symbols and strings in maps
  • From: Josef Reidinger <jreidinger@xxxxxxx>
  • Date: Mon, 21 Sep 2009 17:29:45 +0200
  • Message-id: <E1Mq44M-0008Es-57@xxxxxxxxxxxxxxxx>
ref: refs/heads/resource-restful
commit 22127842286f0df13640ac87b9286f1cacace75c
Author: Josef Reidinger <jreidinger@xxxxxxx>
Date: Mon Sep 21 17:29:45 2009 +0200

remove obsolete things from time after ntp move out, fix various problems
with symbols and strings in maps
---
plugins/ntp/app/controllers/ntp_controller.rb | 4 +-
.../time/app/controllers/systemtimes_controller.rb | 4 +-
plugins/time/app/models/systemtime.rb | 39 ++++++--------------
.../test/functional/systemtimes_controller_test.rb | 12 +++---
plugins/time/test/unit/systemtime_test.rb | 16 +-------
5 files changed, 23 insertions(+), 52 deletions(-)

diff --git a/plugins/ntp/app/controllers/ntp_controller.rb
b/plugins/ntp/app/controllers/ntp_controller.rb
index dda4d03..10cdc4a 100644
--- a/plugins/ntp/app/controllers/ntp_controller.rb
+++ b/plugins/ntp/app/controllers/ntp_controller.rb
@@ -16,7 +16,7 @@ class NtpController < ApplicationController
def update
root = params["ntp"]
if root == nil || root == {} #FIXME exception for this
- render ErrorResult.error(404, 2, "format error - missing actions") and
return
+ raise InvalidParameters [{:name => "ntp",:error => "Missing"}]
end

@ntp = Ntp.find
@@ -27,7 +27,7 @@ class NtpController < ApplicationController
end

@ntp.save
- redirect_to :action => :show
+ show
end

# See update
diff --git a/plugins/time/app/controllers/systemtimes_controller.rb
b/plugins/time/app/controllers/systemtimes_controller.rb
index 73ab539..e669bbd 100644
--- a/plugins/time/app/controllers/systemtimes_controller.rb
+++ b/plugins/time/app/controllers/systemtimes_controller.rb
@@ -22,8 +22,8 @@ class SystemtimesController < ApplicationController
raise InvalidParameters.new [{:name => "Timezone", :error => "Missing"}]
end

- @systemtime = Systemtime.create_from_xml(root)
- @systemtime.save
+ systemtime = Systemtime.create_from_xml(root)
+ systemtime.save
show
end

diff --git a/plugins/time/app/models/systemtime.rb
b/plugins/time/app/models/systemtime.rb
index 0163395..5db9a26 100644
--- a/plugins/time/app/models/systemtime.rb
+++ b/plugins/time/app/models/systemtime.rb
@@ -14,17 +14,7 @@ class Systemtime
attr_accessor :timezone
# Utc status possible values is UTCOnly, UTC and localtime see yast2-country
doc
attr_accessor :utcstatus
- # define how time will be set
- attr_accessor :time_setter
-
- # constants for time_setter
- #don't set time on machine
- NONE = "none"
- # set time manually by values
- MANUAL = "manual"
- # set regular ntp synchronization
- NTP = "ntp"
-
+
private

# Creates argument for dbus call which specify what data is requested.
@@ -67,8 +57,7 @@ class Systemtime
systemtime.time = xmlroot[:time]
systemtime.date = xmlroot[:date]
systemtime.timezone = xmlroot[:timezone]
- systemtime.utcstatus = xmlroot[:utcstatus]
- systemtime.time_setter = xmlroot[:time_setter]
+ systemtime.utcstatus = xmlroot[:utcstatus]
return systemtime
end

@@ -88,29 +77,24 @@ class Systemtime
# so it support partial safe (e.g. save only new timezone if rest of fields
is not set).
def save
settings = {}
+ RAILS_DEFAULT_LOGGER.info "called write with #{settings.inspect}"
if @timezone and !@xxxxxxxxxxxxxx?
- settings[:timezone] = @timezone
+ settings["timezone"] = @timezone
end
if @utcstatus and !@xxxxxxxxxxxxxxx?
- settings[:utcstatus] = @utcstatus
+ settings["utcstatus"] = @utcstatus
end
need_rescue = false
- case @time_setter
- when MANUAL then
- if (@date and !@xxxxxxxxxx?) and
+ if (@date and !@xxxxxxxxxx?) and
(@time and !@xxxxxxxxxx?)
date = @date.split("/")
datetime = "#{date[2]}-#{date[0]}-#{date[1]} - "+@time
- settings[:currenttime] = datetime
- need_rescue = true
- else
- #TODO some exception that time is not set
- end
- when NTP then
- #TODO if routes became configurable ten provide ntp synchronization via
separated vie
- YastService.Call("YaPI::NTP::Synchronize")
+ settings["currenttime"] = datetime
+ need_rescue = true
end
-
+
+ RAILS_DEFAULT_LOGGER.info "called write with #{settings.inspect}"
+
begin
YastService.Call("YaPI::TIME::Write",settings)
rescue Exception => e
@@ -130,7 +114,6 @@ class Systemtime
xml.date @date
xml.timezone @timezone
xml.utcstatus @utcstatus
- xml.time_setter "NONE"
xml.timezones({:type => "array"}) do
@@timezones.each do |region|
if not region.empty?
diff --git a/plugins/time/test/functional/systemtimes_controller_test.rb
b/plugins/time/test/functional/systemtimes_controller_test.rb
index 1d5d105..c231af1 100644
--- a/plugins/time/test/functional/systemtimes_controller_test.rb
+++ b/plugins/time/test/functional/systemtimes_controller_test.rb
@@ -15,10 +15,10 @@ class SystemtimesControllerTest < ActionController::TestCase
}}

def setup
- @model_class = Systemtime
-
- Systemtime.stubs(:find).returns(Systemtime.new)
+ @model_class = Systemtime

+ Systemtime.stubs(:find).returns(Systemtime.new)
+
@controller = SystemtimesController.new
@request = ActionController::TestRequest.new
# http://railsforum.com/viewtopic.php?id=1719
@@ -44,9 +44,9 @@ class SystemtimesControllerTest < ActionController::TestCase
YastService.stubs(:Call).with {
|params,settings|
params == "YaPI::TIME::Write" and
- settings[:timezone] == DATA[:time][:timezone] and
- settings[:utcstatus] == DATA[:time][:utcstatus] and
- ! settings.include?(:currenttime)
+ settings["timezone"] == DATA[:time][:timezone] and
+ settings["utcstatus"] == DATA[:time][:utcstatus] and
+ ! settings.include?("currenttime")
}
end
end
diff --git a/plugins/time/test/unit/systemtime_test.rb
b/plugins/time/test/unit/systemtime_test.rb
index 9161501..978ae56 100644
--- a/plugins/time/test/unit/systemtime_test.rb
+++ b/plugins/time/test/unit/systemtime_test.rb
@@ -67,18 +67,17 @@ class SystemtimeTest < ActiveSupport::TestCase
assert_equal(TEST_TIMEZONES,Systemtime.timezones)
end

- def test_setter_none
+ def test_setter_without_time

YastService.stubs(:Call).with("YaPI::TIME::Write",WRITE_ARGUMENTS_NONE).returns(true)
YastService.expects(:Call).once
YastService.expects(:Call).with("YaPI::NTP::Synchronize").never

@model.timezone = "America/Kentucky/Monticello"
@model.utcstatus = "false"
- @model.time_setter = Systemtime.const_get "NONE"
@model.save
end

- def test_setter_manual
+ def test_setter_with_time

YastService.stubs(:Call).with("YaPI::TIME::Write",WRITE_ARGUMENTS_TIME).returns(true)
YastService.expects(:Call).once
YastService.expects(:Call).with("YaPI::NTP::Synchronize").never
@@ -87,17 +86,6 @@ class SystemtimeTest < ActiveSupport::TestCase
@model.utcstatus = "false"
@model.date = "02/07/2009"
@model.time = "12:18:00"
- @model.time_setter = Systemtime.const_get "MANUAL"
- @model.save
- end
-
- def test_setter_ntp
-
YastService.stubs(:Call).with("YaPI::TIME::Write",WRITE_ARGUMENTS_NTP).returns(true)
- YastService.expects(:Call).with("YaPI::NTP::Synchronize").once
-
- @model.timezone = "America/Kentucky/Monticello"
- @model.utcstatus = "false"
- @model.time_setter = Systemtime.const_get "NTP"
@model.save
end

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages