Transformation Test

Alooma takes an event (a dictionary) and performs transformations on it. This class helps to test single events to inspect the transformation or run multiple samples through the tests for integration testing.

TransformationTest.__init__(api=None, code_package=None, preview_full_events=True, preview_difference_dicts=True, local_or_api='local', pprint_indent=2, pprint_width=250, pprint_depth=5)

Tests the Alooma events

Parameters:
  • api – api authentication using the Alooma package
  • preview – True to print the transformations for visual inspection
  • code_package – Your specific transformation code to use as a package. This is needed for local testing
  • local_or_api – ‘local’ to test on local code or ‘api’ to test on code deployed to Alooma
  • pprint_indent – The indent value to pprint dictionaries
  • pprint_width – The width value to pprint dictionaries

Test Single Event

TransformationTest.test_single_event(sample)

Tests a single event using the local code and pretty prints the before and after dictionaries to the console

Parameters:sample – A single sample event dictionary
Returns:The output dictionary

Loop Through Events to Test

TransformationTest.loop_through_events_to_test(sample_event_list)

Loops through the event files to test each sample

Parameters:sample_event_list – A list of dictionaries to test. The expected format from Alooma is a dictionary as formatted below
Returns:None

Alooma samples are in a list of dictionaries with the sample inside of a key of sample:

[{'sample': {}
{'sample': {}
{'sample': {}]

Test All Events

TransformationTest.test_all_events(sample_event_directory, file_name, file_prefix='input')

Tests all events from a specified file or all the saved input sample.

Parameters:
  • sample_event_directory – The name of the directory where sample files are saved.
  • file_name – The name of a specific file to test. A file should be a list with dictionaries.
  • file_prefix – Specific a file prefix to test all the events in files with a similar name. The defaul will test all the samples for all inputs that have been saved using the Samples.save_alooma_samples_to_files function.
Returns:

True if the samples should be printed to the console