tests.eventstreams_tests module#

Tests for the eventstreams module.

class tests.eventstreams_tests.EventStreamsTestClass(**kwargs)[source]#

Bases: EventStreams

Test class of EventStreams.

Keyword Arguments:
  • canary (bool) – if True, include canary events, see https://w.wiki/7$2z for more info

  • site (APISite) – a project site object. Used if no url is given

  • since (Timestamp or str) – a timestamp for older events; there will likely be between 7 and 31 days of history available but is not guaranteed. It may be given as a pywikibot.Timestamp, an ISO 8601 string or a mediawiki timestamp string.

  • streams (Iterable[str] or str) – event stream types. Mandatory when no url is given. Multiple streams may be given as a string with comma separated stream types or an iterable of strings

  • timeout (int or float or tuple[int or float, int or float]) – a timeout value indication how long to wait to send data before giving up

  • url (str) – an url retrieving events from. Will be set up to a default url using _site.family settings, stream types and timestamp

Parameters:

kwargs – keyword arguments passed to SSEClient and requests library

Raises:
  • ImportError – sseclient is not installed

  • NotImplementedError – no stream types specified

See also

https://stream.wikimedia.org/?doc#streams for available Wikimedia stream types to be passed with streams parameter.

class tests.eventstreams_tests.TestEventSource(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Test sseclient.EventSource.

abstract_class = False#
net = True#
test_stream()[source]#

Verify that the EventSource delivers events without problems.

As found in sseclient 0.0.24 the EventSource gives randomly a ValueError ‘Unterminated string’ when json.load is processed if the limit is high enough.

class tests.eventstreams_tests.TestEventStreamsFilter(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Filter tests for eventstreams module.

abstract_class = False#
data = {'bar': 'baz', 'foo': True}#
dry = True#
setUp()[source]#

Set up unit test.

test_filter_false()[source]#

Test EventStreams filter with assignment of True.

test_filter_function_all()[source]#

Test EventStreams filter all function.

test_filter_function_any()[source]#

Test EventStreams filter any function.

test_filter_function_none()[source]#

Test EventStreams filter none function.

test_filter_mixed_function()[source]#

Test EventStreams filter mixed function.

test_filter_multiple()[source]#

Test EventStreams filter with multiple arguments.

test_filter_sequence_false()[source]#

Test EventStreams filter with assignment of a sequence.

test_filter_sequence_true()[source]#

Test EventStreams filter with assignment of a sequence.

test_filter_true()[source]#

Test EventStreams filter with assignment of False.

test_filter_value()[source]#

Test EventStreams filter with assignment of an int value.

class tests.eventstreams_tests.TestEventStreamsSettingTests(*args, **kwargs)[source]#

Bases: DisableSiteMixin, TestCase

Setting tests for eventstreams module.

abstract_class = False#
dry = True#
setUp()[source]#

Set up unit test.

test_filter_function_settings()[source]#

Test EventStreams filter function settings.

test_filter_function_settings_fail()[source]#

Test EventStreams failing filter function settings.

test_filter_settings()[source]#

Test EventStreams filter settings.

test_maximum_items()[source]#

Test EventStreams total value.

test_timeout_setting()[source]#

Test EventStreams timeout value.

class tests.eventstreams_tests.TestEventStreamsStreamsTests(*args, **kwargs)[source]#

Bases: CheckHostnameMixin, DefaultSiteTestCase

Stream tests for eventstreams module.

abstract_class = False#
code = 'test'#
family = 'wikipedia'#
net = True#
setUp()[source]#

Setup tests.

site = True#
sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
test_multiple_streams()[source]#

Test EventStreams with multiple streams.

test_url_missing_streams()[source]#

Test EventStreams with url from site with missing streams.

test_url_with_streams()[source]#

Test EventStreams with url from default site.

class tests.eventstreams_tests.TestEventStreamsUrlTests(*args, **kwargs)[source]#

Bases: CheckHostnameMixin, TestCase

Url tests for eventstreams module.

abstract_class = False#
net = True#
site = True#
sites = {'de-wp': {'code': 'de', 'family': 'wikipedia', 'hostname': 'de.wikipedia.org'}, 'en-wq': {'code': 'en', 'family': 'wikiquote', 'hostname': 'en.wikiquote.org'}}#
test_url_from_site_de_wp()#

Test EventStreams with url from site on wikipedia:de

test_url_from_site_en_wq()#

Test EventStreams with url from site on wikiquote:en

test_url_parameter_de_wp()#

Test EventStreams with given url on wikipedia:de

test_url_parameter_en_wq()#

Test EventStreams with given url on wikiquote:en