T-40: M1.1c — Pass 1 exchanges: ISO MIC seed, source-code role classifier and reviewable seed-SQL generator
This commit is contained in:
parent
d0d2ebdfc8
commit
dcca90004d
7 changed files with 115 additions and 21 deletions
|
|
@ -5,6 +5,7 @@ import { afterEach, describe, expect, test } from 'bun:test';
|
|||
import { Pool } from 'pg';
|
||||
import { getLogger, setLoggerConfig } from '@stock-bot/logger';
|
||||
import { PostgreSQLClient, runPostgresMigrations } from '@stock-bot/postgres';
|
||||
import { generateExchangeSeedSql } from '../../apps/stock/data-pipeline/src/security-master';
|
||||
|
||||
setLoggerConfig({ logLevel: 'fatal', logConsole: false });
|
||||
const logger = getLogger('security-master-exchange-seed-test');
|
||||
|
|
@ -224,4 +225,68 @@ describe.skipIf(!url)('security master Pass 1 exchange seed migration', () => {
|
|||
|
||||
expect(await countRows()).toEqual(initialCounts);
|
||||
});
|
||||
|
||||
test('reviewed follow-up SQL promotes an existing unreviewed row with reviewed_by and survives baseline re-apply', async () => {
|
||||
const f = await createIsolatedFixture();
|
||||
const baselineSql = readFileSync(exchangeSeedSqlPath, 'utf8');
|
||||
|
||||
const followUpSql = generateExchangeSeedSql({
|
||||
mappings: [
|
||||
{
|
||||
source: 'eod',
|
||||
sourceCode: 'US',
|
||||
role: 'primary_venue',
|
||||
mic: 'XNYS',
|
||||
countryIso: 'US',
|
||||
method: 'explicit_rule',
|
||||
reviewedBy: 'director',
|
||||
},
|
||||
{
|
||||
source: 'qm',
|
||||
sourceCode: 'TSX',
|
||||
role: 'primary_venue',
|
||||
mic: 'XTSE',
|
||||
countryIso: 'CA',
|
||||
method: 'explicit_rule',
|
||||
reviewedBy: 'director',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
// Apply reviewed follow-up after migration 35 has already run
|
||||
await f.pool.query(followUpSql);
|
||||
|
||||
// Re-apply baseline migration 35; promoted and added reviewed rows must remain intact
|
||||
await f.pool.query(baselineSql);
|
||||
|
||||
const promotedRow = (
|
||||
await f.pool.query(
|
||||
`SELECT role, mic, country_iso, method, reviewed_by
|
||||
FROM exchange_source_map
|
||||
WHERE source = 'eod' AND source_code = 'US'`
|
||||
)
|
||||
).rows[0];
|
||||
expect(promotedRow).toEqual({
|
||||
role: 'primary_venue',
|
||||
mic: 'XNYS',
|
||||
country_iso: 'US',
|
||||
method: 'explicit_rule',
|
||||
reviewed_by: 'director',
|
||||
});
|
||||
|
||||
const addedRow = (
|
||||
await f.pool.query(
|
||||
`SELECT role, mic, country_iso, method, reviewed_by
|
||||
FROM exchange_source_map
|
||||
WHERE source = 'qm' AND source_code = 'TSX'`
|
||||
)
|
||||
).rows[0];
|
||||
expect(addedRow).toEqual({
|
||||
role: 'primary_venue',
|
||||
mic: 'XTSE',
|
||||
country_iso: 'CA',
|
||||
method: 'explicit_rule',
|
||||
reviewed_by: 'director',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue