Skip to content

Commit b35a6c3

Browse files
committed
Remove unit tests for parser and rely on E2E tests to validate parsing
1 parent bcc9476 commit b35a6c3

File tree

112 files changed

+485
-14225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+485
-14225
lines changed

Package.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ let package = Package(
3333
name: "SwiftNASRTests",
3434
dependencies: ["SwiftNASR", "Quick", "Nimble"],
3535
resources: [
36-
.copy("Resources/MockDistribution"),
37-
.copy("Resources/FailingMockDistribution"),
38-
.copy("Resources/MockCSVDistribution")
36+
.copy("Resources/FailingMockDistribution")
3937
],
4038
linkerSettings: [.linkedLibrary("swift_Concurrency")]
4139
),

Sources/SwiftNASR/Models/Records/CodedDepartureRoute.swift

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,26 @@ public struct CodedDepartureRoute: Record, Identifiable {
2424
/// Full route string (e.g., "KORD MZV LMN J64 CIVET CIVET4 LAX").
2525
public let routeString: String
2626

27-
/// ARTCC identifier (e.g., "KZAU").
28-
public let ARTCCIdentifier: String
27+
/// Departure center ARTCC identifier (e.g., "ZAU").
28+
public let departureCenterIdentifier: String
29+
30+
/// Arrival center ARTCC identifier (e.g., "ZLA").
31+
public let arrivalCenterIdentifier: String?
32+
33+
/// Space-separated list of transition center ARTCC identifiers.
34+
public let transitionCenterIdentifiers: String?
35+
36+
/// Whether coordination is required for this route.
37+
public let coordinationRequired: Bool?
38+
39+
/// Play information or notes for this route.
40+
public let playInfo: String?
41+
42+
/// Navigation equipment requirements.
43+
public let navigationEquipment: String?
44+
45+
/// Route length in nautical miles.
46+
public let lengthNM: UInt?
2947

3048
/// Reference to parent NASRData for cross-referencing.
3149
weak var data: NASRData?
@@ -42,7 +60,12 @@ public struct CodedDepartureRoute: Record, Identifiable {
4260
routeString.split(separator: " ").map(String.init)
4361
}
4462

63+
/// Backward-compatible alias for `departureCenterIdentifier`.
64+
public var ARTCCIdentifier: String { departureCenterIdentifier }
65+
4566
public enum CodingKeys: String, CodingKey {
46-
case routeCode, origin, destination, departureFix, routeString, ARTCCIdentifier
67+
case routeCode, origin, destination, departureFix, routeString
68+
case departureCenterIdentifier, arrivalCenterIdentifier, transitionCenterIdentifiers
69+
case coordinationRequired, playInfo, navigationEquipment, lengthNM
4770
}
4871
}

Sources/SwiftNASR/NASRData.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ public actor NASRData {
8282
for navaidIndex in 0..<navaids!.count {
8383
navaids![navaidIndex].data = self
8484
let findStateByCode = navaids![navaidIndex].findStateByCode()
85+
let findAirportById = navaids![navaidIndex].findAirportById()
8586
for checkpointIndex in 0..<navaids![navaidIndex].checkpoints.count {
8687
navaids![navaidIndex].checkpoints[checkpointIndex].findStateByCode = findStateByCode
88+
navaids![navaidIndex].checkpoints[checkpointIndex].findAirportById = findAirportById
8789
}
8890
}
8991
}

Sources/SwiftNASR/Parsers/CSV/Parsers/CSVCodedDepartureRouteParser.swift

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,42 @@ import ZIPFoundation
44

