Skip to content

Commit dca3252

Browse files
committed
Add spec for removing duplicate datastreams
Multiple data files for Campbell Scientific may have the same datastreams defined, so they should be re-used and not duplicated.
1 parent b7e08c3 commit dca3252

File tree

3 files changed

+123
-4
lines changed

3 files changed

+123
-4
lines changed

lib/transloader/campbell_scientific/station.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,11 @@ def download_metadata(override_metadata: {}, overwrite: false)
106106
end
107107
end
108108

109-
# TODO: Reduce datastreams to unique entries, as multiple data
110-
# files *may* share the same properties
109+
# Reduce datastreams to unique entries, as multiple data files
110+
# *may* share the same properties
111+
datastreams.uniq! do |datastream|
112+
datastream[:name]
113+
end
111114

112115
logger.warn "Latitude and Longitude unavailable from metadata."
113116
logger.warn "These values must be manually added to the station metadata file."

spec/transloader/campbell_scientific_station_spec.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,21 @@
7272
end
7373
end
7474

75-
# TODO: Removes duplicate datastreams parsed from the headers of
76-
# multiple data files
75+
it "removes duplicate datastreams for multiple data files" do
76+
VCR.use_cassette("campbell_scientific/station_two") do
77+
@provider = Transloader::CampbellScientificProvider.new($cache_dir, @http_client)
78+
@station = @provider.get_station(
79+
station_id: "606830",
80+
data_urls: [
81+
"http://dataservices.campbellsci.ca/sbd/606830/data/CBAY_MET_1HR.dat",
82+
"http://dataservices.campbellsci.ca/sbd/606830/data/CBAY_MET_1HR-Archive_2018-08-05%2015-04-05.dat"
83+
]
84+
)
85+
@station.download_metadata
86+
87+
expect(@station.metadata[:datastreams].length).to eq(22)
88+
end
89+
end
7790
end
7891

7992
##############

spec/vcr/campbell_scientific/station_two.yml

Lines changed: 103 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)