mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
refactor: expose portable FIRMS CSV helpers
This commit is contained in:
1 parent
191edb7c5e
commit
fb8f9e1c49
7 files changed
+83
-4
No files matched your search
@@ -9,7 +9,7 @@ import {
|
||||
filterTrailing24h,
|
||||
isLikelyCsv,
|
||||
parseFirmsCsv,
|
||||
} from './firmsCsv.js';
|
||||
} from 'gods-eye-view/sources/firms-csv';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const FIXTURE = fs.readFileSync(
|
||||
@@ -144,3 +144,21 @@ test('filterTrailing24h on the fixture keeps everything for a same-night now', (
|
||||
const kept = filterTrailing24h(records, Date.UTC(2026, 6, 17, 2, 0));
|
||||
assert.equal(kept.length, records.length);
|
||||
});
|
||||
|
||||
const contractCases = JSON.parse(
|
||||
fs.readFileSync(
|
||||
path.join(__dirname, 'fixtures', 'firms-csv-cases.json'),
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
for (const fixture of contractCases) {
|
||||
test(`portable FIRMS CSV contract: ${fixture.name}`, () => {
|
||||
const records = parseFirmsCsv(fixture.csv);
|
||||
assert.equal(records === null ? null : records.length, fixture.parsedCount);
|
||||
const recent = filterTrailing24h(records, Date.parse(fixture.now));
|
||||
assert.deepEqual(
|
||||
recent.map((record) => record.acqTime),
|
||||
fixture.recentTimes,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
[
|
||||
{
|
||||
"name": "categorical confidence and unpadded midnight time",
|
||||
"csv": "latitude,longitude,acq_date,acq_time,confidence,frp\n30,-97,2026-07-16,45,n,12\n",
|
||||
"now": "2026-07-16T12:00:00Z",
|
||||
"parsedCount": 1,
|
||||
"recentTimes": ["45"]
|
||||
},
|
||||
{
|
||||
"name": "truncated rows are omitted",
|
||||
"csv": "latitude,longitude,acq_date,acq_time,confidence,frp\n30,-97,2026-07-16,1200\n",
|
||||
"now": "2026-07-16T12:00:00Z",
|
||||
"parsedCount": 0,
|
||||
"recentTimes": []
|
||||
},
|
||||
{
|
||||
"name": "invalid acquisition hour does not roll into tomorrow",
|
||||
"csv": "latitude,longitude,acq_date,acq_time,confidence,frp\n30,-97,2026-07-15,2400,n,12\n",
|
||||
"now": "2026-07-16T12:00:00Z",
|
||||
"parsedCount": 1,
|
||||
"recentTimes": []
|
||||
},
|
||||
{
|
||||
"name": "inclusive trailing day and two-hour forward slack",
|
||||
"csv": "latitude,longitude,acq_date,acq_time,confidence,frp\n30,-97,2026-07-15,1200,n,12\n30,-97,2026-07-15,1159,n,12\n30,-97,2026-07-16,1400,h,12\n30,-97,2026-07-16,1401,l,12\n",
|
||||
"now": "2026-07-16T12:00:00Z",
|
||||
"parsedCount": 4,
|
||||
"recentTimes": ["1200", "1400"]
|
||||
},
|
||||
{
|
||||
"name": "upstream error is different from an empty catalog",
|
||||
"csv": "Invalid MAP_KEY",
|
||||
"now": "2026-07-16T12:00:00Z",
|
||||
"parsedCount": null,
|
||||
"recentTimes": []
|
||||
},
|
||||
{
|
||||
"name": "header-only catalog is successful and empty",
|
||||
"csv": "latitude,longitude,acq_date,acq_time,confidence,frp\n",
|
||||
"now": "2026-07-16T12:00:00Z",
|
||||
"parsedCount": 0,
|
||||
"recentTimes": []
|
||||
}
|
||||
]
|
||||
Reference in new issue
Block a user