Skip to content

Commit 91c09ff

Browse files
authored
Merge pull request #607 from HackerShark/fix/location-object-0-bug
Fix for issue #572
2 parents 68ba448 + d7b14cb commit 91c09ff

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

stix2/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ def _check_properties_dependency(self, list_of_properties, list_of_dependent_pro
103103
failed_dependency_pairs = []
104104
for p in list_of_properties:
105105
for dp in list_of_dependent_properties:
106-
if not self.get(p) and self.get(dp):
106+
if p not in self and dp in self:
107+
failed_dependency_pairs.append((p, dp))
108+
elif p in self and (self[p] is None or self[p] is False) and dp in self and self[dp] is not None:
107109
failed_dependency_pairs.append((p, dp))
108110
if failed_dependency_pairs:
109111
raise DependentPropertiesError(self.__class__, failed_dependency_pairs)

stix2/test/v21/test_location.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,48 @@ def test_bing_map_url_multiple_props_and_long_lat_provided():
377377

378378
loc_url = loc.to_maps_url("Bing Maps")
379379
assert loc_url == expected_url
380+
381+
382+
def test_bing_map_url_for_0_long_lat():
383+
expected_url = "https://bing.com/maps/default.aspx?where1=0.0%2C0.0&lvl=16"
384+
385+
loc = stix2.v21.Location(
386+
region="Gulf of Guinea",
387+
country="International waters",
388+
street_address="0°N, 0°E – Null Island",
389+
latitude=0.0,
390+
longitude=0.0,
391+
)
392+
393+
loc_url = loc.to_maps_url("Bing Maps")
394+
assert loc_url == expected_url
395+
396+
397+
def test_bing_map_url_for_0_long():
398+
expected_url = "https://bing.com/maps/default.aspx?where1=0.0%2C39.668&lvl=16"
399+
400+
loc = stix2.v21.Location(
401+
region="Eastern Africa",
402+
country="Kenya",
403+
street_address="0°N, 39.668°E",
404+
latitude=0.0,
405+
longitude=39.668,
406+
)
407+
408+
loc_url = loc.to_maps_url("Bing Maps")
409+
assert loc_url == expected_url
410+
411+
412+
def test_bing_map_url_for_0_lat():
413+
expected_url = "https://bing.com/maps/default.aspx?where1=51.477%2C0.0&lvl=16"
414+
415+
loc = stix2.v21.Location(
416+
region="Western Europe",
417+
country="United Kingdom",
418+
street_address="Royal Observatory, Blackheath Ave, Greenwich, London SE10 8XJ, United Kingdom",
419+
latitude=51.477,
420+
longitude=0.0,
421+
)
422+
423+
loc_url = loc.to_maps_url("Bing Maps")
424+
assert loc_url == expected_url

0 commit comments

Comments
 (0)