krz/moonrise

Night-sky companion for iPhone, Apple Watch and Vision Pro: what's up tonight, the Moon, planets, launches and missions, and a Library of the solar system. SwiftUI app with a Cloudflare Workers backend. astronomy cloudflare-workers ios night-sky space swiftui visionos watchos

Packages/MoonriseKit/Tests/FeedsTests/DSNTests.swift

04b2b1d914788057bcd20945b876847386eb8f65
moonrise/Packages/MoonriseKit/Tests/FeedsTests/DSNTests.swift history · blame · raw

32 lines · 1432 bytes

2 symbols in this file
 1import Foundation
 2import Testing
 3@testable import Feeds
 4
 5@Test func decodesLiveDSNSnapshot() throws {
 6    // dsn.xml saved from eyes.nasa.gov/dsn/data/dsn.xml on 2026-10-18.
 7    let url = try #require(Bundle.module.url(forResource: "Fixtures/dsn", withExtension: "xml"))
 8    let s = try DSNStatus.decode(Data(contentsOf: url))
 9    #expect(s.dishes.count == 15)
10    #expect(Set(s.dishes.map(\.station)) == ["Goldstone", "Madrid", "Canberra"])
11    #expect(s.updated > Date(timeIntervalSince1970: 1_790_000_000))
12    #expect(s.dishes.first { $0.name == "DSS14" }?.activity == "Engineering Upgrades")
13}
14
15@Test func linksNeedAnActiveSignal() throws {
16    let xml = Data("""
17    <dsn><station name="gdscc" friendlyName="Goldstone" timeUTC="1792312582000"/>
18    <dish name="DSS43" activity="Spacecraft Telemetry">
19      <downSignal active="true" dataRate="160" band="X" spacecraft="VGR2" spacecraftID="-32"/>
20      <upSignal active="false" spacecraft="VGR2" spacecraftID="-32"/>
21      <downSignal active="false" spacecraft="MRO" spacecraftID="-74"/>
22      <target name="VGR2" id="32" rtlt="138000"/>
23    </dish></dsn>
24    """.utf8)
25    let s = try DSNStatus.decode(xml)
26    let links = try #require(s.dishes.first?.links)
27    #expect(links.count == 1)
28    #expect(links[0].spacecraft == "Voyager 2")
29    #expect(links[0].receiving && !links[0].sending)
30    #expect(links[0].downlinkRate == 160)
31    #expect(links[0].roundTrip == 138000)
32}