Skip to content

Commit

Permalink
Testsuite for BuildLanOverview
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Nov 27, 2014
1 parent a55faac commit 363b394
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/Makefile.am
Expand Up @@ -19,6 +19,7 @@ TESTS = \
udev_test.rb \
ifroute_test.rb \
s390_helpers_test.rb \
build_lan_overview_test.rb \
remote_test.rb

TEST_EXTENSIONS = .rb
Expand Down
58 changes: 58 additions & 0 deletions test/build_lan_overview_test.rb
@@ -0,0 +1,58 @@
#!/usr/bin/env rspec

require_relative "test_helper"

require "yast"

Yast.import "LanItems"

include Yast::UIShortcuts
include Yast::I18n

describe "LanItemsClass#BuildLanOverview" do
let(:unknown_device_overview) { ["<ul><li><p>Unknown Network Device<br>Not configured yet.</p></li></ul>", []] }
let(:wlan_items) {
{
0 => {
"ifcfg" => "wlan0"
}
}
}
let(:wlan_ifcfg) {
{
"BOOTPROTO" => "none",
"NAME" => "WiFi Link 6000 Series",
"WIRELESS_AUTH_MODE" => "open",
"WIRELESS_KEY_0" => ""
}
}

# targeted mainly against bnc#906694
it "returns translated network device textual description for wlan device" do
allow(Yast::LanItems)
.to receive(:Items)
.and_return(wlan_items)
allow(Yast::LanItems)
.to receive(:GetDeviceMap)
.and_return(wlan_ifcfg)
allow(Yast::NetworkInterfaces)
.to receive(:Current)
.and_return(wlan_ifcfg)
allow(FastGettext)
.to receive(:locale)
.and_return("de")

# hack locale search path
Yast::I18n::LOCALE_DIR = File.expand_path("../locale", __FILE__)

textdomain("network")

# other checks depends on this
# - output of BuildLanOverview changes according number of devices
# even for "failing" (unknown devices) path
expect(Yast::LanItems.Items.size).to eql 1

overview = Yast::LanItems.BuildLanOverview
expect(overview).not_to eql unknown_device_overview
end
end
Binary file added test/locale/de/LC_MESSAGES/network.mo
Binary file not shown.

0 comments on commit 363b394

Please sign in to comment.