55
/// CSV Coded Departure Route Parser for parsing CDR.csv
66
///
7-
/// CDR is a comma-delimited file with 6 fields:
8-
/// Route Code, Origin, Destination, Departure Fix, Route String, ARTCC
7+
/// CDR is a comma-delimited file with 12 fields:
8+
/// RCode, Orig, Dest, DepFix, Route String, DCNTR, ACNTR, TCNTRs, CoordReq, Play, NavEqp, Length
99
class CSVCodedDepartureRouteParser: CSVParser {
1010
var csvDirectory = URL(fileURLWithPath: "/")
1111
var routes = [String: CodedDepartureRoute]()
1212

1313
// CSV field mapping (0-based indices)
14-
// Fields: Route Code, Origin, Destination, Departure Fix, Route String, ARTCC
14+
// Fields: RCode, Orig, Dest, DepFix, Route String, DCNTR, ACNTR, TCNTRs, CoordReq, Play, NavEqp, Length
1515
private let csvFieldMapping: [Int] = [
16-
0, // 0: Route Code
17-
1, // 1: Origin
18-
2, // 2: Destination
19-
3, // 3: Departure Fix
16+
0, // 0: RCode (Route Code)
17+
1, // 1: Orig (Origin)
18+
2, // 2: Dest (Destination)
19+
3, // 3: DepFix (Departure Fix)
2020
4, // 4: Route String
21-
5 // 5: ARTCC
21+
5, // 5: DCNTR (Departure Center)
22+
6, // 6: ACNTR (Arrival Center)
23+
7, // 7: TCNTRs (Transition Centers)
24+
8, // 8: CoordReq (Coordination Required)
25+
9, // 9: Play (Play Info)
26+
10, // 10: NavEqp (Navigation Equipment)
27+
11 // 11: Length
2228
]
2329

2430
private let transformer = CSVTransformer([
25-
.string(), // 0: Route Code
26-
.string(), // 1: Origin
27-
.string(), // 2: Destination
28-
.string(), // 3: Departure Fix
31+
.string(), // 0: RCode
32+
.string(), // 1: Orig
33+
.string(), // 2: Dest
34+
.string(), // 3: DepFix
2935
.string(), // 4: Route String
30-
.string() // 5: ARTCC
36+
.string(), // 5: DCNTR
37+
.string(nullable: .blank), // 6: ACNTR
38+
.string(nullable: .blank), // 7: TCNTRs
39+
.string(nullable: .blank), // 8: CoordReq (Y/N)
40+
.string(nullable: .blank), // 9: Play
41+
.string(nullable: .blank), // 10: NavEqp
42+
.unsignedInteger(nullable: .blank) // 11: Length
3143
])
3244

3345
func prepare(distribution: Distribution) throws {
@@ -44,35 +56,50 @@ class CSVCodedDepartureRouteParser: CSVParser {
4456
}
4557

4658
func parse(data _: Data) async throws {
47-
try await parseCSVFile(filename: "CDR.csv", expectedFieldCount: 6) { fields in
48-
guard fields.count >= 3 else {
59+
try await parseCSVFile(filename: "CDR.csv", expectedFieldCount: 12) { fields in
60+
guard fields.count >= 6 else {
4961
throw ParserError.truncatedRecord(
5062
recordType: "CDR",
51-
expectedMinLength: 3,
63+
expectedMinLength: 6,
5264
actualLength: fields.count
5365
)
5466
}
5567

56-
var mappedFields = [String](repeating: "", count: 6)
68+
var mappedFields = [String](repeating: "", count: 12)
5769
for (transformerIndex, csvIndex) in self.csvFieldMapping.enumerated()
5870
where csvIndex < fields.count {
5971
mappedFields[transformerIndex] = fields[csvIndex]
6072
}
6173

6274
let transformedValues = try self.transformer.applyTo(
6375
mappedFields,
64-
indices: Array(0..<6)
76+
indices: Array(0..<12)
6577
)
6678

6779
let routeCode = transformedValues[0] as! String
6880

81+
// Parse CoordReq (Y/N) to Bool
82+
let coordReqString = transformedValues[8] as? String
83+
let coordinationRequired: Bool?
84+
switch coordReqString?.uppercased() {
85+
case "Y": coordinationRequired = true
86+
case "N": coordinationRequired = false
87+
default: coordinationRequired = nil
88+
}
89+
6990
let route = CodedDepartureRoute(
7091
routeCode: routeCode,
7192
origin: transformedValues[1] as! String,
7293
destination: transformedValues[2] as! String,
7394
departureFix: transformedValues[3] as! String,
7495
routeString: transformedValues[4] as! String,
75-
ARTCCIdentifier: transformedValues[5] as! String
96+
departureCenterIdentifier: transformedValues[5] as! String,
97+
arrivalCenterIdentifier: transformedValues[6] as? String,
98+
transitionCenterIdentifiers: transformedValues[7] as? String,
99+
coordinationRequired: coordinationRequired,
100+
playInfo: transformedValues[9] as? String,
101+
navigationEquipment: transformedValues[10] as? String,
102+
lengthNM: transformedValues[11] as? UInt
76103
)
77104

78105
self.routes[routeCode] = route

Tests/SwiftNASRTests/CSV/ARTCCCSVParserSpec.swift

Lines changed: 0 additions & 105 deletions
This file was deleted.

0 commit comments

Comments
 (0)