def __init__(self, name, latitude, longitude, radius, include, exclude, days): """Initialize the Spot Crime sensor.""" import spotcrime self._name = name self._include = include self._exclude = exclude self.days = days self._spotcrime = spotcrime.SpotCrime((latitude, longitude), radius, None, None, self.days) self._attributes = None self._state = None self._previous_incidents = set() self._attributes = {ATTR_ATTRIBUTION: spotcrime.ATTRIBUTION}
def get_crimes(rental, radius): crimes = spotcrime.SpotCrime((float(rental['lat']), float(rental['long'])), radius / 100, None, ['Other'], days=365) return crimes.get_incidents()
def test_get_incidents(self): sc = spotcrime.SpotCrime(NEWARK, 0.01, None, None, 10) incidents = sc.get_incidents() self.assertIsInstance(incidents, list)
def test_get_map_url(self): sc = spotcrime.SpotCrime(NEWARK, 0.01, None, None, 10) self.assertTrue(sc.get_map_url().startswith('https://spotcrime.com'))