def test_the_iterator_can_be_consumed(): factory = ShellFactory(CONF_OFFLINE) iterator = gen_profiles(10) shelled = factory.shell_iterator(iterator, destination='some-destination') iterator_bis = gen_profiles(10) assert list(shelled) == list(iterator_bis)
def test_shell_around_generators(mock_starfish): # Arrange config = Config(mock_starfish.url, 'test_3', 'run_1') starfish = ShellFactory(config) iterable = gen_profiles(10) # Act: Shell Processes shelled_input = starfish.shell_iterator(iterable, source='my-shelled-source') processed = first_3(shelled_input) shelled_result = starfish.shell_iterator( processed, destination='my-shelled-destination') list(shelled_result) # Consume the result iterator # Assert assert shelled_input.starfish.consumed == 10 assert shelled_result.starfish.consumed == 3
def test_some_failure_should_never_block_the_processing(): # Arrange config = Config('http://wrong_url', 'test_3', 'run_1') starfish = ShellFactory(config) iterable = gen_profiles(10) # Act: Shell Processes shelled_input = starfish.shell_iterator(iterable, source='my-shelled-source') processed = first_3(shelled_input) shelled_result = starfish.shell_iterator( processed, destination='my-shelled-destination') result = list(shelled_result) # Consume the result iterator # Assert assert len(result) == 3 assert shelled_input.starfish.failed assert shelled_result.starfish.failed
def test_shell_around_a_simple_functions(mock_starfish): with env(STARFISH_API_URL=mock_starfish.url, STARFISH_SERVICE_ID='test_1', STARFISH_RUN_ID='run_1'): starfish = ShellFactory.from_env() shelled = starfish.shell_process( noop_processing, source='some-source-identifier', destination='some-destination-identifier') # that would be the moment where you store profiles somewhere else. list(shelled(gen_profiles(10))) # The content has been consumed assert shelled.starfish.consumed == 20 # The server has been requested logs = mock_starfish.logs assert len(logs) == 20 assert 'some-source-identifier' in logs.sources assert 'some-destination-identifier' in logs.destinations for log in logs: assert check_server_log(log)
def test_the_iterator_has_starfish_infos(): factory = ShellFactory(CONF_OFFLINE) iterator = gen_profiles(10) shelled = factory.shell_iterator(iterator, source='source') assert shelled.starfish
def test_i_can_wrap_iterators(): factory = ShellFactory(CONF_OFFLINE) iterator = gen_profiles(10) shelled = factory.shell_iterator(iterator, source='some-source') assert shelled