Skip to content

Commit

Permalink
fix(location): Fixing Location.duplicate() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Mackey committed Mar 11, 2019
1 parent 4c30ec2 commit f80a295
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ladybug/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ def meridian(self):

def duplicate(self):
"""Duplicate location."""
return self(self.city, self.country, self.latitude, self.longitude,
self.time_zone, self.elevation, self.station_id, self.source)
return Location(self.city, self.state, self.country,
self.latitude, self.longitude, self.time_zone, self.elevation,
self.station_id, self.source)

@property
def ep_style_location_string(self):
Expand Down
21 changes: 21 additions & 0 deletions tests/location_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,27 @@ def test_json_methods(self):
assert loc_from_json.elevation == elevation
assert loc_from_json.country == country

def test_duplicate(self):
"""Test the duplicate method."""
city = 'Tehran'
country = 'Iran'
latitude = 36
longitude = 34
time_zone = 3.5
elevation = 54

loc = Location(city=city, country=country, latitude=latitude,
longitude=longitude, time_zone=time_zone,
elevation=elevation)
loc_dup = loc.duplicate()

assert loc.city == loc_dup.city == city
assert loc.country == loc_dup.country == country
assert loc.latitude == loc_dup.latitude == latitude
assert loc.longitude == loc_dup.longitude == longitude
assert loc.time_zone == loc_dup.time_zone == time_zone
assert loc.elevation == loc_dup.elevation == elevation


if __name__ == "__main__":
unittest.main()

0 comments on commit f80a295

Please sign in to comment.