def test_no_functions_throw_exceptions(self): try: dshield.backscatter() dshield.handler() dshield.infocon() dshield.ip('8.8.8.8') dshield.port(80) dshield.portdate(80) dshield.topports() dshield.topips() dshield.sources() dshield.porthistory(80) dshield.asnum(1) dshield.dailysummary() dshield.daily404summary(datetime.date(2011, 12, 1)) dshield.daily404detail(datetime.date(2011, 12, 1)) dshield.glossary() dshield.webhoneypotsummary(datetime.date(2011, 12, 1)) dshield.webhoneypotbytype(datetime.date(2011, 12, 1)) except requests.RequestException: # don't care about network errors pass except Exception: # anything else is a fail self.assertTrue(False)
def test_daily404summary(self): responses.add(responses.GET, 'https://dshield.org/api/daily404summary/2012-02-23?json', body='{"daily404summary":"test"}', match_querystring=True, content_type='text/json') data = {'daily404summary': 'test'} self.assertEquals(dshield.daily404summary('2012-02-23'), data) self.assertEquals(dshield.daily404summary(datetime.date(2012, 2, 23)), data) self.assertEquals(dshield.daily404summary('2012-02-23', return_format=dshield.JSON), '{"daily404summary":"test"}')
def test_daily404summary(self): responses.add( responses.GET, 'https://dshield.org/api/daily404summary/2012-02-23?json', body='{"daily404summary":"test"}', match_querystring=True, content_type='text/json') data = {'daily404summary': 'test'} self.assertEquals(dshield.daily404summary('2012-02-23'), data) self.assertEquals(dshield.daily404summary(datetime.date(2012, 2, 23)), data) self.assertEquals( dshield.daily404summary('2012-02-23', return_format=dshield.JSON), '{"daily404summary":"test"}')