-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathtest_android2csv.rb
More file actions
73 lines (58 loc) · 2.15 KB
/
Copy pathtest_android2csv.rb
File metadata and controls
73 lines (58 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require 'test_helper'
class TestAndroid2CSV < Test::Unit::TestCase
def test_load_strings_with_wrong_file
assert_raise(Errno::ENOENT) do
output = Babelish::Android2CSV.new.load_strings "file that does not exist.strings"
end
end
def test_load_strings
expected_output = [{"app_name" => "android2csv", "action_greetings" => "Hello", "ANOTHER_STRING" => "testEN", "empty" => ""}, {}]
output = Babelish::Android2CSV.new.load_strings "test/data/android.xml"
assert_equal expected_output, output
end
def test_initialize
csv_filename = "file.csv"
filenames = %w{french.strings english.strings}
headers = %w{constants french english}
converter = Babelish::Android2CSV.new(
:csv_filename => csv_filename,
:headers => headers,
:filenames => filenames)
assert_equal csv_filename, converter.csv_filename
assert_equal headers, converter.headers
assert_equal filenames, converter.filenames
end
def test_initialize_with_default_values
converter = Babelish::Android2CSV.new
assert_not_nil converter.csv_filename
end
def test_special_chars
csv_filename = "./android_special_chars_output.csv"
filenames = "test/data/android_special_chars.xml"
headers = %w{variables german}
converter = Babelish::Android2CSV.new(
:csv_filename => csv_filename,
:headers => headers,
:filenames => [filenames])
converter.convert
assert File.exist?(converter.csv_filename)
assert_equal File.read("test/data/android_special_chars.csv"), File.read(csv_filename)
# clean up
system("rm -rf ./" + csv_filename)
end
def test_cdata_are_not_removed
csv_filename = "./test.csv"
filename = "test/data/android_cdata.xml"
headers = %w{variables german}
expected_output = [["html"], {filename => {"html" => "<![CDATA[<p>Text<p>]]>"}}]
converter = Babelish::Android2CSV.new(
:csv_filename => csv_filename,
:headers => headers,
:filenames => [filename])
output = converter.convert(false)
assert File.exist?(converter.csv_filename)
assert_equal expected_output, output
# clean up
system("rm -rf ./" + csv_filename)
end
end