lomas_server.tests package

Submodules

lomas_server.tests.constants module

lomas_server.tests.test_api module

class lomas_server.tests.test_api.TestRootAPIEndpoint(methodName='runTest')[source]

Bases: TestCase

End-to-end tests of the api endpoints.

This test can be both executed as an integration test (enabled by setting LOMAS_TEST_MONGO_INTEGRATION to True), or a standard test. The first requires a mongodb to be started before running while the latter will use a local YamlDatabase.

setUp() None[source]

Set Up Header and DB for test

classmethod setUpClass() None[source]

Hook method for setting up class fixture before running tests in the class.

tearDown() None[source]

Hook method for deconstructing the test fixture after testing it.

classmethod tearDownClass() None[source]

Hook method for deconstructing the class fixture after running all tests in the class.

test_config_and_internal_server_exception() None[source]

Test set wrong configuration

test_dummy_opendp_query() None[source]
test_dummy_smartnoise_sql_query() None[source]
test_get_dataset_metadata() None[source]
test_get_dummy_dataset() None[source]
test_get_initial_budget() None[source]
test_get_previous_queries() None[source]
test_get_remaining_budget() None[source]
test_get_total_spent_budget() None[source]
test_opendp_cost() None[source]
test_opendp_query() None[source]
test_root() None[source]

Test root endpoint redirection to state endpoint

test_smartnoise_sql_cost() None[source]
test_smartnoise_sql_query() None[source]

Test smartnoise-sql query

test_smartnoise_sql_query_datetime() None[source]

Test smartnoise-sql query on datetime

test_smartnoise_sql_query_on_s3_dataset() None[source]

Test smartnoise-sql on s3 dataset

test_smartnoise_sql_query_parameters() None[source]

Test smartnoise-sql query parameters

test_state() None[source]

Test state endpoint

test_subsequent_budget_limit_logic() None[source]

lomas_server.tests.test_api_diffprivlib module

class lomas_server.tests.test_api_diffprivlib.TestDiffPrivLibEndpoint(methodName='runTest')[source]

Bases: TestRootAPIEndpoint

Test DiffPrivLib Endpoint with different models

test_clustering_models() None[source]

Test diffprivlib query: K-Means

test_diffprivlib_cost() None[source]
test_diffprivlib_query() None[source]

Test diffprivlib query

test_dimension_reduction_models() None[source]

Test diffprivlib query: PCA

test_dummy_diffprivlib_query() None[source]
test_linear_regression_models() None[source]

Test diffprivlib query: Linear Regression

test_logistic_regression_models() None[source]

Test diffprivlib query: Logistic Regression

test_naives_bayes_model() None[source]

Test diffprivlib query: Gaussian Naives Bayes

test_trees_models() None[source]

Test diffprivlib query: Random Forest, Decision Tree

lomas_server.tests.test_api_diffprivlib.validate_pipeline(response)[source]

Validate that the pipeline ran successfully Returns a model and a score.

lomas_server.tests.test_api_smartnoise_synth module

class lomas_server.tests.test_api_smartnoise_synth.TestSmartnoiseSynthEndpoint(methodName='runTest')[source]

Bases: TestRootAPIEndpoint

Test Smartnoise Synth Endpoints with different Synthesizers

test_dummy_smartnoise_synth_query() None[source]
test_smartnoise_synth_cost() None[source]
test_smartnoise_synth_query() None[source]

Test smartnoise synth query

test_smartnoise_synth_query_aim() None[source]

Test smartnoise synth query AIM Synthesizer

test_smartnoise_synth_query_constraints() None[source]

Test smartnoise synth query constraints

test_smartnoise_synth_query_datetime() None[source]

Test smartnoise synth query on other dataset for datetime columns

test_smartnoise_synth_query_delta_none() None[source]

Test smartnoise synth query on other synthesizer with delta None

test_smartnoise_synth_query_dpgan() None[source]

Test smartnoise synth query dpgan Synthesizer

test_smartnoise_synth_query_mst() None[source]

Test smartnoise synth query MST Synthesizer

test_smartnoise_synth_query_mwem() None[source]

Test smartnoise synth query MWEM Synthesizer

test_smartnoise_synth_query_pacsynth() None[source]

Test smartnoise synth query PAC-Synth Synthesizer TOO UNSTABLE BECAUSE OF RUST PANIC

test_smartnoise_synth_query_patectgan() None[source]

Test smartnoise synth query PATE-CTGAN Synthesizer

test_smartnoise_synth_query_pategan() None[source]

Test smartnoise synth query pategan Synthesizer

test_smartnoise_synth_query_private_id() None[source]

Test smartnoise synth query on other dataset for private id and categorical int columns

test_smartnoise_synth_query_samples() None[source]

Test smartnoise synth query return samples

test_smartnoise_synth_query_select_cols() None[source]

Test smartnoise synth query select_cols

lomas_server.tests.test_api_smartnoise_synth.get_model(query_response)[source]

Unpickle model from API response

lomas_server.tests.test_collection_models module

class lomas_server.tests.test_collection_models.TestMetadataModel(methodName='runTest')[source]

Bases: TestCase

Tests for the input validation of dataset metadata.

test_boolean_column() None[source]
test_categories() None[source]

test categories validation

test_categories_match_cardinality() None[source]

Test categories match cardinality

test_categories_match_type() None[source]

Test categories match column type

test_categories_required() None[source]

test categories required

test_datetime_column() None[source]
test_float_column() None[source]
test_int_column() None[source]
test_lower_upper_bounded() None[source]

Test lower is smaller than upper and of right type

test_metadata_columns_discriminator() None[source]

Test metadata column discriminator

test_precision() None[source]

test precision can only be 32 or 64

test_standard_metadata_fields()[source]

Test standard metadata fields

lomas_server.tests.test_dummy_generation module

class lomas_server.tests.test_dummy_generation.TestMakeDummyDataset(methodName='runTest')[source]

Bases: TestCase

Tests for the generation of dummy datasets.

metadata: dict[str, Any] = {'columns': {}, 'max_ids': 1, 'row_privacy': True, 'rows': 100}
test_boolean_column() None[source]
test_categorical_column() None[source]
test_datetime_column() None[source]
test_float_column() None[source]
test_int_column() None[source]
test_nullable_column() None[source]
test_seed() None[source]

lomas_server.tests.test_mongodb_admin module

class lomas_server.tests.test_mongodb_admin.TestMongoDBAdmin(methodName='runTest')[source]

Bases: TestCase

Tests for the functions in mongodb_admin.py.

This is an integration test and requires a mongodb database to be started before being executed.

The test is only executed if the LOMAS_TEST_MONGO_INTEGRATION environment variable is set to True.

classmethod setUpClass() None[source]

Connection to database

tearDown() None[source]

Drop all data from database

test_add_dataset_to_user() None[source]

Test add dataset to a user

test_add_datasets_via_yaml() None[source]

Test add datasets via a YAML file

test_add_demo_data_to_mongodb_admin() None[source]

Test add demo data to admin db

test_add_local_dataset() None[source]

Test adding a local dataset

test_add_s3_dataset() None[source]

Test adding a dataset stored on S3

test_add_s3_datasets_via_yaml() None[source]

Test add datasets via a YAML file

test_add_user() None[source]

Test adding a user

test_add_user_wb() None[source]

Test adding a user with a dataset

test_add_users_via_yaml() None[source]

Test create user collection via YAML file

test_del_dataset() None[source]

Test dataset deletion

test_del_dataset_to_user() None[source]

Test delete dataset from user

test_del_user() None[source]

Test deleting a user

test_drop_collection() None[source]

Test drop collection from db

test_get_archives_of_user() None[source]

Test show archives of user

test_get_collection() None[source]

Test show collection from db

test_get_dataset() None[source]

Test show dataset

test_get_list_of_datasets() None[source]

Test get list of datasets

test_get_list_of_datasets_from_users() None[source]

Test get list of datasets from users

test_get_list_of_users() None[source]

Test get list of users

test_get_metadata_of_dataset() None[source]

Test show metadata_dataset

test_get_user() None[source]

Test show user

test_set_budget_field() None[source]

Test setting a budget field

test_set_may_query() None[source]

Test set may query

lomas_server.tests.test_mongodb_admin_cli module

class lomas_server.tests.test_mongodb_admin_cli.TestMongoDBAdmin(methodName='runTest')[source]

Bases: TestCase

Tests for the functions in mongodb_admin.py.

This is an integration test and requires a mongodb database to be started before being executed.

The test is only executed if the LOMAS_TEST_MONGO_INTEGRATION environment variable is set to True.

run_cli_command(command: str, args: List) None[source]

Run a MongoDB administration CLI command.

Parameters:
  • command (str) – The subcommand to run.

  • args (List[str]) – A list of arguments for the subcommand.

Raises:

ValueError – If the command returns a non-zero exit status.

classmethod setUpClass() None[source]

Connection to database

tearDown() None[source]

Drop all data from database

test_add_dataset_to_user_cli() None[source]

Test add dataset to a user via cli

test_add_datasets_via_yaml_cli() None[source]

Test add datasets via a YAML file via cli

test_add_local_dataset_cli() None[source]

Test adding a local dataset via cli

test_add_user_cli() None[source]

Test adding a user via cli

test_add_user_wb_cli() None[source]

Test adding a user with a dataset via cli

test_add_users_via_yaml_cli() None[source]

Test create user collection via YAML file via cli

test_del_dataset_cli() None[source]

Test dataset deletion via cli

test_del_dataset_to_user_cli() None[source]

Test delete dataset from user via cli

test_del_user_cli() None[source]

Test deleting a user via cli

test_drop_collection_cli() None[source]

Test drop collection from db via cli

test_get_archives_of_user_cli() None[source]

Test show archives of user via CLI Does not verify output for not

test_get_collection_cli() None[source]

Test show collection from db via CLI

test_get_dataset_cli() None[source]

Test show dataset Does not verify output for not

test_get_list_of_datasets_cli() None[source]

Test get list of datasets via CLI Does not verify output for not

test_get_list_of_datasets_from_user_cli() None[source]

Test get list of users via CLI Does not verify output for not

test_get_list_of_users_cli() None[source]

Test get list of users via CLI Does not verify output for not

test_get_metadata_of_dataset_cli() None[source]

Test show metadata_of dataset Does not verify output for not

test_get_user_cli() None[source]

Test show user via CLI Does not verify output for not

test_set_budget_field_cli() None[source]

Test setting a budget field via cli

test_set_may_query_cli() None[source]

Test set may query via cli

Module contents