def test_scenario5(self): """ Scenario: Successfully creating a batch anomaly score from an anomaly detector: Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs And I create an anomaly detector And I wait until the anomaly detector is ready less than <time_3> secs When I create a batch anomaly score And I check the batch anomaly score is ok And I wait until the batch anomaly score is ready less than <time_4> secs And I download the created anomaly score file to "<local_file>" Then the batch anomaly score file is like "<predictions_file>" Examples: | data | time_1 | time_2 | time_3 | time_4 | local_file | predictions_file | | ../data/tiny_kdd.csv | 30 | 30 | 50 | 50 | ./tmp/batch_predictions.csv |./data/batch_predictions_a.csv | """ print self.test_scenario5.__doc__ examples = [ ['data/tiny_kdd.csv', '30', '30', '50', '50', 'tmp/batch_predictions.csv', 'data/batch_predictions_a.csv']] for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than(self, example[2]) anomaly_create.i_create_an_anomaly(self) anomaly_create.the_anomaly_is_finished_in_less_than(self, example[3]) batch_pred_create.i_create_a_batch_prediction_with_anomaly(self) batch_pred_create.the_batch_anomaly_score_is_finished_in_less_than(self, example[4]) batch_pred_create.i_download_anomaly_score_file(self, example[5]) batch_pred_create.i_check_predictions(self, example[6])
def test_scenario6(self): """ Scenario: Successfully creating an anomaly score: Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs And I create an anomaly detector from a dataset And I wait until the anomaly detector is ready less than <time_3> secs When I create an anomaly score for "<data_input>" Then the anomaly score is "<score>" Examples: | data | time_1 | time_2 | time_3 | data_input | score | | ../data/tiny_kdd.csv | 10 | 10 | 100 | {"src_bytes": 350} | 0.92618 | | ../data/iris_sp_chars.csv | 10 | 10 | 100 | {"pétal&width\u0000": 300} | 0.90198 | """ print self.test_scenario6.__doc__ examples = [ ['data/tiny_kdd.csv', '10', '10', '100', '{"src_bytes": 350}', '0.92846'], ['data/iris_sp_chars.csv', '10', '10', '100', '{"pétal&width\u0000": 300}', '0.89313']] for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than(self, example[2]) anomaly_create.i_create_an_anomaly(self) anomaly_create.the_anomaly_is_finished_in_less_than(self, example[3]) prediction_create.i_create_an_anomaly_score(self, example[4]) prediction_create.the_anomaly_score_is(self, example[5])
def test_scenario6(self): """ Scenario 6: Successfully creating a local anomaly from an exported file: Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs And I create an anomaly And I wait until the anomaly is ready less than <time_3> secs And I export the anomaly to "<exported_file>" When I create a local anomaly from the file "<exported_file>" Then the anomaly ID and the local anomaly ID match Examples: | data | time_1 | time_2 | time_3 | exported_file | ../data/iris.csv | 10 | 10 | 50 | ./tmp/anomaly.json """ print self.test_scenario6.__doc__ examples = [ ['data/iris.csv', '10', '10', '500', './tmp/anomaly.json']] for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than(self, example[2]) anomaly_create.i_create_an_anomaly(self) anomaly_create.the_anomaly_is_finished_in_less_than(self, example[3]) anomaly_create.i_export_anomaly(self, example[4]) anomaly_create.i_create_local_anomaly_from_file(self, example[4]) anomaly_create.check_anomaly_id_local_id(self)
def test_scenario2(self): """ Scenario: Successfully creating an anomaly detector from a dataset and generating the anomalous dataset: Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs Then I create an anomaly detector of <rows> anomalies from a dataset And I wait until the anomaly detector is ready less than <time_4> secs And I create a dataset with only the anomalies And I wait until the dataset is ready less than <time_3> secs And I check that the dataset has <rows> rows Examples: | data | time_1 | time_2 | time_3 |time_4| rows| | ../data/iris_anomalous.csv | 40 | 40 | 80 | 40 | 1 """ print self.test_scenario2.__doc__ examples = [['data/iris_anomalous.csv', '40', '40', '80', '40', '1']] for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than( self, example[2]) anomaly_create.i_create_an_anomaly_with_top_n_from_dataset( self, example[5]) anomaly_create.the_anomaly_is_finished_in_less_than( self, example[3]) anomaly_create.create_dataset_with_anomalies(self) dataset_create.the_dataset_is_finished_in_less_than( self, example[4]) anomaly_create.the_dataset_has_n_rows(self, example[5])
def test_scenario6(self): """ Scenario: Successfully creating an anomaly score: Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs And I create an anomaly detector from a dataset And I wait until the anomaly detector is ready less than <time_3> secs When I create an anomaly score for "<data_input>" Then the anomaly score is "<score>" Examples: | data | time_1 | time_2 | time_3 | data_input | score | | ../data/tiny_kdd.csv | 10 | 10 | 100 | {"src_bytes": 350} | 0.92618 | | ../data/iris_sp_chars.csv | 10 | 10 | 100 | {"pétal&width\u0000": 300} | 0.90198 | """ print self.test_scenario5.__doc__ examples = [ ['data/tiny_kdd.csv', '10', '10', '100', '{"src_bytes": 350}', '0.92618', 'data/iris_sp_chars.csv', '10', '10', '100', '{"pétal&width\u0000": 300}', '0.90198'], ['data/iris_sp_chars.csv', '10', '10', '100', '{"pétal&width\u0000": 300}', '0.90198']] for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than(self, example[2]) anomaly_create.i_create_an_anomaly(self) anomaly_create.the_anomaly_is_finished_in_less_than(self, example[3]) prediction_create.i_create_an_anomaly_score(self, example[4]) prediction_create.the_anomaly_score_is(self, example[5])
def test_scenario3(self): """ Scenario: Successfully comparing scores from anomaly detectors: Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs And I create an anomaly detector And I wait until the anomaly detector is ready less than <time_3> secs And I create a local anomaly detector When I create an anomaly score for "<data_input>" Then the anomaly score is "<score>" And I create a local anomaly score for "<data_input>" Then the local anomaly score is "<score>" Examples: | data | time_1 | time_2 | time_3 | data_input | score | """ examples = [ ['data/tiny_kdd.csv', '20', '20', '30', '{"000020": 255.0, "000004": 183.0, "000016": 4.0, "000024": 0.04, "000025": 0.01, "000026": 0.0, "000019": 0.25, "000017": 4.0, "000018": 0.25, "00001e": 0.0, "000005": 8654.0, "000009": "0", "000023": 0.01, "00001f": 123.0}', '0.69802']] show_doc(self.test_scenario3, examples) for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than(self, example[2]) anomaly_create.i_create_an_anomaly(self) anomaly_create.the_anomaly_is_finished_in_less_than(self, example[3]) prediction_compare.i_create_a_local_anomaly(self) prediction_create.i_create_an_anomaly_score(self, example[4]) prediction_create.the_anomaly_score_is(self, example[5]) prediction_compare.i_create_a_local_anomaly_score(self, example[4]) prediction_compare.the_local_anomaly_score_is(self, example[5])
def test_scenario3(self): """ Scenario: Successfully comparing scores from anomaly detectors: Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs And I create an anomaly detector And I wait until the anomaly detector is ready less than <time_3> secs And I create a local anomaly detector When I create an anomaly score for "<data_input>" Then the anomaly score is "<score>" And I create a local anomaly score for "<data_input>" Then the local anomaly score is "<score>" Examples: | data | time_1 | time_2 | time_3 | data_input | score | """ examples = [ ['data/tiny_kdd.csv', '30', '30', '30', '{"000020": 255.0, "000004": 183.0, "000016": 4.0, "000024": 0.04, "000025": 0.01, "000026": 0.0, "000019": 0.25, "000017": 4.0, "000018": 0.25, "00001e": 0.0, "000005": 8654.0, "000009": "0", "000023": 0.01, "00001f": 123.0}', '0.69802']] show_doc(self.test_scenario3, examples) for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than(self, example[2]) anomaly_create.i_create_an_anomaly(self) anomaly_create.the_anomaly_is_finished_in_less_than(self, example[3]) prediction_compare.i_create_a_local_anomaly(self) prediction_create.i_create_an_anomaly_score(self, example[4]) prediction_create.the_anomaly_score_is(self, example[5]) prediction_compare.i_create_a_local_anomaly_score(self, example[4]) prediction_compare.the_local_anomaly_score_is(self, example[5])
def test_scenario1c(self): """ Scenario: Successfully comparing remote and local predictions with raw date input for anomaly detectors Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs And I create an anomaly detector And I wait until the anomaly detector is ready less than <time_3> secs And I create a local anomaly detector When I create an anomaly score for "<data_input>" Then the anomaly score is "<score>" And I create a local anomaly score for "<data_input>" Then the local anomaly score is "<score>" Examples: |data|time_1|time_2|time_3|data_input|score| """ examples = [ [ 'data/dates2.csv', '20', '30', '60', '{"time-1":"2001-01-05T23:04:04.693","cat-0":"cat2","target-2":0.01}', 0.54911 ], [ 'data/dates2.csv', '20', '30', '60', '{"time-1":"2011-04-01T00:16:45.747","cat-0":"cat2","target-2":0.32}', 0.52477 ], [ 'data/dates2.csv', '20', '30', '60', '{"time-1":"1969-W29-1T17:36:39Z","cat-0":"cat1","target-2":0.87}', 0.93678 ], [ 'data/dates2.csv', '20', '30', '60', '{"time-1":"Mon Jul 14 17:36 +0000 1969","cat-0":"cat1","target-2":0}', 0.93717 ] ] show_doc(self.test_scenario1c, examples) for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than( self, example[2]) anomaly_create.i_create_an_anomaly(self) anomaly_create.the_anomaly_is_finished_in_less_than( self, example[3]) prediction_compare.i_create_a_local_anomaly(self) prediction_create.i_create_an_anomaly_score(self, example[4]) prediction_create.the_anomaly_score_is(self, example[5]) prediction_compare.i_create_a_local_anomaly_score(self, example[4]) prediction_compare.the_local_anomaly_score_is(self, example[5])
def test_scenario1b(self): """ Scenario: Successfully comparing remote and local predictions with raw date input for anomaly detectors Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs And I create an anomaly detector And I wait until the anomaly detector is ready less than <time_3> secs And I create a local anomaly detector When I create an anomaly score for "<data_input>" Then the anomaly score is "<score>" And I create a local anomaly score for "<data_input>" Then the local anomaly score is "<score>" Examples: |data|time_1|time_2|time_3|data_input|score| """ examples = [ [ 'data/dates2.csv', '20', '30', '60', '{"time-1":"1932-01-30T19:24:11.440","cat-0":"cat2","target-2":0.1}', 0.54343 ], [ 'data/dates2.csv', '20', '30', '60', '{"time-1":"1950-11-06T05:34:05.602","cat-0":"cat1" ,"target-2":0.9}', 0.5202 ], [ 'data/dates2.csv', '20', '30', '60', '{"time-1":"1969-7-14 17:36","cat-0":"cat2","target-2":0.9}', 0.93639 ] ] show_doc(self.test_scenario1b, examples) for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than( self, example[2]) anomaly_create.i_create_an_anomaly(self) anomaly_create.the_anomaly_is_finished_in_less_than( self, example[3]) prediction_compare.i_create_a_local_anomaly(self) prediction_create.i_create_an_anomaly_score(self, example[4]) prediction_create.the_anomaly_score_is(self, example[5]) prediction_compare.i_create_a_local_anomaly_score(self, example[4]) prediction_compare.the_local_anomaly_score_is(self, example[5])
def test_scenario1(self): """ Scenario: Successfully comparing remote and local predictions with raw date input for anomaly detectors Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs And I create an anomaly detector And I wait until the anomaly detector is ready less than <time_3> secs And I create a local anomaly detector When I create an anomaly score for "<data_input>" Then the anomaly score is "<score>" And I create a local anomaly score for "<data_input>" Then the local anomaly score is "<score>" Examples: |data|time_1|time_2|time_3|data_input|score| """ examples = [ [ 'data/dates2.csv', '20', '30', '60', '{"time-1":"1910-05-08T19:10:23.106","cat-0":"cat2","target-2":0.4}', 0.52477 ], [ 'data/dates2.csv', '20', '30', '60', '{"time-1":"1920-06-30T20:21:20.320","cat-0":"cat1","target-2":0.2}', 0.50654 ] ] show_doc(self.test_scenario1, examples) for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than( self, example[2]) anomaly_create.i_create_an_anomaly(self) anomaly_create.the_anomaly_is_finished_in_less_than( self, example[3]) prediction_compare.i_create_a_local_anomaly(self) prediction_create.i_create_an_anomaly_score(self, example[4]) prediction_create.the_anomaly_score_is(self, example[5]) prediction_compare.i_create_a_local_anomaly_score(self, example[4]) prediction_compare.the_local_anomaly_score_is(self, example[5])
def test_scenario1(self): """ Scenario: Successfully creating an anomaly detector from a dataset and a dataset list: Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs Then I create an anomaly detector from a dataset And I wait until the anomaly detector is ready less than <time_4> secs And I check the anomaly detector stems from the original dataset And I store the dataset id in a list And I create a dataset And I wait until the dataset is ready less than <time_3> secs And I store the dataset id in a list Then I create an anomaly detector from a dataset list And I wait until the anomaly detector is ready less than <time_4> secs And I check the anomaly detector stems from the original dataset list Examples: | data | time_1 | time_2 | time_3 | time_4 | | ../data/tiny_kdd.csv | 40 | 40 | 80 | 100 """ print self.test_scenario1.__doc__ examples = [ ['data/tiny_kdd.csv', '40', '40', '40', '100']] for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than(self, example[2]) anomaly_create.i_create_an_anomaly_from_dataset(self) anomaly_create.the_anomaly_is_finished_in_less_than(self, example[4]) anomaly_create.i_check_anomaly_dataset_and_datasets_ids(self) mm_create.i_store_dataset_id(self) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than(self, example[3]) mm_create.i_store_dataset_id(self) anomaly_create.i_create_an_anomaly_from_dataset_list(self) anomaly_create.the_anomaly_is_finished_in_less_than(self, example[4]) anomaly_create.i_check_anomaly_datasets_and_datasets_ids(self)
def test_scenario1(self): """ Scenario: Successfully creating an anomaly detector from a dataset and a dataset list: Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs Then I create an anomaly detector from a dataset And I wait until the anomaly detector is ready less than <time_4> secs And I check the anomaly detector stems from the original dataset And I store the dataset id in a list And I create a dataset And I wait until the dataset is ready less than <time_3> secs And I store the dataset id in a list Then I create an anomaly detector from a dataset list And I wait until the anomaly detector is ready less than <time_4> secs And I check the anomaly detector stems from the original dataset list Examples: | data | time_1 | time_2 | time_3 | time_4 | | ../data/tiny_kdd.csv | 40 | 40 | 40 | 100 """ print self.test_scenario1.__doc__ examples = [ ['data/tiny_kdd.csv', '40', '40', '40', '100']] for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than(self, example[2]) anomaly_create.i_create_an_anomaly_from_dataset(self) anomaly_create.the_anomaly_is_finished_in_less_than(self, example[4]) anomaly_create.i_check_anomaly_dataset_and_datasets_ids(self) mm_create.i_store_dataset_id(self) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than(self, example[3]) mm_create.i_store_dataset_id(self) anomaly_create.i_create_an_anomaly_from_dataset_list(self) anomaly_create.the_anomaly_is_finished_in_less_than(self, example[4]) anomaly_create.i_check_anomaly_datasets_and_datasets_ids(self)
def test_scenario2(self): """ Scenario: Successfully creating an anomaly detector from a dataset and generating the anomalous dataset: Given I create a data source uploading a "<data>" file And I wait until the source is ready less than <time_1> secs And I create a dataset And I wait until the dataset is ready less than <time_2> secs Then I create an anomaly detector of <rows> anomalies from a dataset And I wait until the anomaly detector is ready less than <time_4> secs And I create a dataset with only the anomalies And I wait until the dataset is ready less than <time_3> secs And I check that the dataset has <rows> rows Examples: | data | time_1 | time_2 | time_3 |time_4| rows| | ../data/iris_anomalous.csv | 40 | 40 | 80 | 40 | 1 """ print self.test_scenario2.__doc__ examples = [ ['data/iris_anomalous.csv', '40', '40', '80', '40', '1']] for example in examples: print "\nTesting with:\n", example source_create.i_upload_a_file(self, example[0]) source_create.the_source_is_finished(self, example[1]) dataset_create.i_create_a_dataset(self) dataset_create.the_dataset_is_finished_in_less_than(self, example[2]) anomaly_create.i_create_an_anomaly_with_top_n_from_dataset( self, example[5]) anomaly_create.the_anomaly_is_finished_in_less_than(self, example[3]) anomaly_create.create_dataset_with_anomalies(self) dataset_create.the_dataset_is_finished_in_less_than(self, example[4]) anomaly_create.the_dataset_has_n_rows(self, example[5])