gtfs 3.8.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/index.d.ts +130 -137
- package/@types/tests.ts +18 -13
- package/CHANGELOG.md +18 -0
- package/README.md +233 -212
- package/config-sample-rtupdates.json +6 -18
- package/lib/advancedQuery.js +8 -17
- package/lib/db.js +35 -59
- package/lib/export.js +16 -10
- package/lib/gtfs/agencies.js +8 -6
- package/lib/gtfs/areas.js +8 -11
- package/lib/gtfs/attributions.js +8 -6
- package/lib/gtfs/calendar-dates.js +8 -6
- package/lib/gtfs/calendars.js +8 -6
- package/lib/gtfs/fare-attributes.js +8 -6
- package/lib/gtfs/fare-leg-rules.js +8 -6
- package/lib/gtfs/fare-products.js +8 -6
- package/lib/gtfs/fare-rules.js +8 -6
- package/lib/gtfs/fare-transfer-rules.js +8 -6
- package/lib/gtfs/feed-info.js +8 -6
- package/lib/gtfs/frequencies.js +8 -6
- package/lib/gtfs/levels.js +8 -11
- package/lib/gtfs/pathways.js +8 -6
- package/lib/gtfs/routes.js +8 -11
- package/lib/gtfs/shapes.js +34 -39
- package/lib/gtfs/stop-areas.js +8 -6
- package/lib/gtfs/stop-times.js +8 -6
- package/lib/gtfs/stops.js +27 -33
- package/lib/gtfs/transfers.js +8 -6
- package/lib/gtfs/translations.js +8 -6
- package/lib/gtfs/trips.js +8 -11
- package/lib/gtfs-realtime/service-alerts.js +9 -7
- package/lib/gtfs-realtime/stop-times-updates.js +9 -7
- package/lib/gtfs-realtime/trip-updates.js +9 -7
- package/lib/gtfs-realtime/vehicle-positions.js +9 -7
- package/lib/gtfs-ride/board-alights.js +8 -6
- package/lib/gtfs-ride/ride-feed-infos.js +8 -6
- package/lib/gtfs-ride/rider-trips.js +8 -6
- package/lib/gtfs-ride/riderships.js +8 -6
- package/lib/gtfs-ride/trip-capacities.js +8 -6
- package/lib/gtfs.js +3 -9
- package/lib/import.js +213 -273
- package/lib/non-standard/directions.js +8 -6
- package/lib/non-standard/stop-attributes.js +8 -6
- package/lib/non-standard/timetable-notes-references.js +8 -6
- package/lib/non-standard/timetable-notes.js +8 -6
- package/lib/non-standard/timetable-pages.js +8 -6
- package/lib/non-standard/timetable-stop-order.js +8 -6
- package/lib/non-standard/timetables.js +8 -6
- package/lib/non-standard/trips-dated-vehicle-journey.js +9 -7
- package/package.json +4 -4
- package/test/mocha/advanced-query.js +9 -15
- package/test/mocha/export-gtfs.js +5 -6
- package/test/mocha/fare-transfer-rules.js +32 -0
- package/test/mocha/get-agencies.js +13 -19
- package/test/mocha/get-areas.js +27 -0
- package/test/mocha/get-attributions.js +7 -13
- package/test/mocha/get-board-alights.js +7 -13
- package/test/mocha/get-calendar-dates.js +11 -17
- package/test/mocha/get-calendars.js +11 -17
- package/test/mocha/get-directions.js +7 -13
- package/test/mocha/get-fare-attributes.js +9 -15
- package/test/mocha/get-fare-leg-rules.js +27 -0
- package/test/mocha/get-fare-products.js +27 -0
- package/test/mocha/get-fare-rules.js +9 -15
- package/test/mocha/get-feed-info.js +7 -13
- package/test/mocha/get-frequencies.js +7 -13
- package/test/mocha/get-levels.js +7 -7
- package/test/mocha/get-pathways.js +7 -13
- package/test/mocha/get-ride-feed-infos.js +7 -13
- package/test/mocha/get-rider-trips.js +7 -13
- package/test/mocha/get-riderships.js +7 -13
- package/test/mocha/get-routes.js +13 -13
- package/test/mocha/get-shapes-as-geojson.js +14 -15
- package/test/mocha/get-shapes.js +25 -25
- package/test/mocha/get-stop-attributes.js +7 -13
- package/test/mocha/get-stops-as-geojson.js +13 -19
- package/test/mocha/get-stops.js +19 -19
- package/test/mocha/get-stoptimes.js +11 -17
- package/test/mocha/get-timetable-pages.js +7 -13
- package/test/mocha/get-timetable-stop-orders.js +6 -7
- package/test/mocha/get-timetables.js +7 -13
- package/test/mocha/get-transfers.js +7 -13
- package/test/mocha/get-translations.js +7 -13
- package/test/mocha/get-trip-capacities.js +7 -13
- package/test/mocha/get-trips.js +9 -9
- package/test/mocha/import-gtfs.js +11 -11
- package/test/mocha/{get-db.js → open-db.js} +37 -29
- package/test/mocha/raw-query.js +34 -0
- package/test/mocha/exec-raw-query.js +0 -39
- package/test/mocha/run-raw-query.js +0 -54
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import sqlString from 'sqlstring-sqlite';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { openDb } from '../db.js';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
formatOrderByClause,
|
|
@@ -12,19 +12,21 @@ import directions from '../../models/non-standard/directions.js';
|
|
|
12
12
|
/*
|
|
13
13
|
* Returns an array of all directions that match the query parameters.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export function getDirections(
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
19
|
options = {}
|
|
20
20
|
) {
|
|
21
|
-
const db = options.db ?? (
|
|
21
|
+
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(directions.filenameBase);
|
|
23
23
|
const selectClause = formatSelectClause(fields);
|
|
24
24
|
const whereClause = formatWhereClauses(query);
|
|
25
25
|
const orderByClause = formatOrderByClause(orderBy);
|
|
26
26
|
|
|
27
|
-
return db
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return db
|
|
28
|
+
.prepare(
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
|
|
30
|
+
)
|
|
31
|
+
.all();
|
|
30
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import sqlString from 'sqlstring-sqlite';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { openDb } from '../db.js';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
formatOrderByClause,
|
|
@@ -12,19 +12,21 @@ import stopAttributes from '../../models/non-standard/stop-attributes.js';
|
|
|
12
12
|
/*
|
|
13
13
|
* Returns an array of all stop attributes that match the query parameters.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export function getStopAttributes(
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
19
|
options = {}
|
|
20
20
|
) {
|
|
21
|
-
const db = options.db ?? (
|
|
21
|
+
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(stopAttributes.filenameBase);
|
|
23
23
|
const selectClause = formatSelectClause(fields);
|
|
24
24
|
const whereClause = formatWhereClauses(query);
|
|
25
25
|
const orderByClause = formatOrderByClause(orderBy);
|
|
26
26
|
|
|
27
|
-
return db
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return db
|
|
28
|
+
.prepare(
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
|
|
30
|
+
)
|
|
31
|
+
.all();
|
|
30
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import sqlString from 'sqlstring-sqlite';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { openDb } from '../db.js';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
formatOrderByClause,
|
|
@@ -12,19 +12,21 @@ import timetableNotesReferences from '../../models/non-standard/timetable-notes-
|
|
|
12
12
|
/*
|
|
13
13
|
* Returns an array of all timetable notes references that match the query parameters.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export function getTimetableNotesReferences(
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
19
|
options = {}
|
|
20
20
|
) {
|
|
21
|
-
const db = options.db ?? (
|
|
21
|
+
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(timetableNotesReferences.filenameBase);
|
|
23
23
|
const selectClause = formatSelectClause(fields);
|
|
24
24
|
const whereClause = formatWhereClauses(query);
|
|
25
25
|
const orderByClause = formatOrderByClause(orderBy);
|
|
26
26
|
|
|
27
|
-
return db
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return db
|
|
28
|
+
.prepare(
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
|
|
30
|
+
)
|
|
31
|
+
.all();
|
|
30
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import sqlString from 'sqlstring-sqlite';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { openDb } from '../db.js';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
formatOrderByClause,
|
|
@@ -12,19 +12,21 @@ import timetableNotes from '../../models/non-standard/timetable-notes.js';
|
|
|
12
12
|
/*
|
|
13
13
|
* Returns an array of all timetable notes that match the query parameters.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export function getTimetableNotes(
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
19
|
options = {}
|
|
20
20
|
) {
|
|
21
|
-
const db = options.db ?? (
|
|
21
|
+
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(timetableNotes.filenameBase);
|
|
23
23
|
const selectClause = formatSelectClause(fields);
|
|
24
24
|
const whereClause = formatWhereClauses(query);
|
|
25
25
|
const orderByClause = formatOrderByClause(orderBy);
|
|
26
26
|
|
|
27
|
-
return db
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return db
|
|
28
|
+
.prepare(
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
|
|
30
|
+
)
|
|
31
|
+
.all();
|
|
30
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import sqlString from 'sqlstring-sqlite';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { openDb } from '../db.js';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
formatOrderByClause,
|
|
@@ -12,19 +12,21 @@ import timetablePages from '../../models/non-standard/timetable-pages.js';
|
|
|
12
12
|
/*
|
|
13
13
|
* Returns an array of all timetable pages that match the query parameters.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export function getTimetablePages(
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
19
|
options = {}
|
|
20
20
|
) {
|
|
21
|
-
const db = options.db ?? (
|
|
21
|
+
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(timetablePages.filenameBase);
|
|
23
23
|
const selectClause = formatSelectClause(fields);
|
|
24
24
|
const whereClause = formatWhereClauses(query);
|
|
25
25
|
const orderByClause = formatOrderByClause(orderBy);
|
|
26
26
|
|
|
27
|
-
return db
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return db
|
|
28
|
+
.prepare(
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
|
|
30
|
+
)
|
|
31
|
+
.all();
|
|
30
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import sqlString from 'sqlstring-sqlite';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { openDb } from '../db.js';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
formatOrderByClause,
|
|
@@ -12,19 +12,21 @@ import timetableStopOrder from '../../models/non-standard/timetable-stop-order.j
|
|
|
12
12
|
/*
|
|
13
13
|
* Returns an array of all timetable stop orders that match the query parameters.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export function getTimetableStopOrders(
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
19
|
options = {}
|
|
20
20
|
) {
|
|
21
|
-
const db = options.db ?? (
|
|
21
|
+
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(timetableStopOrder.filenameBase);
|
|
23
23
|
const selectClause = formatSelectClause(fields);
|
|
24
24
|
const whereClause = formatWhereClauses(query);
|
|
25
25
|
const orderByClause = formatOrderByClause(orderBy);
|
|
26
26
|
|
|
27
|
-
return db
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return db
|
|
28
|
+
.prepare(
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
|
|
30
|
+
)
|
|
31
|
+
.all();
|
|
30
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import sqlString from 'sqlstring-sqlite';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { openDb } from '../db.js';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
formatOrderByClause,
|
|
@@ -12,19 +12,21 @@ import timetables from '../../models/non-standard/timetables.js';
|
|
|
12
12
|
/*
|
|
13
13
|
* Returns an array of all timetables that match the query parameters.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export function getTimetables(
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
19
|
options = {}
|
|
20
20
|
) {
|
|
21
|
-
const db = options.db ?? (
|
|
21
|
+
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(timetables.filenameBase);
|
|
23
23
|
const selectClause = formatSelectClause(fields);
|
|
24
24
|
const whereClause = formatWhereClauses(query);
|
|
25
25
|
const orderByClause = formatOrderByClause(orderBy);
|
|
26
26
|
|
|
27
|
-
return db
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return db
|
|
28
|
+
.prepare(
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
|
|
30
|
+
)
|
|
31
|
+
.all();
|
|
30
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import sqlString from 'sqlstring-sqlite';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { openDb } from '../db.js';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
formatOrderByClause,
|
|
@@ -10,21 +10,23 @@ import {
|
|
|
10
10
|
import directions from '../../models/non-standard/trips-dated-vehicle-journey.js';
|
|
11
11
|
|
|
12
12
|
/*
|
|
13
|
-
* Returns an array of all
|
|
13
|
+
* Returns an array of all trips dated vehicle journeys that match the query parameters.
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export function getTripsDatedVehicleJourneys(
|
|
16
16
|
query = {},
|
|
17
17
|
fields = [],
|
|
18
18
|
orderBy = [],
|
|
19
19
|
options = {}
|
|
20
20
|
) {
|
|
21
|
-
const db = options.db ?? (
|
|
21
|
+
const db = options.db ?? openDb();
|
|
22
22
|
const tableName = sqlString.escapeId(directions.filenameBase);
|
|
23
23
|
const selectClause = formatSelectClause(fields);
|
|
24
24
|
const whereClause = formatWhereClauses(query);
|
|
25
25
|
const orderByClause = formatOrderByClause(orderBy);
|
|
26
26
|
|
|
27
|
-
return db
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
return db
|
|
28
|
+
.prepare(
|
|
29
|
+
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
|
|
30
|
+
)
|
|
31
|
+
.all();
|
|
30
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gtfs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Import GTFS transit data into SQLite and query routes, stops, times, fares and more",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"transit",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"@turf/helpers": "^6.5.0",
|
|
77
|
+
"better-sqlite3": "^8.0.1",
|
|
77
78
|
"csv-parse": "^5.3.3",
|
|
78
79
|
"csv-stringify": "^6.2.3",
|
|
79
80
|
"gtfs-realtime-bindings": "^0.0.6",
|
|
@@ -85,8 +86,6 @@
|
|
|
85
86
|
"promise-map-series": "^0.3.0",
|
|
86
87
|
"recursive-copy": "^2.0.14",
|
|
87
88
|
"sanitize-filename": "^1.6.3",
|
|
88
|
-
"sqlite": "^4.1.2",
|
|
89
|
-
"sqlite3": "^5.1.4",
|
|
90
89
|
"sqlstring-sqlite": "^0.1.1",
|
|
91
90
|
"strip-bom-stream": "^5.0.0",
|
|
92
91
|
"tmp-promise": "^3.0.3",
|
|
@@ -96,8 +95,9 @@
|
|
|
96
95
|
"yoctocolors": "^1.0.0"
|
|
97
96
|
},
|
|
98
97
|
"devDependencies": {
|
|
98
|
+
"@types/better-sqlite3": "^7.6.3",
|
|
99
99
|
"dtslint": "^4.2.1",
|
|
100
|
-
"eslint": "^8.
|
|
100
|
+
"eslint": "^8.31.0",
|
|
101
101
|
"eslint-config-prettier": "^8.5.0",
|
|
102
102
|
"eslint-config-xo": "^0.43.1",
|
|
103
103
|
"husky": "^8.0.2",
|
|
@@ -3,26 +3,20 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
advancedQuery,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, advancedQuery } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('advancedQuery():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no trips',
|
|
19
|
+
it('should return empty array if no trips', () => {
|
|
26
20
|
const routeId = 'fake-route-id';
|
|
27
21
|
|
|
28
22
|
const advancedQueryOptions = {
|
|
@@ -38,13 +32,13 @@ describe('advancedQuery():', () => {
|
|
|
38
32
|
},
|
|
39
33
|
],
|
|
40
34
|
};
|
|
41
|
-
const results =
|
|
35
|
+
const results = advancedQuery('stop_times', advancedQueryOptions);
|
|
42
36
|
|
|
43
37
|
should.exists(results);
|
|
44
38
|
results.should.have.length(0);
|
|
45
39
|
});
|
|
46
40
|
|
|
47
|
-
it('should return expected trips with joined trip',
|
|
41
|
+
it('should return expected trips with joined trip', () => {
|
|
48
42
|
const tripId = '329';
|
|
49
43
|
|
|
50
44
|
const advancedQueryOptions = {
|
|
@@ -60,7 +54,7 @@ describe('advancedQuery():', () => {
|
|
|
60
54
|
},
|
|
61
55
|
],
|
|
62
56
|
};
|
|
63
|
-
const results =
|
|
57
|
+
const results = advancedQuery('stop_times', advancedQueryOptions);
|
|
64
58
|
|
|
65
59
|
const expectedResults = [
|
|
66
60
|
{ trip_id: '329', arrival_time: '9:09:00' },
|
|
@@ -12,7 +12,6 @@ import { unzip, generateFolderName } from '../../lib/file-utils.js';
|
|
|
12
12
|
import config from '../test-config.js';
|
|
13
13
|
import {
|
|
14
14
|
openDb,
|
|
15
|
-
getDb,
|
|
16
15
|
closeDb,
|
|
17
16
|
importGtfs,
|
|
18
17
|
exportGtfs,
|
|
@@ -22,13 +21,13 @@ import models from '../../models/models.js';
|
|
|
22
21
|
|
|
23
22
|
describe('exportGtfs():', function () {
|
|
24
23
|
before(async () => {
|
|
25
|
-
|
|
24
|
+
openDb(config);
|
|
26
25
|
await importGtfs(config);
|
|
27
26
|
});
|
|
28
27
|
|
|
29
28
|
after(async () => {
|
|
30
|
-
const db =
|
|
31
|
-
|
|
29
|
+
const db = openDb(config);
|
|
30
|
+
closeDb(db);
|
|
32
31
|
});
|
|
33
32
|
|
|
34
33
|
this.timeout(10000);
|
|
@@ -86,7 +85,7 @@ describe('exportGtfs():', function () {
|
|
|
86
85
|
});
|
|
87
86
|
|
|
88
87
|
after(async () => {
|
|
89
|
-
const agencies =
|
|
88
|
+
const agencies = getAgencies({}, ['agency_name']);
|
|
90
89
|
await rm(
|
|
91
90
|
path.join(
|
|
92
91
|
process.cwd(),
|
|
@@ -99,7 +98,7 @@ describe('exportGtfs():', function () {
|
|
|
99
98
|
|
|
100
99
|
for (const model of models) {
|
|
101
100
|
it(`should import the same number of ${model.filenameBase}`, async () => {
|
|
102
|
-
const agencies =
|
|
101
|
+
const agencies = getAgencies({}, ['agency_name']);
|
|
103
102
|
const filePath = path.join(
|
|
104
103
|
process.cwd(),
|
|
105
104
|
'gtfs-export',
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
|
|
3
|
+
import should from 'should';
|
|
4
|
+
|
|
5
|
+
import config from '../test-config.js';
|
|
6
|
+
import {
|
|
7
|
+
openDb,
|
|
8
|
+
closeDb,
|
|
9
|
+
importGtfs,
|
|
10
|
+
getFareTransferRules,
|
|
11
|
+
} from '../../index.js';
|
|
12
|
+
|
|
13
|
+
describe('getFareTransferRules():', () => {
|
|
14
|
+
before(async () => {
|
|
15
|
+
openDb(config);
|
|
16
|
+
await importGtfs(config);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
after(() => {
|
|
20
|
+
const db = openDb(config);
|
|
21
|
+
closeDb(db);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should return empty array if no fare_transfer_rules exist', () => {
|
|
25
|
+
const transferId = 'fake-transfer-id';
|
|
26
|
+
const results = getFareTransferRules({
|
|
27
|
+
transfer_id: transferId,
|
|
28
|
+
});
|
|
29
|
+
should.exists(results);
|
|
30
|
+
results.should.have.length(0);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -2,36 +2,30 @@
|
|
|
2
2
|
import should from 'should';
|
|
3
3
|
|
|
4
4
|
import config from '../test-config.js';
|
|
5
|
-
import {
|
|
6
|
-
openDb,
|
|
7
|
-
getDb,
|
|
8
|
-
closeDb,
|
|
9
|
-
importGtfs,
|
|
10
|
-
getAgencies,
|
|
11
|
-
} from '../../index.js';
|
|
5
|
+
import { openDb, closeDb, importGtfs, getAgencies } from '../../index.js';
|
|
12
6
|
|
|
13
7
|
describe('getAgencies():', () => {
|
|
14
8
|
before(async () => {
|
|
15
|
-
|
|
9
|
+
openDb(config);
|
|
16
10
|
await importGtfs(config);
|
|
17
11
|
});
|
|
18
12
|
|
|
19
|
-
after(
|
|
20
|
-
const db =
|
|
21
|
-
|
|
13
|
+
after(() => {
|
|
14
|
+
const db = openDb(config);
|
|
15
|
+
closeDb(db);
|
|
22
16
|
});
|
|
23
17
|
|
|
24
|
-
it('should return empty array if no agencies exist',
|
|
18
|
+
it('should return empty array if no agencies exist', () => {
|
|
25
19
|
const agencyId = 'fake-agency-id';
|
|
26
|
-
const results =
|
|
20
|
+
const results = getAgencies({
|
|
27
21
|
agency_id: agencyId,
|
|
28
22
|
});
|
|
29
23
|
should.exists(results);
|
|
30
24
|
results.should.have.length(0);
|
|
31
25
|
});
|
|
32
26
|
|
|
33
|
-
it('should return expected agencies with no query',
|
|
34
|
-
const results =
|
|
27
|
+
it('should return expected agencies with no query', () => {
|
|
28
|
+
const results = getAgencies();
|
|
35
29
|
|
|
36
30
|
const expectedResult = {
|
|
37
31
|
id: 1,
|
|
@@ -50,11 +44,11 @@ describe('getAgencies():', () => {
|
|
|
50
44
|
expectedResult.should.match(results[0]);
|
|
51
45
|
});
|
|
52
46
|
|
|
53
|
-
it('should return expected agency for agency_id and agency_lang',
|
|
47
|
+
it('should return expected agency for agency_id and agency_lang', () => {
|
|
54
48
|
const agencyId = 'CT';
|
|
55
49
|
const agencyLand = 'en';
|
|
56
50
|
|
|
57
|
-
const results =
|
|
51
|
+
const results = getAgencies({
|
|
58
52
|
agency_id: agencyId,
|
|
59
53
|
agency_lang: agencyLand,
|
|
60
54
|
});
|
|
@@ -76,10 +70,10 @@ describe('getAgencies():', () => {
|
|
|
76
70
|
expectedResult.should.match(results[0]);
|
|
77
71
|
});
|
|
78
72
|
|
|
79
|
-
it('should return only specific keys for expected agency for agency_id',
|
|
73
|
+
it('should return only specific keys for expected agency for agency_id', () => {
|
|
80
74
|
const agencyId = 'CT';
|
|
81
75
|
|
|
82
|
-
const results =
|
|
76
|
+
const results = getAgencies(
|
|
83
77
|
{
|
|
84
78
|
agency_id: agencyId,
|
|
85
79
|
},
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
|
|
3
|
+
import should from 'should';
|
|
4
|
+
|
|
5
|
+
import config from '../test-config.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getAreas } from '../../index.js';
|
|
7
|
+
|
|
8
|
+
describe('getAreas():', () => {
|
|
9
|
+
before(async () => {
|
|
10
|
+
openDb(config);
|
|
11
|
+
await importGtfs(config);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should return empty array if no areas exist', () => {
|
|
20
|
+
const areaId = 'fake-area-id';
|
|
21
|
+
const results = getAreas({
|
|
22
|
+
area_id: areaId,
|
|
23
|
+
});
|
|
24
|
+
should.exists(results);
|
|
25
|
+
results.should.have.length(0);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -3,28 +3,22 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getAttributions,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getAttributions } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getAttributions():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no attributions exist',
|
|
19
|
+
it('should return empty array if no attributions exist', () => {
|
|
26
20
|
const attributionId = 'fake-attribution-id';
|
|
27
|
-
const results =
|
|
21
|
+
const results = getAttributions({
|
|
28
22
|
attribution_id: attributionId,
|
|
29
23
|
});
|
|
30
24
|
should.exists(results);
|
|
@@ -3,29 +3,23 @@
|
|
|
3
3
|
import should from 'should';
|
|
4
4
|
|
|
5
5
|
import config from '../test-config.js';
|
|
6
|
-
import {
|
|
7
|
-
openDb,
|
|
8
|
-
getDb,
|
|
9
|
-
closeDb,
|
|
10
|
-
importGtfs,
|
|
11
|
-
getBoardAlights,
|
|
12
|
-
} from '../../index.js';
|
|
6
|
+
import { openDb, closeDb, importGtfs, getBoardAlights } from '../../index.js';
|
|
13
7
|
|
|
14
8
|
describe('getBoardAlights():', () => {
|
|
15
9
|
before(async () => {
|
|
16
|
-
|
|
10
|
+
openDb(config);
|
|
17
11
|
await importGtfs(config);
|
|
18
12
|
});
|
|
19
13
|
|
|
20
|
-
after(
|
|
21
|
-
const db =
|
|
22
|
-
|
|
14
|
+
after(() => {
|
|
15
|
+
const db = openDb(config);
|
|
16
|
+
closeDb(db);
|
|
23
17
|
});
|
|
24
18
|
|
|
25
|
-
it('should return empty array if no board alights (GTFS-ride)',
|
|
19
|
+
it('should return empty array if no board alights (GTFS-ride)', () => {
|
|
26
20
|
const tripId = 'fake-trip-id';
|
|
27
21
|
|
|
28
|
-
const results =
|
|
22
|
+
const results = getBoardAlights({
|
|
29
23
|
trip_id: tripId,
|
|
30
24
|
});
|
|
31
25
|
should.exists(results);
|