seed.tests package¶
Submodules¶
seed.tests.test_admin_views module¶
:copyright (c) 2014 - 2016, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author
-
class
seed.tests.test_admin_views.
AdminViewsTest
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
-
setUp
()¶
-
test_add_org
()¶ Happy path test for creating a new org.
-
test_add_org_dupe
()¶ Trying to create an org with a dupe name fails.
-
test_add_user_existing_org
()¶ Test creating a new user, adding them to an existing org in the process.
-
test_add_user_new_org
()¶ Create a new user and a new org at the same time.
-
test_add_user_no_org
()¶ Shouldn’t be able to create a new user without either selecting or creating an org at the same time.
-
test_signup_process
()¶ Simulates the entire new user signup process, from initial account creation by an admin to recieving the signup email to confirming the account and setting a password.
-
test_signup_process_force_lowercase_email
()¶ Simulates the signup and login forcing login username to lowercase
-
seed.tests.test_decorators module¶
:copyright (c) 2014 - 2016, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author
-
class
seed.tests.test_decorators.
TestDecorators
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests for locking tasks and reporting progress.
-
locked
= 1¶
-
pk
= 34¶
-
setUp
()¶
-
test_get_prog_key
()¶ We format our cache key properly.
-
test_increment_cache
()¶ Sum our progress by increments properly.
-
test_locking
()¶ Make sure we indicate we’re locked iff we’re inside the function.
-
test_locking_w_exception
()¶ Make sure we release our lock if we’ve had an exception.
-
test_progress
()¶ When a task finishes, it increments the progress counter properly.
-
unlocked
= 0¶
-
-
exception
seed.tests.test_decorators.
TestException
¶ Bases:
exceptions.Exception
seed.tests.test_exporters module¶
:copyright (c) 2014 - 2016, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author
-
class
seed.tests.test_exporters.
TestExporters
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests for exporting data to various formats.
-
setUp
()¶
-
tearDown
()¶
-
test_csv_export
()¶ Ensures exported CSV data matches source data
-
test_csv_export_extra_data
()¶ Ensures exported CSV data matches source data
-
test_data_model_assumptions
()¶ Some parts of export make certain assumptions about the data model, this test ensures that those assumptions are true.
-
test_xls_export
()¶ Ensures exported XLS data matches source data
-
seed.tests.test_models module¶
:copyright (c) 2014 - 2016, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author
-
class
seed.tests.test_models.
TestBuildingSnapshot
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Test the clean methods on BuildingSnapshotModel.
-
bs1_data
= {'custom_id_1': 1243, 'city': 'Gotham City', 'pm_property_id': 1243, 'postal_code': 8999, 'tax_lot_id': '435/422', 'address_line_2': '', 'property_name': 'Greenfield Complex', 'address_line_1': '555 Database LN.'}¶
-
bs2_data
= {'custom_id_1': 37376, 'city': 'Gotham City', 'pm_property_id': 9999, 'postal_code': 8999, 'tax_lot_id': '1231', 'address_line_2': 'Apt 4', 'property_name': 'A Place', 'address_line_1': '44444 Hmmm Ave.'}¶
-
setUp
()¶
-
test_clean
()¶ Make sure we convert datestrings properly.
-
test_create_child
()¶ Child BS has reference to parent.
-
test_get_column_mapping
()¶ Honor organizational bounds, get mapping data.
-
test_get_column_mappings
()¶ We produce appropriate data structure for mapping
-
test_get_tip
()¶ BS tip should point to the end of the tree.
-
test_merge_extra_data
()¶ extra_data dicts get merged proper-like.
-
test_merge_extra_data_does_not_override_with_blank_data
()¶ Test that blank fields in extra data don’t override real data
-
test_merge_extra_data_no_data
()¶ Test edgecase where there is no extra_data to merge.
-
test_recurse_tree
()¶ Make sure we get an accurate child tree.
-
test_remove_child
()¶ Test behavior for removing a child.
-
test_save_snapshot_match_default_to_first_building
()¶ Test good case for saving a snapshot match with the first building as default.
-
test_save_snapshot_match_default_to_second_building
()¶ Test good case for saving a snapshot match with the second building as default.
-
test_source_attributions
()¶ Test that we can point back to an attribute’s source.
This is explicitly just testing the low-level data model, none of the convenience functions.
-
test_unmatch_snapshot_tree_last_match
()¶ Tests the simplest case of unmatching a building where the child snapshot created from the original matching has not since been matched with another building (no children).
-
test_unmatch_snapshot_tree_prior_match
()¶ Tests the more complicated case of unmatching a building after more buildings have been matched to the snapshot resulting from the original match.
-
test_unmatch_snapshot_tree_retains_canonical_snapshot
()¶ TODO:
-
test_update_building
()¶ Good case for updating a building.
-
seed.tests.test_tasks module¶
:copyright (c) 2014 - 2016, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author
-
class
seed.tests.test_tasks.
TestCleaner
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests that our logic for constructing cleaners works.
-
setUp
()¶
-
test_build_cleaner
()¶
-
-
class
seed.tests.test_tasks.
TestTasks
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests for dealing with SEED related tasks.
-
setUp
()¶
-
test_cached_first_row_order
()¶ Tests to make sure the first row is saved in the correct order. It should be the order of the headers in the original file.
-
test_delete_organization_buildings
()¶ tests the delete builings for an org
-
test_get_ancestors
()¶ Tests get_ancestors(building), returns all non-composite, non-raw BuildingSnapshot instances.
-
test_handle_id_matches_duplicate_data
()¶ Test for handle_id_matches behavior when matching duplicate data
-
test_is_same_snapshot
()¶ Test to check if two snapshots are duplicates
-
test_map_data
()¶ Save mappings based on user specifications.
-
test_mapping_w_concat
()¶ When we have a json encoded list as a column mapping, we concat.
-
test_match_buildings
()¶ Good case for testing our matching system.
-
test_match_duplicate_buildings
()¶ Test for behavior when trying to match duplicate building data
-
test_match_no_canonical_buildings
()¶ If no canonicals exist, create, but no new BSes.
-
test_match_no_matches
()¶ When a canonical exists, but doesn’t match, we create a new one.
-
test_no_unmatched_buildings
()¶ Make sure we shortcut out if there isn’t unmatched data.
-
test_save_raw_data
()¶ Save information in extra_data, set other attrs.
-
test_save_raw_data_batch_iterator
()¶ Ensure split_csv completes
-
test_separates_system_and_possible_match_types
()¶ We save possible matches separately.
-
-
class
seed.tests.test_tasks.
TestTasksXLS
(methodName='runTest')¶ Bases:
seed.tests.test_tasks.TestTasks
Runs the TestTasks tests with an XLS file
-
setUp
()¶
-
-
class
seed.tests.test_tasks.
TestTasksXLSX
(methodName='runTest')¶ Bases:
seed.tests.test_tasks.TestTasks
Runs the TestsTasks tests with an XLSX file.
-
setUp
()¶
-
seed.tests.test_views module¶
:copyright (c) 2014 - 2016, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author
-
class
seed.tests.test_views.
BuildingDetailViewTests
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests of the SEED Building Detail page
-
setUp
()¶
-
test_get_building
()¶ tests the get_building view which retuns building detail and source information from parent buildings.
-
test_get_building_with_deleted_dataset
()¶ tests the get_building view where the dataset has been deleted and the building should load without showing the sources from deleted import files.
-
test_get_building_with_project
()¶ tests get_building projects payload
-
test_get_match_tree
()¶ tests get_match_tree
-
test_get_match_tree_from_child
()¶ tests get_match_tree from the child
-
test_save_match_audit_log
()¶ tests that a building match logs an audit_log
-
test_save_match_invalid_org
()¶ tests that a building match checks perm of org id
-
test_save_match_wrong_perms_different_building_orgs
()¶ tests that a building match is valid for BS orgs
-
test_save_match_wrong_perms_org_id
()¶ tests that a building match is valid for the org id
-
test_save_unmatch_audit_log
()¶ tests that a building unmatch logs an audit_log
-
test_update_building_audit_log
()¶ tests that a building update logs an audit_log
-
-
class
seed.tests.test_views.
DataImporterViewTests
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests of the data_importer views (and the objects they create).
-
setUp
()¶
-
test_get_first_five_rows
()¶ Make sure we get our first five rows back correctly.
-
test_get_raw_column_names
()¶ Make sure we get column names back in a format we expect.
-
-
class
seed.tests.test_views.
DefaultColumnsViewTests
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests of the SEED default custom saved columns
-
setUp
()¶
-
tearDown
()¶
-
test_get_columns
()¶
-
test_get_columns_project
()¶ check that status labels are included for projects
-
test_get_default_columns_initial_state
()¶
-
test_get_default_columns_with_set_columns
()¶
-
test_set_default_columns
()¶
-
-
class
seed.tests.test_views.
MatchTreeTests
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Currently only tests _parent_tree_coparents
-
setUp
()¶
-
test_parent_tree_coparents
(*args, **kwargs)¶ Tests that _parent_tree_coparents returns what we expect
-
-
class
seed.tests.test_views.
SearchViewTests
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
Tests of the SEED search_buildings
-
setUp
()¶
-
test_seach_active_canonicalbuildings
()¶ tests the search_buildings method used throughout the app for only returning active CanonicalBuilding BuildingSnapshot insts.
-
test_search_case_insensitive_exact_match
()¶ Tests search_buidlings method when called with a case insensitive exact match.
-
test_search_empty_column
()¶ Tests search_buidlings method when called with an empty column query.
-
test_search_exact_match
()¶ Tests search_buidlings method when called with an exact match.
-
test_search_extra_data
()¶ tests the search_buidlings method used throughout the app for only returning active CanonicalBuilding BuildingSnapshot insts.
-
test_search_extra_data_empty_column
()¶ Empty column query on extra_data key should match key’s value being empty in jsonfield.
-
test_search_extra_data_exact_match
()¶ Exact match on extra_data json keys
-
test_search_extra_data_non_empty_column
()¶ Not-empty column query on extra_data key.
-
test_search_extra_data_non_existent_column
()¶ Empty column query on extra_data key should match key not existing in jsonfield.
-
test_search_filter_range
()¶ Tests search_buidlings method when called with a range.
-
test_search_not_empty_column
()¶ Tests search_buidlings method when called with a not-empty column query.
-
test_search_sort
()¶ tests the search_buidlings method used throughout the app for only returning active CanonicalBuilding BuildingSnapshot insts.
-
test_sort_extra_data
()¶ Tests that sorting on extra data takes the column type into account.
-
-
class
seed.tests.test_views.
TestMCMViews
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
-
assert_expected_mappings
(actual, expected)¶ For each k,v pair of form column_name: [dest_col, confidence] in actual, assert that expected contains the same column_name and dest_col mapping.
-
expected_mappings
= {u'year built': [u'year_built', 50], u'building id': [u'Building air leakage', 64], u'name': [u'Name of Audit Certification Holder', 47], u'address': [u'owner_address', 70]}¶
-
raw_columns_expected
= {u'status': u'success', u'raw_columns': [u'name', u'address', u'year built', u'building id']}¶
-
setUp
()¶
-
test_create_dataset
()¶ tests the create_dataset view, allows duplicate dataset names
-
test_get_column_mapping_suggestions
(*args, **kwargs)¶ Good case for
get_column_mapping_suggestions
.
-
test_get_column_mapping_suggestions_concat
(*args, **kwargs)¶ When one of the column mappings represents a concatenation.
-
test_get_raw_column_names
()¶ Good case for
get_raw_column_names
.
-
test_progress
()¶ Make sure we retrieve data from cache properly.
-
test_remap_buildings
()¶ Test good case for resetting mapping.
-
test_reset_mapped_w_matching_done
()¶ Make sure we don’t delete buildings that have been merged.
-
test_reset_mapped_w_previous_matches
()¶ Ensure we ignore mapped buildings with children BSes.
-
test_save_column_mappings
()¶
-
test_save_column_mappings_idempotent
()¶ We need to make successive calls to save_column_mappings.
-
test_save_column_mappings_w_concat
()¶ Concat payloads come back as lists.
-
seed.tests.tests module¶
:copyright (c) 2014 - 2016, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author
-
class
seed.tests.tests.
ComplianceTestCase
(methodName='runTest')¶ Bases:
django.test.testcases.TestCase
-
test_basic_compliance_creation
()¶
-
seed.tests.util module¶
:copyright (c) 2014 - 2016, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author
-
class
seed.tests.util.
FakeClient
¶ Bases:
object
An extremely light-weight test client.
-
get
(view_func, data, headers=None, **kwargs)¶
-
post
(view_func, data, headers=None, **kwargs)¶
-
-
class
seed.tests.util.
FakeRequest
(data=None, headers=None, user=None, method='POST', **kwargs)¶ Bases:
object
A simple request stub.
-
GET
= {}¶
-
META
= {'REMOTE_ADDR': '127.0.0.1'}¶
-
POST
= {}¶
-
body
= None¶
-
path
= 'fake_login_path'¶
-
-
seed.tests.util.
make_fake_mappings
(mappings, org)¶ Takes a dict and saves a ColumnMapping object for each key
-
seed.tests.util.
make_fake_snapshot
(import_file, init_data, bs_type, is_canon=False, org=None)¶ For making fake mapped BuildingSnapshots to test matching against.
Module contents¶
:copyright (c) 2014 - 2016, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA :author