Commit 828265dd authored by BERET Benjamin DGAC/CRNA-E's avatar BERET Benjamin DGAC/CRNA-E
Browse files

Do not run B2B connnection dependant tests in CI unless configured to

parent 98c9fa16
Pipeline #8797 passed with stages
in 10 minutes and 19 seconds
......@@ -14,6 +14,11 @@ describe('queryFlightPlans', () => {
beforeAll(async () => {
const clients = await getClients();
if (!clients) {
return;
}
Flight = clients.Flight;
const res = await Flight.queryFlightsByAirspace({
......@@ -21,26 +26,37 @@ describe('queryFlightPlans', () => {
includeProposalFlights: false,
trafficType: 'LOAD',
trafficWindow: {
wef: moment.utc().add(2, 'hours').format(timeFormat),
unt: moment.utc().add(4, 'hours').format(timeFormat),
wef: moment
.utc()
.add(2, 'hours')
.format(timeFormat),
unt: moment
.utc()
.add(4, 'hours')
.format(timeFormat),
},
airspace: 'LFEERMS',
});
// $FlowFixMe
if(!res.data.flights) {
if (!res.data.flights) {
return;
}
const knownFlight = res.data.flights.find(({ flight }) => {
if(flight && flight.flightId && flight.flightId.keys && /(AFR)|(BAW)|(MON)|(EZY)/i.test(flight.flightId.keys.aircraftId)) {
if (
flight &&
flight.flightId &&
flight.flightId.keys &&
/(AFR)|(BAW)|(MON)|(EZY)/i.test(flight.flightId.keys.aircraftId)
) {
return true;
}
return false;
});
if(!knownFlight) {
if (!knownFlight) {
throw new Error('Could not find a valid callsign !');
}
......@@ -48,6 +64,10 @@ describe('queryFlightPlans', () => {
});
test('query known flight', async () => {
if (!Flight) {
return;
}
// AFR006 is LFPG to KFJK, hopefully, everyday !
const res = await Flight.queryFlightPlans({
aircraftId: knownCallsign,
......@@ -55,8 +75,14 @@ describe('queryFlightPlans', () => {
airFiled: false,
nonICAOAerodromeOfDestination: false,
estimatedOffBlockTime: {
wef: moment.utc().subtract(12, 'hours').format(timeFormat),
unt: moment.utc().add(12, 'hours').format(timeFormat),
wef: moment
.utc()
.subtract(12, 'hours')
.format(timeFormat),
unt: moment
.utc()
.add(12, 'hours')
.format(timeFormat),
},
});
......
......@@ -11,10 +11,19 @@ describe('queryFlightsByAirspace', () => {
let Flight;
beforeAll(async () => {
const clients = await getClients();
if (!clients) {
return;
}
Flight = clients.Flight;
});
test('query in LFEERMS', async () => {
if(!Flight) {
return;
}
const res = await Flight.queryFlightsByAirspace({
dataset: { type: 'OPERATIONAL' },
includeProposalFlights: false,
......
......@@ -13,6 +13,11 @@ describe('queryFlightsByMeasure', () => {
beforeAll(async () => {
const clients = await getClients();
if (!clients) {
return;
}
Flight = clients.Flight;
const res = await clients.Flow.queryRegulations({
......@@ -23,7 +28,11 @@ describe('queryFlightsByMeasure', () => {
.subtract(10, 'hour')
.startOf('hour')
.format(timeFormat),
unt: moment.utc().add(10, 'hour').startOf('hour').format(timeFormat),
unt: moment
.utc()
.add(10, 'hour')
.startOf('hour')
.format(timeFormat),
},
requestedRegulationFields: { item: ['location', 'reason'] },
});
......@@ -36,18 +45,23 @@ describe('queryFlightsByMeasure', () => {
// $FlowFixMe
item.location['referenceLocation-ReferenceLocationAirspace'] &&
item.location['referenceLocation-ReferenceLocationAirspace'].id &&
regex.test(item.location['referenceLocation-ReferenceLocationAirspace'].id);
regex.test(
item.location['referenceLocation-ReferenceLocationAirspace'].id,
);
const measure = res.data.regulations.item.find(hasAirspaceMatching(/LFE/));
// console.log(inspect(measure, { depth: null }));
// $FlowFixMe
measureId = measure.regulationId;
});
// Not authorised with current certificate
xtest('query in regulation', async () => {
if (!Flight) {
return;
}
if (!measureId) {
console.warn('No measure was found, cannot query flights by measure');
return;
......@@ -64,7 +78,11 @@ describe('queryFlightsByMeasure', () => {
.subtract(1, 'hour')
.startOf('hour')
.format(timeFormat),
unt: moment.utc().add(1, 'hour').startOf('hour').format(timeFormat),
unt: moment
.utc()
.add(1, 'hour')
.startOf('hour')
.format(timeFormat),
},
measure: { REGULATION: measureId },
mode: 'CONCERNED_BY_MEASURE',
......
......@@ -11,30 +11,44 @@ describe('queryFlightsByTrafficVolume', () => {
let Flight;
beforeAll(async () => {
const clients = await getClients();
if (!clients) {
return;
}
Flight = clients.Flight;
});
test('query in LFEERMS', async () => {
if (!Flight) {
return;
}
const res = await Flight.queryFlightsByTrafficVolume({
dataset: { type: 'OPERATIONAL' },
includeProposalFlights: false,
trafficType: 'LOAD',
trafficWindow: {
wef: moment.utc().subtract(10, 'minutes').format(timeFormat),
unt: moment.utc().add(10, 'minutes').format(timeFormat),
wef: moment
.utc()
.subtract(10, 'minutes')
.format(timeFormat),
unt: moment
.utc()
.add(10, 'minutes')
.format(timeFormat),
},
trafficVolume: 'EGLLARR',
});
expect(res.status).toBe('OK');
if(!res.data) {
if (!res.data) {
// No flights in the TV, return early
return;
}
const { data: { flights } } = res;
expect(Array.isArray(flights)).toBe(true);
flights.forEach(flight =>
......
......@@ -12,6 +12,11 @@ describe('retrieveFlight', () => {
let knownFlightKeys;
beforeAll(async () => {
const clients = await getClients();
if (!clients) {
return;
}
Flight = clients.Flight;
const res = await Flight.queryFlightsByAirspace({
......@@ -19,8 +24,14 @@ describe('retrieveFlight', () => {
includeProposalFlights: false,
trafficType: 'LOAD',
trafficWindow: {
wef: moment.utc().subtract(30, 'minutes').format(timeFormat),
unt: moment.utc().add(30, 'minutes').format(timeFormat),
wef: moment
.utc()
.subtract(30, 'minutes')
.format(timeFormat),
unt: moment
.utc()
.add(30, 'minutes')
.format(timeFormat),
},
airspace: 'LFEERMS',
});
......@@ -38,6 +49,10 @@ describe('retrieveFlight', () => {
});
test('query in LFEERMS', async () => {
if (!Flight) {
return;
}
if (!knownFlightKeys) {
throw new Error('Could not fetch a known flight, test aborted !');
}
......
......@@ -10,11 +10,20 @@ describe('queryHotspots', () => {
let Flow;
beforeAll(async () => {
const clients = await getClients();
if (!clients) {
return;
}
Flow = clients.Flow;
});
// Not authorised with this certificate
xtest('List all hotspots', async () => {
if (!Flow) {
return;
}
try {
const res = await Flow.queryHotspots({
dataset: { type: 'OPERATIONAL' },
......
......@@ -10,10 +10,19 @@ describe('queryRegulations', () => {
let Flow;
beforeAll(async () => {
const clients = await getClients();
if (!clients) {
return;
}
Flow = clients.Flow;
});
test('List all regulations', async () => {
if (!Flow) {
return;
}
try {
const res = await Flow.queryRegulations({
dataset: { type: 'OPERATIONAL' },
......
......@@ -10,10 +10,19 @@ describe('queryTrafficCountsByAirspace', () => {
let Flow;
beforeAll(async () => {
const clients = await getClients();
if (!clients) {
return;
}
Flow = clients.Flow;
});
test('LFEE5R, aggregated', async () => {
if (!Flow) {
return;
}
try {
const res = await Flow.queryTrafficCountsByAirspace({
dataset: { type: 'OPERATIONAL' },
......@@ -23,7 +32,11 @@ describe('queryTrafficCountsByAirspace', () => {
.subtract(1, 'hour')
.startOf('hour')
.format(timeFormat),
unt: moment.utc().add(1, 'hour').startOf('hour').format(timeFormat),
unt: moment
.utc()
.add(1, 'hour')
.startOf('hour')
.format(timeFormat),
},
includeProposalFlights: false,
trafficTypes: { item: ['LOAD', 'DEMAND', 'REGULATED_DEMAND'] },
......
......@@ -10,10 +10,19 @@ describe('queryTrafficCountsByTrafficVolume', () => {
let Flow;
beforeAll(async () => {
const clients = await getClients();
if (!clients) {
return;
}
Flow = clients.Flow;
});
test('LFEE5R, aggregated', async () => {
if (!Flow) {
return;
}
try {
const res = await Flow.queryTrafficCountsByTrafficVolume({
dataset: { type: 'OPERATIONAL' },
......@@ -23,7 +32,11 @@ describe('queryTrafficCountsByTrafficVolume', () => {
.subtract(1, 'hour')
.startOf('hour')
.format(timeFormat),
unt: moment.utc().add(1, 'hour').startOf('hour').format(timeFormat),
unt: moment
.utc()
.add(1, 'hour')
.startOf('hour')
.format(timeFormat),
},
includeProposalFlights: false,
trafficTypes: { item: ['LOAD', 'DEMAND', 'REGULATED_DEMAND'] },
......@@ -36,7 +49,6 @@ describe('queryTrafficCountsByTrafficVolume', () => {
calculationType: 'OCCUPANCY',
});
expect(res.data.counts).toBeDefined();
// $FlowFixMe
expect(Array.isArray(res.data.counts.item)).toBe(true);
......
......@@ -11,10 +11,19 @@ describe('retrieveSectorConfigurationPlan', () => {
let Flow;
beforeAll(async () => {
const clients = await getClients();
if (!clients) {
return;
}
Flow = clients.Flow;
});
test('LFEERMS', async () => {
if (!Flow) {
return;
}
try {
const res = await Flow.retrieveSectorConfigurationPlan({
dataset: { type: 'OPERATIONAL' },
......
......@@ -8,10 +8,20 @@ describe('createSubscriptions', () => {
let PubSub;
beforeAll(async () => {
const clients = await getClients();
if (!clients) {
return;
}
PubSub = clients.PublishSubscribe;
});
afterAll(async () => {
if (!PubSub) {
// Test is most likely skipped
return;
}
const res = await PubSub.listSubscriptions();
const { data: { subscriptions } } = res;
......@@ -27,7 +37,9 @@ describe('createSubscriptions', () => {
.filter(({ description }) => description === '__TEST__')
.map(({ uuid }) => uuid);
await Promise.all(toDelete.map(uuid => PubSub.deleteSubscription({ uuid })));
await Promise.all(
toDelete.map(uuid => PubSub.deleteSubscription({ uuid })),
);
});
test('Empty test', () => {});
......
......@@ -10,13 +10,21 @@ describe('listSubscriptions', () => {
let PubSub;
beforeAll(async () => {
const clients = await getClients();
if (!clients) {
return;
}
PubSub = clients.PublishSubscribe;
});
test('Empty test', () => {});
xtest('list subscriptions', async () => {
if (!PubSub) {
return;
}
const res = await PubSub.listSubscriptions();
console.log(inspect(res.data, { depth: null }));
......
/* @flow */
import 'dotenv/config';
import { fromEnv } from '../src/security';
import { makeB2BClient } from '../src';
import { makeB2BClient, type B2BClient } from '../src';
import path from 'path';
let clientsPromise;
export async function getClients(args?: { fresh?: boolean }) {
export async function getClients(args?: {
fresh?: boolean,
}): Promise<?B2BClient> {
if (process.env.CI && !process.env.REAL_B2B_CONNECTIONS) {
console.log('Running in CI context, disabling connections to NM B2B');
return Promise.resolve();
}
if (clientsPromise && !(args && args.fresh)) {
return clientsPromise;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment