def test_construct(): try: EventSource(config=None, tool=None) except TypeError: return raise TypeError("EventSource should raise a TypeError when " "instantiated due to its abstract methods")
def test_allowed_tels_from_config(): dataset = get_dataset_path("gamma_test_large.simtel.gz") config = Config({'EventSource': { 'input_url': dataset, 'allowed_tels': {1, 3} }}) reader = EventSource.from_config(config=config, parent=None) assert len(reader.allowed_tels) == 2
def test_factory_allowed_tels_from_config(): dataset = get_dataset_path("gamma_test_large.simtel.gz") config = Config({'EventSource': { 'input_url': dataset, 'allowed_tels': {1, 3} }}) reader = EventSource.from_config(config=config, parent=None) assert len(reader.allowed_tels) == 2
def test_from_config_default(): old_default = EventSource.input_url.default_value dataset = get_dataset_path("gamma_test_large.simtel.gz") EventSource.input_url.default_value = dataset config = Config() reader = EventSource.from_config(config=config, parent=None) assert isinstance(reader, SimTelEventSource) assert reader.input_url == dataset EventSource.input_url.default_value = old_default
def test_max_events_from_config(): dataset = get_dataset_path("gamma_test_large.simtel.gz") max_events = 10 config = Config({'EventSource': { 'input_url': dataset, 'max_events': max_events, }}) reader = EventSource.from_config(config=config) assert reader.max_events == max_events
def test_factory_max_events_from_config(): dataset = get_dataset_path("gamma_test_large.simtel.gz") max_events = 10 config = Config({'EventSource': { 'input_url': dataset, 'max_events': max_events, }}) reader = EventSource.from_config(config=config) assert reader.max_events == max_events
def test_max_events_from_config(): dataset = get_dataset_path("gamma_test_large.simtel.gz") max_events = 10 config = Config( {"EventSource": { "input_url": dataset, "max_events": max_events }}) reader = EventSource.from_config(config=config) assert reader.max_events == max_events
def test_from_config_invalid_type(): dataset = get_dataset_path("gamma_test_large.simtel.gz") EventSource.input_url.default_value = dataset config = Config({'EventSource': {'input_url': 124}}) with pytest.raises(TraitError): EventSource.from_config(config=config, parent=None)
def test_from_config(): dataset = get_dataset_path("gamma_test_large.simtel.gz") config = Config({'EventSource': {'input_url': dataset}}) reader = EventSource.from_config(config=config, parent=None) assert isinstance(reader, SimTelEventSource) assert reader.input_url == dataset
def test_construct(): with pytest.raises(TypeError): EventSource()