Skip to content

Commit

Permalink
Remove unused code from DataPoint and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sxg committed Mar 13, 2019
1 parent 33288c2 commit 6b97eee
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 95 deletions.
82 changes: 0 additions & 82 deletions Source/DataPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,86 +122,4 @@ public struct DataPoint: Decodable {
case time, summary, icon, sunriseTime, sunsetTime, moonPhase, nearestStormDistance, nearestStormBearing, precipitationIntensity, precipitationIntensityMax, precipitationIntensityMaxTime, precipitationProbability, precipitationAccumulation, temperature, temperatureLow, temperatureLowTime, temperatureHigh, temperatureHighTime, apparentTemperature, apparentTemperatureLow, apparentTemperatureLowTime, apparentTemperatureHigh, apparentTemperatureHighTime, dewPoint, windGust, windSpeed, windBearing, cloudCover, humidity, pressure, visibility, ozone, uvIndex, uvIndexTime
}

/// Creates a new `DataPoint` from a JSON object.
///
/// - parameter json: A JSON object with keys corresponding to the `DataPoint`'s properties.
///
/// - returns: A new `DataPoint` filled with data from the given JSON object.
public init(fromJSON json: NSDictionary) {
time = Date(timeIntervalSince1970: json["time"] as! Double)
summary = json["summary"] as? String
if let jsonIcon = json["icon"] as? String {
icon = Icon(rawValue: jsonIcon)
} else {
icon = nil
}
if let jsonSunriseTime = json["sunriseTime"] as? Double {
sunriseTime = Date(timeIntervalSince1970: jsonSunriseTime)
} else {
sunriseTime = nil
}
if let jsonSunsetTime = json["sunsetTime"] as? Double {
sunsetTime = Date(timeIntervalSince1970: jsonSunsetTime)
} else {
sunsetTime = nil
}
moonPhase = json["moonPhase"] as? Double
nearestStormDistance = json["nearestStormDistance"] as? Double
nearestStormBearing = json["nearestStormBearing"] as? Double
precipitationIntensity = json["precipIntensity"] as? Double
precipitationIntensityMax = json["precipIntensityMax"] as? Double
if let jsonPrecipitationIntensityMaxTime = json["precipIntensityMaxTime"] as? Double {
precipitationIntensityMaxTime = Date(timeIntervalSince1970: jsonPrecipitationIntensityMaxTime)
} else {
precipitationIntensityMaxTime = nil
}
precipitationProbability = json["precipProbability"] as? Double
if let jsonPrecipitationType = json["precipType"] as? String {
precipitationType = Precipitation(rawValue: jsonPrecipitationType)
} else {
precipitationType = nil
}
precipitationAccumulation = json["precipAccumulation"] as? Double
temperature = json["temperature"] as? Double
temperatureLow = json["temperatureLow"] as? Double
if let jsonTemperatureLowTime = json["temperatureLowTime"] as? Double {
temperatureLowTime = Date(timeIntervalSince1970: jsonTemperatureLowTime)
} else {
temperatureLowTime = nil
}
temperatureHigh = json["temperatureHigh"] as? Double
if let jsonTemperatureHighTime = json["temperatureHighTime"] as? Double {
temperatureHighTime = Date(timeIntervalSince1970: jsonTemperatureHighTime)
} else {
temperatureHighTime = nil
}
apparentTemperature = json["apparentTemperature"] as? Double
apparentTemperatureLow = json["apparentTemperatureLow"] as? Double
if let jsonApparentTemperatureLowTime = json["apparentTemperatureLowTime"] as? Double {
apparentTemperatureLowTime = Date(timeIntervalSince1970: jsonApparentTemperatureLowTime)
} else {
apparentTemperatureLowTime = nil
}
apparentTemperatureHigh = json["apparentTemperatureHigh"] as? Double
if let jsonApparentTemperatureHighTime = json["apparentTemperatureHighTime"] as? Double {
apparentTemperatureHighTime = Date(timeIntervalSince1970: jsonApparentTemperatureHighTime)
} else {
apparentTemperatureHighTime = nil
}
dewPoint = json["dewPoint"] as? Double
windGust = json["windGust"] as? Double
windSpeed = json["windSpeed"] as? Double
windBearing = json["windBearing"] as? Double
cloudCover = json["cloudCover"] as? Double
humidity = json["humidity"] as? Double
pressure = json["pressure"] as? Double
visibility = json["visibility"] as? Double
ozone = json["ozone"] as? Double
uvIndex = json["uvIndex"] as? Double
if let jsonUVIndexTime = json["uvIndexTime"] as? Double {
uvIndexTime = Date(timeIntervalSince1970: jsonUVIndexTime)
} else {
uvIndexTime = nil
}
}
}
13 changes: 0 additions & 13 deletions Tests/DataPointTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,6 @@ class DataPointTests: XCTestCase {
super.tearDown()
}

func testInitFromJSON() {
// Given
// When
// let dataPoint = DataPoint(fromJSON: self.dataPointJSON)

// Then
// XCTAssertNotNil(dataPoint)
// XCTAssertEqual(dataPoint.time, Date(timeIntervalSince1970: 1453575677))
// XCTAssertEqual(dataPoint.summary, "Snow")
// XCTAssertEqual(dataPoint.icon, Icon.snow)
// XCTAssertEqual(dataPoint.precipitationType, Precipitation.snow)
}

func testInitFromDecoder() {
// Given
// When
Expand Down

0 comments on commit 6b97eee

Please sign in to comment.