diff --git a/swh/scheduler/tests/updater/test_events.py b/swh/scheduler/tests/updater/test_events.py index 3d497a9..b50349a 100644 --- a/swh/scheduler/tests/updater/test_events.py +++ b/swh/scheduler/tests/updater/test_events.py @@ -1,50 +1,53 @@ # Copyright (C) 2018 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information import unittest from arrow import utcnow from hypothesis import given -from hypothesis.strategies import one_of, text, just, sampled_from +from hypothesis.strategies import text, sampled_from from nose.tools import istest from swh.scheduler.updater.events import SWHEvent, LISTENED_EVENTS from swh.scheduler.updater.ghtorrent import events def event_values_ko(): return set(events['evt']).union( set(events['ent'])).difference( set(LISTENED_EVENTS)) +WRONG_EVENTS = sorted(list(event_values_ko())) + + class EventTest(unittest.TestCase): def _make_event(self, event_name): return { 'type': event_name, 'url': 'something', 'last_seen': utcnow(), } @istest @given(sampled_from(LISTENED_EVENTS)) def check_ok(self, event_name): evt = self._make_event(event_name) self.assertTrue(SWHEvent(evt).check()) @istest @given(text()) def check_with_noisy_event_should_be_ko(self, event_name): if event_name in LISTENED_EVENTS: # just in generation generates a real and correct name, skip it return evt = self._make_event(event_name) self.assertFalse(SWHEvent(evt).check()) @istest - @given(one_of(map(just, event_values_ko()))) + @given(sampled_from(WRONG_EVENTS)) def check_ko(self, event_name): evt = self._make_event(event_name) self.assertFalse(SWHEvent(evt).check())