mpw 3.2.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'mpw/config'
4
+ require 'test/unit'
5
+ require 'locale'
6
+ require 'i18n'
7
+
8
+ class TestConfig < Test::Unit::TestCase
9
+ def setup
10
+ lang = Locale::Tag.parse(ENV['LANG']).to_simple.to_s[0..1]
11
+
12
+ if defined?(I18n.enforce_available_locales)
13
+ I18n.enforce_available_locales = true
14
+ end
15
+
16
+ I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
17
+ I18n.load_path = Dir["#{File.expand_path('../../i18n', __FILE__)}/*.yml"]
18
+ I18n.default_locale = :en
19
+ I18n.locale = lang.to_sym
20
+ end
21
+
22
+ def test_00_config
23
+ data = { gpg_key: 'test@example.com',
24
+ lang: 'en',
25
+ wallet_dir: '/tmp/test',
26
+ gpg_exe: '',
27
+ }
28
+
29
+ @config = MPW::Config.new
30
+ @config.setup(data)
31
+ @config.load_config
32
+
33
+ data.each do |k,v|
34
+ assert_equal(v, @config.send(k))
35
+ end
36
+
37
+ @config.setup_gpg_key('password', 'test@example.com', 2048)
38
+ assert(@config.check_gpg_key?)
39
+ end
40
+
41
+ def test_01_password
42
+ data = { pwd_alpha: false,
43
+ pwd_numeric: false,
44
+ pwd_special: true,
45
+ pwd_length: 32,
46
+ }
47
+
48
+ @config = MPW::Config.new
49
+ @config.load_config
50
+
51
+ assert_equal(@config.password[:length], 16)
52
+ assert(@config.password[:alpha])
53
+ assert(@config.password[:numeric])
54
+ assert(!@config.password[:special])
55
+
56
+ @config.setup(data)
57
+ @config.load_config
58
+
59
+ assert_equal(@config.password[:length], data[:pwd_length])
60
+ assert(!@config.password[:alpha])
61
+ assert(!@config.password[:numeric])
62
+ assert(@config.password[:special])
63
+ end
64
+ end
data/test/test_item.rb CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- require_relative '../lib/Item'
3
+ require 'mpw/item'
4
4
  require 'test/unit'
5
5
  require 'yaml'
6
6
 
7
7
  class TestItem < Test::Unit::TestCase
8
8
  def setup
9
- @fixture_file = 'files/fixtures.yml'
9
+ @fixture_file = 'test/files/fixtures.yml'
10
10
  @fixtures = YAML.load_file(@fixture_file)
11
11
 
12
12
  if defined?(I18n.enforce_available_locales)
13
13
  I18n.enforce_available_locales = false
14
14
  end
15
15
 
16
- I18n.load_path = Dir['../i18n/cli/*.yml']
16
+ I18n.load_path = Dir['./i18n/cli/*.yml']
17
17
  I18n.default_locale = :en
18
18
 
19
19
 
@@ -25,14 +25,12 @@ class TestItem < Test::Unit::TestCase
25
25
  end
26
26
 
27
27
  def test_01_add_new
28
- data = {name: @fixtures['add_new']['name'],
29
- group: @fixtures['add_new']['group'],
30
- host: @fixtures['add_new']['host'],
31
- protocol: @fixtures['add_new']['protocol'],
32
- user: @fixtures['add_new']['user'],
33
- password: @fixtures['add_new']['password'],
34
- port: @fixtures['add_new']['port'],
35
- comment: @fixtures['add_new']['comment'],
28
+ data = { group: @fixtures['add_new']['group'],
29
+ host: @fixtures['add_new']['host'],
30
+ protocol: @fixtures['add_new']['protocol'],
31
+ user: @fixtures['add_new']['user'],
32
+ port: @fixtures['add_new']['port'],
33
+ comment: @fixtures['add_new']['comment'],
36
34
  }
37
35
 
38
36
  item = MPW::Item.new(data)
@@ -40,27 +38,23 @@ class TestItem < Test::Unit::TestCase
40
38
  assert(!item.nil?)
41
39
  assert(!item.empty?)
42
40
 
43
- assert_equal(@fixtures['add_new']['name'], item.name)
44
41
  assert_equal(@fixtures['add_new']['group'], item.group)
45
42
  assert_equal(@fixtures['add_new']['host'], item.host)
46
43
  assert_equal(@fixtures['add_new']['protocol'], item.protocol)
47
44
  assert_equal(@fixtures['add_new']['user'], item.user)
48
- assert_equal(@fixtures['add_new']['password'], item.password)
49
45
  assert_equal(@fixtures['add_new']['port'].to_i, item.port)
50
46
  assert_equal(@fixtures['add_new']['comment'], item.comment)
51
47
  end
52
48
 
53
49
  def test_02_add_existing
54
- data = {id: @fixtures['add_existing']['id'],
55
- name: @fixtures['add_existing']['name'],
56
- group: @fixtures['add_existing']['group'],
57
- host: @fixtures['add_existing']['host'],
58
- protocol: @fixtures['add_existing']['protocol'],
59
- user: @fixtures['add_existing']['user'],
60
- password: @fixtures['add_existing']['password'],
61
- port: @fixtures['add_existing']['port'],
62
- comment: @fixtures['add_existing']['comment'],
63
- created: @fixtures['add_existing']['created'],
50
+ data = { id: @fixtures['add_existing']['id'],
51
+ group: @fixtures['add_existing']['group'],
52
+ host: @fixtures['add_existing']['host'],
53
+ protocol: @fixtures['add_existing']['protocol'],
54
+ user: @fixtures['add_existing']['user'],
55
+ port: @fixtures['add_existing']['port'],
56
+ comment: @fixtures['add_existing']['comment'],
57
+ created: @fixtures['add_existing']['created'],
64
58
  }
65
59
 
66
60
  item = MPW::Item.new(data)
@@ -69,26 +63,22 @@ class TestItem < Test::Unit::TestCase
69
63
  assert(!item.empty?)
70
64
 
71
65
  assert_equal(@fixtures['add_existing']['id'], item.id)
72
- assert_equal(@fixtures['add_existing']['name'], item.name)
73
66
  assert_equal(@fixtures['add_existing']['group'], item.group)
74
67
  assert_equal(@fixtures['add_existing']['host'], item.host)
75
68
  assert_equal(@fixtures['add_existing']['protocol'], item.protocol)
76
69
  assert_equal(@fixtures['add_existing']['user'], item.user)
77
- assert_equal(@fixtures['add_existing']['password'], item.password)
78
70
  assert_equal(@fixtures['add_existing']['port'].to_i, item.port)
79
71
  assert_equal(@fixtures['add_existing']['comment'], item.comment)
80
72
  assert_equal(@fixtures['add_existing']['created'], item.created)
81
73
  end
82
74
 
83
75
  def test_03_update
84
- data = {name: @fixtures['add_new']['name'],
85
- group: @fixtures['add_new']['group'],
86
- host: @fixtures['add_new']['host'],
87
- protocol: @fixtures['add_new']['protocol'],
88
- user: @fixtures['add_new']['user'],
89
- password: @fixtures['add_new']['password'],
90
- port: @fixtures['add_new']['port'],
91
- comment: @fixtures['add_new']['comment'],
76
+ data = { group: @fixtures['add_new']['group'],
77
+ host: @fixtures['add_new']['host'],
78
+ protocol: @fixtures['add_new']['protocol'],
79
+ user: @fixtures['add_new']['user'],
80
+ port: @fixtures['add_new']['port'],
81
+ comment: @fixtures['add_new']['comment'],
92
82
  }
93
83
 
94
84
  item = MPW::Item.new(data)
@@ -99,14 +89,12 @@ class TestItem < Test::Unit::TestCase
99
89
  created = item.created
100
90
  last_edit = item.last_edit
101
91
 
102
- data = {name: @fixtures['update']['name'],
103
- group: @fixtures['update']['group'],
104
- host: @fixtures['update']['host'],
105
- protocol: @fixtures['update']['protocol'],
106
- user: @fixtures['update']['user'],
107
- password: @fixtures['update']['password'],
108
- port: @fixtures['update']['port'],
109
- comment: @fixtures['update']['comment'],
92
+ data = { group: @fixtures['update']['group'],
93
+ host: @fixtures['update']['host'],
94
+ protocol: @fixtures['update']['protocol'],
95
+ user: @fixtures['update']['user'],
96
+ port: @fixtures['update']['port'],
97
+ comment: @fixtures['update']['comment'],
110
98
  }
111
99
 
112
100
  sleep(1)
@@ -114,12 +102,10 @@ class TestItem < Test::Unit::TestCase
114
102
 
115
103
  assert(!item.empty?)
116
104
 
117
- assert_equal(@fixtures['update']['name'], item.name)
118
105
  assert_equal(@fixtures['update']['group'], item.group)
119
106
  assert_equal(@fixtures['update']['host'], item.host)
120
107
  assert_equal(@fixtures['update']['protocol'], item.protocol)
121
108
  assert_equal(@fixtures['update']['user'], item.user)
122
- assert_equal(@fixtures['update']['password'], item.password)
123
109
  assert_equal(@fixtures['update']['port'].to_i, item.port)
124
110
  assert_equal(@fixtures['update']['comment'], item.comment)
125
111
 
@@ -127,39 +113,13 @@ class TestItem < Test::Unit::TestCase
127
113
  assert_not_equal(last_edit, item.last_edit)
128
114
  end
129
115
 
130
- def test_04_update_with_empty_name
131
- data = {name: @fixtures['add_new']['name'],
132
- group: @fixtures['add_new']['group'],
133
- host: @fixtures['add_new']['host'],
134
- protocol: @fixtures['add_new']['protocol'],
135
- user: @fixtures['add_new']['user'],
136
- password: @fixtures['add_new']['password'],
137
- port: @fixtures['add_new']['port'],
138
- comment: @fixtures['add_new']['comment'],
139
- }
140
-
141
- item = MPW::Item.new(data)
142
-
143
- assert(!item.nil?)
144
- assert(!item.empty?)
145
-
146
- last_edit = item.last_edit
147
-
148
- sleep(1)
149
- assert(!item.update({name: ''}))
150
-
151
- assert_equal(last_edit, item.last_edit)
152
- end
153
-
154
116
  def test_05_update_one_element
155
- data = {name: @fixtures['add_new']['name'],
156
- group: @fixtures['add_new']['group'],
157
- host: @fixtures['add_new']['host'],
158
- protocol: @fixtures['add_new']['protocol'],
159
- user: @fixtures['add_new']['user'],
160
- password: @fixtures['add_new']['password'],
161
- port: @fixtures['add_new']['port'],
162
- comment: @fixtures['add_new']['comment'],
117
+ data = { group: @fixtures['add_new']['group'],
118
+ host: @fixtures['add_new']['host'],
119
+ protocol: @fixtures['add_new']['protocol'],
120
+ user: @fixtures['add_new']['user'],
121
+ port: @fixtures['add_new']['port'],
122
+ comment: @fixtures['add_new']['comment'],
163
123
  }
164
124
 
165
125
  item = MPW::Item.new(data)
@@ -172,12 +132,10 @@ class TestItem < Test::Unit::TestCase
172
132
  sleep(1)
173
133
  assert(item.update({comment: @fixtures['update']['comment']}))
174
134
 
175
- assert_equal(@fixtures['add_new']['name'], item.name)
176
135
  assert_equal(@fixtures['add_new']['group'], item.group)
177
136
  assert_equal(@fixtures['add_new']['host'], item.host)
178
137
  assert_equal(@fixtures['add_new']['protocol'], item.protocol)
179
138
  assert_equal(@fixtures['add_new']['user'], item.user)
180
- assert_equal(@fixtures['add_new']['password'], item.password)
181
139
  assert_equal(@fixtures['add_new']['port'].to_i, item.port)
182
140
  assert_equal(@fixtures['update']['comment'], item.comment)
183
141
 
@@ -185,14 +143,12 @@ class TestItem < Test::Unit::TestCase
185
143
  end
186
144
 
187
145
  def test_05_delete
188
- data = {name: @fixtures['add_new']['name'],
189
- group: @fixtures['add_new']['group'],
190
- host: @fixtures['add_new']['host'],
191
- protocol: @fixtures['add_new']['protocol'],
192
- user: @fixtures['add_new']['user'],
193
- password: @fixtures['add_new']['password'],
194
- port: @fixtures['add_new']['port'],
195
- comment: @fixtures['add_new']['comment'],
146
+ data = { group: @fixtures['add_new']['group'],
147
+ host: @fixtures['add_new']['host'],
148
+ protocol: @fixtures['add_new']['protocol'],
149
+ user: @fixtures['add_new']['user'],
150
+ port: @fixtures['add_new']['port'],
151
+ comment: @fixtures['add_new']['comment'],
196
152
  }
197
153
 
198
154
  item = MPW::Item.new(data)
@@ -200,17 +156,15 @@ class TestItem < Test::Unit::TestCase
200
156
  assert(!item.nil?)
201
157
  assert(!item.empty?)
202
158
 
203
- assert(item.delete)
159
+ item.delete
204
160
  assert(!item.nil?)
205
161
  assert(item.empty?)
206
162
 
207
163
  assert_equal(nil, item.id)
208
- assert_equal(nil, item.name)
209
164
  assert_equal(nil, item.group)
210
165
  assert_equal(nil, item.host)
211
166
  assert_equal(nil, item.protocol)
212
167
  assert_equal(nil, item.user)
213
- assert_equal(nil, item.password)
214
168
  assert_equal(nil, item.port)
215
169
  assert_equal(nil, item.comment)
216
170
  assert_equal(nil, item.created)
data/test/test_mpw.rb CHANGED
@@ -1,121 +1,44 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- require_relative '../lib/MPW'
4
- require_relative '../lib/Item'
3
+ require 'mpw/mpw'
4
+ require 'mpw/item'
5
5
  require 'test/unit'
6
6
  require 'yaml'
7
7
  require 'csv'
8
8
 
9
9
  class TestMPW < Test::Unit::TestCase
10
10
  def setup
11
- fixture_file = 'files/fixtures.yml'
11
+ fixture_file = './test/files/fixtures.yml'
12
12
 
13
- file_gpg = 'test.gpg'
14
- key = ENV['MPW_TEST_KEY']
15
-
16
- puts
13
+ wallet_file = 'default.gpg'
14
+ key = 'test@example.com'
15
+ password = 'password'
17
16
 
18
17
  if defined?(I18n.enforce_available_locales)
19
18
  I18n.enforce_available_locales = false
20
19
  end
21
20
 
22
- File.delete(file_gpg) if File.exist?(file_gpg)
23
-
24
- @mpw = MPW::MPW.new(file_gpg, key)
21
+ @mpw = MPW::MPW.new(key, wallet_file, password)
25
22
  @fixtures = YAML.load_file(fixture_file)
26
23
  end
27
24
 
28
- def test_01_import_yaml
29
- import_file = 'files/test_import.yml'
30
-
31
- assert(@mpw.import(import_file, :yaml))
32
- assert_equal(2, @mpw.list.length)
33
-
34
- item = @mpw.list[0]
35
- assert_equal(@fixtures['add_new']['name'], item.name)
36
- assert_equal(@fixtures['add_new']['group'], item.group)
37
- assert_equal(@fixtures['add_new']['host'], item.host)
38
- assert_equal(@fixtures['add_new']['protocol'], item.protocol)
39
- assert_equal(@fixtures['add_new']['user'], item.user)
40
- assert_equal(@fixtures['add_new']['password'], item.password)
41
- assert_equal(@fixtures['add_new']['port'].to_i, item.port)
42
- assert_equal(@fixtures['add_new']['comment'], item.comment)
43
- end
44
-
45
- def test_02_export_yaml
46
- import_file = 'files/test_import.yml'
47
- export_file = 'test_export.yml'
48
-
49
- assert(@mpw.import(import_file))
50
- assert_equal(2, @mpw.list.length)
51
- assert(@mpw.export(export_file, :yaml))
52
- export = YAML::load_file(export_file)
53
- assert_equal(2, export.length)
54
-
55
- result = export.values[0]
56
- assert_equal(@fixtures['add_new']['name'], result['name'])
57
- assert_equal(@fixtures['add_new']['group'], result['group'])
58
- assert_equal(@fixtures['add_new']['host'], result['host'])
59
- assert_equal(@fixtures['add_new']['protocol'], result['protocol'])
60
- assert_equal(@fixtures['add_new']['user'], result['user'])
61
- assert_equal(@fixtures['add_new']['password'], result['password'])
62
- assert_equal(@fixtures['add_new']['port'].to_i, result['port'])
63
- assert_equal(@fixtures['add_new']['comment'], result['comment'])
64
-
65
- File.unlink(export_file)
66
- end
67
-
68
- def test_03_import_csv
69
- import_file = 'files/test_import.csv'
70
-
71
- assert(@mpw.import(import_file, :csv))
72
- assert_equal(2, @mpw.list.length)
73
-
74
- import = CSV.parse(File.read(import_file), headers: true)
75
-
76
- item = @mpw.list[0]
77
- assert_equal(import[0]['name'], item.name)
78
- assert_equal(import[0]['group'], item.group)
79
- assert_equal(import[0]['host'], item.host)
80
- assert_equal(import[0]['protocol'], item.protocol)
81
- assert_equal(import[0]['user'], item.user)
82
- assert_equal(import[0]['password'], item.password)
83
- assert_equal(import[0]['port'].to_i, item.port)
84
- assert_equal(import[0]['comment'], item.comment)
25
+ def test_00_decrypt_empty_file
26
+ @mpw.read_data
27
+ assert_equal(0, @mpw.list.length)
85
28
  end
86
29
 
87
- def test_04_export_csv
88
- import_file = 'files/test_import.csv'
89
- export_file = 'test_export.csv'
90
-
91
- assert(@mpw.import(import_file, :csv))
92
- assert_equal(2, @mpw.list.length)
93
- assert(@mpw.export(export_file, :csv))
94
- export = CSV.parse(File.read(export_file), headers: true)
95
- assert_equal(2, export.length)
96
-
97
- result = export[0]
98
- assert_equal(@fixtures['add_new']['name'], result['name'])
99
- assert_equal(@fixtures['add_new']['group'], result['group'])
100
- assert_equal(@fixtures['add_new']['host'], result['host'])
101
- assert_equal(@fixtures['add_new']['protocol'], result['protocol'])
102
- assert_equal(@fixtures['add_new']['user'], result['user'])
103
- assert_equal(@fixtures['add_new']['password'], result['password'])
104
- assert_equal(@fixtures['add_new']['port'], result['port'])
105
- assert_equal(@fixtures['add_new']['comment'], result['comment'])
106
-
107
- File.unlink(export_file)
30
+ def test_01_encrypt_empty_file
31
+ @mpw.read_data
32
+ @mpw.write_data
108
33
  end
109
34
 
110
- def test_05_add_item
111
- data = {name: @fixtures['add_new']['name'],
112
- group: @fixtures['add_new']['group'],
113
- host: @fixtures['add_new']['host'],
114
- protocol: @fixtures['add_new']['protocol'],
115
- user: @fixtures['add_new']['user'],
116
- password: @fixtures['add_new']['password'],
117
- port: @fixtures['add_new']['port'],
118
- comment: @fixtures['add_new']['comment'],
35
+ def test_02_add_item
36
+ data = { group: @fixtures['add_new']['group'],
37
+ host: @fixtures['add_new']['host'],
38
+ protocol: @fixtures['add_new']['protocol'],
39
+ user: @fixtures['add_new']['user'],
40
+ port: @fixtures['add_new']['port'],
41
+ comment: @fixtures['add_new']['comment'],
119
42
  }
120
43
 
121
44
  item = MPW::Item.new(data)
@@ -123,69 +46,95 @@ class TestMPW < Test::Unit::TestCase
123
46
  assert(!item.nil?)
124
47
  assert(!item.empty?)
125
48
 
126
- assert(@mpw.add(item))
49
+ @mpw.read_data
50
+ @mpw.add(item)
51
+ @mpw.set_password(item.id, @fixtures['add_new']['password'])
127
52
 
128
53
  assert_equal(1, @mpw.list.length)
129
54
 
130
55
  item = @mpw.list[0]
131
- assert_equal(@fixtures['add_new']['name'], item.name)
132
- assert_equal(@fixtures['add_new']['group'], item.group)
133
- assert_equal(@fixtures['add_new']['host'], item.host)
134
- assert_equal(@fixtures['add_new']['protocol'], item.protocol)
135
- assert_equal(@fixtures['add_new']['user'], item.user)
136
- assert_equal(@fixtures['add_new']['password'], item.password)
137
- assert_equal(@fixtures['add_new']['port'].to_i, item.port)
138
- assert_equal(@fixtures['add_new']['comment'], item.comment)
56
+ @fixtures['add_new'].each do |k,v|
57
+ if k == 'password'
58
+ assert_equal(v, @mpw.get_password(item.id))
59
+ else
60
+ assert_equal(v, item.send(k).to_s)
61
+ end
62
+ end
63
+
64
+ @mpw.write_data
139
65
  end
140
66
 
141
- def test_11_encrypt_empty_file
142
- assert(@mpw.encrypt)
67
+ def test_03_decrypt_file
68
+ @mpw.read_data
69
+ assert_equal(1, @mpw.list.length)
70
+
71
+ item = @mpw.list[0]
72
+ @fixtures['add_new'].each do |k,v|
73
+ if k == 'password'
74
+ assert_equal(v, @mpw.get_password(item.id))
75
+ else
76
+ assert_equal(v, item.send(k).to_s)
77
+ end
78
+ end
143
79
  end
144
80
 
145
- def test_12_encrypt
146
- import_file = 'files/test_import.yml'
81
+ def test_04_delete_item
82
+ @mpw.read_data
147
83
 
148
- assert(@mpw.import(import_file, :yaml))
149
- assert_equal(2, @mpw.list.length)
84
+ assert_equal(1, @mpw.list.length)
150
85
 
151
- assert(@mpw.encrypt)
152
- end
86
+ @mpw.list.each do |item|
87
+ item.delete
88
+ end
153
89
 
154
- def test_13_decrypt_empty_file
155
- assert(@mpw.decrypt)
156
90
  assert_equal(0, @mpw.list.length)
91
+
92
+ @mpw.write_data
157
93
  end
158
94
 
159
- def test_14_decrypt
160
- import_file = 'files/test_import.yml'
95
+ def test_05_search
96
+ @mpw.read_data
97
+
98
+ @fixtures.each_value do |v|
99
+ data = { group: v['group'],
100
+ host: v['host'],
101
+ protocol: v['protocol'],
102
+ user: v['user'],
103
+ port: v['port'],
104
+ comment: v['comment'],
105
+ }
106
+
107
+ item = MPW::Item.new(data)
108
+
109
+ assert(!item.nil?)
110
+ assert(!item.empty?)
111
+
112
+ @mpw.add(item)
113
+ @mpw.set_password(item.id, v['password'])
114
+ end
161
115
 
162
- assert(@mpw.import(import_file, :yaml))
163
- assert_equal(2, @mpw.list.length)
116
+ assert_equal(3, @mpw.list.length)
117
+ assert_equal(1, @mpw.list(group: @fixtures['add_new']['group']).length)
118
+ assert_equal(1, @mpw.list(pattern: 'existing').length)
119
+ assert_equal(2, @mpw.list(pattern: 'host_[eu]').length)
120
+ end
164
121
 
165
- assert(@mpw.encrypt)
122
+ def test_06_add_gpg_key
123
+ @mpw.read_data
166
124
 
167
- assert(@mpw.decrypt)
168
- assert_equal(2, @mpw.list.length)
125
+ @mpw.add_key('test2@example.com')
126
+ assert_equal(2, @mpw.list_keys.length)
169
127
 
170
- item = @mpw.list[0]
171
- assert_equal(@fixtures['add_new']['name'], item.name)
172
- assert_equal(@fixtures['add_new']['group'], item.group)
173
- assert_equal(@fixtures['add_new']['host'], item.host)
174
- assert_equal(@fixtures['add_new']['protocol'], item.protocol)
175
- assert_equal(@fixtures['add_new']['user'], item.user)
176
- assert_equal(@fixtures['add_new']['password'], item.password)
177
- assert_equal(@fixtures['add_new']['port'].to_i, item.port)
178
- assert_equal(@fixtures['add_new']['comment'], item.comment)
128
+ @mpw.write_data
179
129
  end
180
130
 
181
- def test_15_search
182
- import_file = 'files/test_import.yml'
131
+ def test_07_delete_gpg_key
132
+ @mpw.read_data
133
+ assert_equal(2, @mpw.list_keys.length)
183
134
 
184
- assert(@mpw.import(import_file, :yaml))
185
- assert_equal(2, @mpw.list.length)
135
+ @mpw.delete_key('test2@example.com')
136
+ assert_equal(1, @mpw.list_keys.length)
186
137
 
187
- assert_equal(1, @mpw.list(group: @fixtures['add_new']['group']).length)
188
- assert_equal(1, @mpw.list(protocol: @fixtures['add_new']['protocol']).length)
189
- assert_equal(2, @mpw.list(search: @fixtures['add_new']['name'][0..-2]).length)
138
+ @mpw.write_data
190
139
  end
191
140
  end
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'yaml'
4
+ require 'test/unit'
5
+
6
+ class TestTranslate < Test::Unit::TestCase
7
+ def test_00_check_translate
8
+ missing = 0
9
+
10
+ Dir.glob('i18n/*.yml').each do |yaml|
11
+ lang = File.basename(yaml, '.yml')
12
+ translate = YAML.load_file(yaml)
13
+
14
+ `grep -r -o "I18n.t('.*)" bin/ lib/ | cut -d"'" -f2`.each_line do |line|
15
+ begin
16
+ t = translate[lang]
17
+ line.strip.split('.').each do |v|
18
+ t = t[v]
19
+ end
20
+
21
+ assert(!t.to_s.empty?)
22
+ rescue
23
+ puts "#{lang}.#{line}"
24
+ missing = 1
25
+ end
26
+ end
27
+ end
28
+
29
+ assert_equal(0, missing)
30
+ end
31
+ end
data/test/tests.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
- require_relative 'test_mpw.rb'
3
+ require_relative 'init.rb'
4
+ require_relative 'test_config.rb'
4
5
  require_relative 'test_item.rb'
6
+ require_relative 'test_mpw.rb'
7
+ require_relative 'test_translate.rb'