|
|
|
@ -4,6 +4,7 @@ require "rake" |
|
|
|
describe "full import", type: :task do |
|
|
|
describe "full import", type: :task do |
|
|
|
let(:instance_name) { "paas_import_instance" } |
|
|
|
let(:instance_name) { "paas_import_instance" } |
|
|
|
let(:paas_config_service) { instance_double(Configuration::PaasConfigurationService) } |
|
|
|
let(:paas_config_service) { instance_double(Configuration::PaasConfigurationService) } |
|
|
|
|
|
|
|
let(:env_config_service) { instance_double(Configuration::EnvConfigurationService) } |
|
|
|
let(:storage_service) { instance_double(Storage::S3Service) } |
|
|
|
let(:storage_service) { instance_double(Storage::S3Service) } |
|
|
|
let(:orgs_list) { "Institution name,Id,Old Completed lettings logs,Old In progress lettings logs,Old Completed sales logs,Old In progress sales logs\norg1,1.zip,0,0,0,0\norg2,2.zip,0,0,0,0" } |
|
|
|
let(:orgs_list) { "Institution name,Id,Old Completed lettings logs,Old In progress lettings logs,Old Completed sales logs,Old In progress sales logs\norg1,1.zip,0,0,0,0\norg2,2.zip,0,0,0,0" } |
|
|
|
|
|
|
|
|
|
|
|
@ -12,8 +13,10 @@ describe "full import", type: :task do |
|
|
|
allow(storage_service).to receive(:write_file).and_return(nil) |
|
|
|
allow(storage_service).to receive(:write_file).and_return(nil) |
|
|
|
allow(storage_service).to receive(:get_file_io).and_return(orgs_list) |
|
|
|
allow(storage_service).to receive(:get_file_io).and_return(orgs_list) |
|
|
|
allow(Configuration::PaasConfigurationService).to receive(:new).and_return(paas_config_service) |
|
|
|
allow(Configuration::PaasConfigurationService).to receive(:new).and_return(paas_config_service) |
|
|
|
|
|
|
|
allow(Configuration::EnvConfigurationService).to receive(:new).and_return(env_config_service) |
|
|
|
allow(ENV).to receive(:[]) |
|
|
|
allow(ENV).to receive(:[]) |
|
|
|
allow(ENV).to receive(:[]).with("IMPORT_PAAS_INSTANCE").and_return(instance_name) |
|
|
|
allow(ENV).to receive(:[]).with("IMPORT_PAAS_INSTANCE").and_return(instance_name) |
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe "import:generate_reports" do |
|
|
|
describe "import:generate_reports" do |
|
|
|
@ -33,12 +36,22 @@ describe "full import", type: :task do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "creates a report using given organisation csv" do |
|
|
|
it "creates a report using given organisation csv" do |
|
|
|
|
|
|
|
allow(ENV).to receive(:[]).with("VCAP_SERVICES").and_return("dummy") |
|
|
|
expect(Storage::S3Service).to receive(:new).with(paas_config_service, instance_name) |
|
|
|
expect(Storage::S3Service).to receive(:new).with(paas_config_service, instance_name) |
|
|
|
expect(Imports::ImportReportService).to receive(:new).with(storage_service, CSV.parse(orgs_list, headers: true)) |
|
|
|
expect(Imports::ImportReportService).to receive(:new).with(storage_service, CSV.parse(orgs_list, headers: true)) |
|
|
|
expect(import_report_service).to receive(:create_reports).with("some_name") |
|
|
|
expect(import_report_service).to receive(:create_reports).with("some_name") |
|
|
|
|
|
|
|
|
|
|
|
task.invoke("some_name") |
|
|
|
task.invoke("some_name") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "creates a report using given organisation csv" do |
|
|
|
|
|
|
|
allow(ENV).to receive(:[]).with("VCAP_SERVICES") |
|
|
|
|
|
|
|
expect(Storage::S3Service).to receive(:new).with(env_config_service, instance_name) |
|
|
|
|
|
|
|
expect(Imports::ImportReportService).to receive(:new).with(storage_service, CSV.parse(orgs_list, headers: true)) |
|
|
|
|
|
|
|
expect(import_report_service).to receive(:create_reports).with("some_name") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
task.invoke("some_name") |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|