Commit 7aba763f by John Donnal

rubocop fixes

parent 6c82e8d4
......@@ -19,7 +19,8 @@ class DbAdapter
# Create the schema:
# 3 elements: path, attributes, streams
{ path: entry[0],
{
path: entry[0],
attributes: {
data_type: entry[1],
start_time: entry[2] || 0,
......
......@@ -21,7 +21,8 @@ class UpdateFolder
# update the folder attributes from metadata
info = __read_info_entry(@entries) || {}
@folder.update_attributes(
info.slice(*DbFolder.defined_attributes))
info.slice(*DbFolder.defined_attributes)
)
# process the contents of the folder
__parse_folder_entries(@folder, @entries)
# delete any files or folders still in the
......@@ -114,7 +115,7 @@ class UpdateFolder
# if any entry_group has chunks left, this is a folder
entry_group.select { |entry|
!entry[:chunks].empty?
}.count == 0
}.count.zero?
end
# create or update a DbFile object at the
......
......@@ -11,7 +11,8 @@ describe DbAdapter do
expect(entry).to include(:path, :attributes)
expect(entry[:attributes]).to(
include(:data_type, :start_time,
:end_time, :total_rows, :total_time))
:end_time, :total_rows, :total_time)
)
end
end
end
......@@ -12,20 +12,23 @@ class DbSchemaHelper
start_time: 0,
end_time: 0,
total_rows: 0,
total_time: 0 }.merge(metadata),
total_time: 0
}.merge(metadata),
streams: __build_streams(stream_count)
}
end
# build stream hash for a file
def __build_streams(count)
return {} unless count > 0
return {} unless count.positive?
streams = []
(0..(count - 1)).each do |i|
streams <<
{ 'name': "stream#{i}",
{
'name': "stream#{i}",
'units': 'unit',
'column': i }
'column': i
}
end
streams
end
......
......@@ -21,9 +21,9 @@ RSpec.describe 'Db' do
expect(db_x.url).to eq('custom_string')
end
it 'can be left as default' do
nilm = Nilm.create(url: "base")
nilm = Nilm.create(url: 'base')
db_x = Db.new(nilm: nilm, url: '')
expect(db_x.url).to eq("base/nilmdb")
expect(db_x.url).to eq('base/nilmdb')
end
end
end
......@@ -129,15 +129,14 @@ describe 'UpdateDb' do
# create Db with a file 'temp'
update_with_schema([helper.entry('/folder1/temp'),
helper.entry('/folder1/info',
metadata: { name: 'f1' })
])
metadata: { name: 'f1' })])
temp = DbFile.find_by_name('temp')
# the file 'temp' should be here
expect(temp).to be_present
# update Db without 'temp'
update_with_schema([helper.entry('/folder1/info',
metadata: { name: 'f1' })
], db: @db)
metadata: { name: 'f1' })],
db: @db)
# it should be gone
expect(DbFile.find_by_name('temp')).to be nil
# ...and the service should have a warning
......@@ -147,8 +146,7 @@ describe 'UpdateDb' do
# create Db with a folder 'temp'
update_with_schema([helper.entry('/folder1/stub'),
helper.entry('/folder1/temp/info',
metadata: { name: 'temp' })
])
metadata: { name: 'temp' })])
temp = DbFolder.find_by_name('temp')
# the file 'temp' should be here
expect(temp).to be_present
......
......@@ -54,16 +54,16 @@ describe 'ServiceStatus' do
child.add_warning('test')
expect(
parent.absorb_status(child,
action: ServiceStatus::NEVER_FAIL))
.to be true
action: ServiceStatus::NEVER_FAIL)
).to be true
end
it 'fails on errors and warnings with FAIL_ON_WARNING' do
child.add_warning('test')
expect(
parent.absorb_status(child,
action: ServiceStatus::FAIL_ON_WARNING))
.to be false
action: ServiceStatus::FAIL_ON_WARNING)
).to be false
end
it 'fails on errors with FAIL_ON_ERROR' do
child.add_error('test')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment