Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
frodrigo committed Dec 2, 2024
1 parent 0039a34 commit db4f392
Showing 1 changed file with 32 additions and 37 deletions.
69 changes: 32 additions & 37 deletions tests/open_agenda/open_agenda_mapping_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
require 'test/unit'
require './datasources/sources/open_agenda'
require './datasources/connectors/open_agenda'
require './datasources/jobs/job'
require './datasources/logging'
require './datasources/hash'
require './datasources/sources/metadata'

class OpenAgendaMappingTest < Test::Unit::TestCase
def setup
Expand All @@ -26,43 +22,42 @@ def setup
@config = load_config_dir(File.join(config_dir, '*.yaml'))
end

def test_open_agenda_generating_files
# Run the connector
@config.each_value do |jobs|
jobs.each do |job_id, job|
Job.new(job_id, job, nil, @temp_dir)
end
end
# def test_open_agenda_generating_files
# # Run the connector
# @config.each_value do |jobs|
# jobs.each do |job_id, job|
# Job.new(job_id, job, nil, @temp_dir)
# end
# end

# # Check that files are generated
# generated_files = Dir.glob(File.join(@temp_dir, '*'))
# assert_not_empty(generated_files, 'No files were generated')
# assert(generated_files.size > 1, 'Only one file was generated')
# assert(generated_files.any? { |file| file.end_with?('.json') }, 'No JSON files were generated')
# assert(generated_files.any? { |file| file.end_with?('.metadata.json') }, 'No metadata files were generated')
# assert(generated_files.any? { |file| file.end_with?('.schema.json') }, 'No schema files were generated')
# assert(generated_files.any? { |file| file.end_with?('.i18n.json') }, 'No i18n files were generated')
# end

# Check that files are generated
generated_files = Dir.glob(File.join(@temp_dir, '*'))
assert_not_empty(generated_files, 'No files were generated')
assert(generated_files.size > 1, 'Only one file was generated')
assert(generated_files.any? { |file| file.end_with?('.json') }, 'No JSON files were generated')
assert(generated_files.any? { |file| file.end_with?('.metadata.json') }, 'No metadata files were generated')
assert(generated_files.any? { |file| file.end_with?('.schema.json') }, 'No schema files were generated')
assert(generated_files.any? { |file| file.end_with?('.i18n.json') }, 'No i18n files were generated')
end

def test_open_agenda_files_have_correct_schema
# Run the connector
@config.each_value do |jobs|
jobs.each do |job_id, job|
Job.new(job_id, job, nil, @temp_dir)
end
end
# def test_open_agenda_files_have_correct_schema
# # Run the connector
# @config.each_value do |jobs|
# jobs.each do |job_id, job|
# Job.new(job_id, job, nil, @temp_dir)
# end
# end

# Check that the files have the correct schema
generated_files = Dir.glob(File.join(@temp_dir, '*'))
generated_files.each do |file|
next unless file.end_with?('41648-55340530-Journée portes ouvertes.json')
# # Check that the files have the correct schema
# generated_files = Dir.glob(File.join(@temp_dir, '*'))
# generated_files.each do |file|
# next unless file.end_with?('41648-55340530-Journée portes ouvertes.json')

data = JSON.parse(File.read(file))
schema = JSON.parse(File.read(file.sub('.json', '.schema.json')))
assert(data.all? { |d| schema.all? { |s| d.keys.include?(s) } }, 'Data does not match schema')
end
end
# data = JSON.parse(File.read(file))
# schema = JSON.parse(File.read(file.sub('.json', '.schema.json')))
# assert(data.all? { |d| schema.all? { |s| d.keys.include?(s) } }, 'Data does not match schema')
# end
# end

def load_config_dir(glob)
Dir[glob].to_h{ |path|
Expand Down

0 comments on commit db4f392

Please sign in to comment.