Пример #1
0
    def test_get_today(self):
        mware = SuspiciousCrashSignatures(config=self.config)
        stats = mware.get()

        self.assertEquals(1, len(stats['hits']))
        now = datetimeutil.utc_now().strftime('%Y-%m-%d')
        self.assertEquals(now, stats['hits'][0]['date'])
        self.assertEquals(1, len(stats['hits'][0]['signatures']))
        self.assertEquals('testsignature1', stats['hits'][0]['signatures'][0])
Пример #2
0
    def test_get_today(self):
        mware = SuspiciousCrashSignatures(config=self.config)
        stats = mware.get()

        eq_(1, len(stats['hits']))
        now = datetimeutil.utc_now().strftime('%Y-%m-%d')
        eq_(now, stats['hits'][0]['date'])
        eq_(1, len(stats['hits'][0]['signatures']))
        eq_('testsignature1', stats['hits'][0]['signatures'][0])
Пример #3
0
    def test_get_with_start_end(self):
        mware = SuspiciousCrashSignatures(config=self.config)

        start = datetimeutil.utc_now() - datetime.timedelta(16)
        end = start + datetime.timedelta(5)

        start = start.strftime('%Y-%m-%d')
        end = end.strftime('%Y-%m-%d')

        stats = mware.get(start_date=start, end_date=end)
        fifteen = datetimeutil.utc_now() - datetime.timedelta(15)
        fifteen = fifteen.strftime('%Y-%m-%d')
        self.assertEquals(1, len(stats['hits']))
        self.assertEquals(fifteen, stats['hits'][0]['date'])
        self.assertEquals(1, len(stats['hits'][0]['signatures']))
        self.assertEquals('testsignature2', stats['hits'][0]['signatures'][0])
Пример #4
0
    def test_get_with_start_end(self):
        mware = SuspiciousCrashSignatures(config=self.config)

        start = datetimeutil.utc_now() - datetime.timedelta(16)
        end = start + datetime.timedelta(5)

        start = start.strftime('%Y-%m-%d')
        end = end.strftime('%Y-%m-%d')

        stats = mware.get(start_date=start, end_date=end)
        fifteen = datetimeutil.utc_now() - datetime.timedelta(15)
        fifteen = fifteen.strftime('%Y-%m-%d')
        eq_(1, len(stats['hits']))
        eq_(fifteen, stats['hits'][0]['date'])
        eq_(1, len(stats['hits'][0]['signatures']))
        eq_('testsignature2', stats['hits'][0]['signatures'][0])
Пример #5
0
    def test_get_with_start(self):
        mware = SuspiciousCrashSignatures(config=self.config)

        sometimeago = datetimeutil.utc_now() - datetime.timedelta(16)
        sometimeago = sometimeago.strftime('%Y-%m-%d')

        now = datetimeutil.utc_now()
        fifteen = now - datetime.timedelta(15)
        now = now.strftime('%Y-%m-%d')
        fifteen = fifteen.strftime('%Y-%m-%d')
        stats = mware.get(start_date=sometimeago)
        self.assertEquals(2, len(stats['hits']))

        stats['hits'].sort(key=lambda x: x['date'])
        self.assertEquals(fifteen, stats['hits'][0]['date'])
        self.assertEquals(now, stats['hits'][1]['date'])

        self.assertEquals(1, len(stats['hits'][0]['signatures']))
        self.assertEquals(1, len(stats['hits'][1]['signatures']))
        self.assertEquals('testsignature2', stats['hits'][0]['signatures'][0])
        self.assertEquals('testsignature1', stats['hits'][1]['signatures'][0])
Пример #6
0
    def test_get_with_start(self):
        mware = SuspiciousCrashSignatures(config=self.config)

        sometimeago = datetimeutil.utc_now() - datetime.timedelta(16)
        sometimeago = sometimeago.strftime('%Y-%m-%d')

        now = datetimeutil.utc_now()
        fifteen = now - datetime.timedelta(15)
        now = now.strftime('%Y-%m-%d')
        fifteen = fifteen.strftime('%Y-%m-%d')
        stats = mware.get(start_date=sometimeago)
        eq_(2, len(stats['hits']))

        stats['hits'].sort(key=lambda x: x['date'])
        eq_(fifteen, stats['hits'][0]['date'])
        eq_(now, stats['hits'][1]['date'])

        eq_(1, len(stats['hits'][0]['signatures']))
        eq_(1, len(stats['hits'][1]['signatures']))
        eq_('testsignature2', stats['hits'][0]['signatures'][0])
        eq_('testsignature1', stats['hits'][1]['signatures'][0])