Tests Package

Admin Views

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 receiving 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

Decorators

class seed.tests.test_decorators.ClassDecoratorTests(methodName='runTest')

Bases: django.test.testcases.TestCase

test_ajax_request_class_dict()
test_ajax_request_class_dict_status_error()
test_ajax_request_class_dict_status_false()
test_ajax_request_class_format_type()
test_require_organization_id_class_no_org_id()
test_require_organization_id_class_org_id()
test_require_organization_id_class_org_id_not_int()
class seed.tests.test_decorators.RequireOrganizationIDTests(methodName='runTest')

Bases: django.test.testcases.TestCase

setUp()
test_require_organization_id_fail_no_key()
test_require_organization_id_fail_not_numeric()
test_require_organization_id_success_integer()
test_require_organization_id_success_string()
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 if and only if 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

Exporters

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

Models

Tasks

class seed.tests.test_tasks.TestTasks(methodName='runTest')

Bases: django.test.testcases.TestCase

Tests for dealing with SEED related tasks.

setUp()
test_delete_organization()
test_delete_organization_buildings(*args, **kwargs)

tests the delete buildings for an organization

test_delete_organization_doesnt_delete_user_if_multiple_memberships()

Deleting an org shouldn’t delete the orgs users if the user belongs to many orgs.

Views

class seed.tests.test_views.BuildingDetailViewTests(methodName='runTest')

Bases: django.test.testcases.TestCase

Tests of the SEED Building Detail page

setUp()
test_get_match_tree(*args, **kwargs)

tests get_match_tree

test_get_match_tree_from_child(*args, **kwargs)

tests get_match_tree from the child

test_get_property(*args, **kwargs)
test_get_taxlot(*args, **kwargs)
test_save_match_audit_log(*args, **kwargs)

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(*args, **kwargs)

tests that a building unmatch logs an audit_log

test_update_building_audit_log(*args, **kwargs)

tests that a building update logs an audit_log

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_default_columns_initial_state()
test_get_default_columns_with_set_columns()
test_set_default_columns()
class seed.tests.test_views.GetDatasetsViewsTests(methodName='runTest')

Bases: django.test.testcases.TestCase

setUp()
test_delete_dataset()
test_get_dataset()
test_get_datasets()
test_get_datasets_count()
test_get_datasets_count_invalid()
test_update_dataset()
class seed.tests.test_views.ImportFileViewsTests(methodName='runTest')

Bases: django.test.testcases.TestCase

setUp()
test_delete_duplicates_from_import_file()
test_delete_file()
test_get_import_file()
test_get_matching_results()
class seed.tests.test_views.InventoryViewTests(methodName='runTest')

Bases: django.test.testcases.TestCase

setUp()
tearDown()
test_get_cycles()
test_get_properties()
test_get_properties_cycle_id()
test_get_properties_empty_page()
test_get_properties_page_not_an_integer()
test_get_properties_property_extra_data()
test_get_properties_taxlot_extra_data()
test_get_properties_with_taxlots()
test_get_property()
test_get_property_columns()
test_get_property_history()
test_get_property_multiple_taxlots()
test_get_taxlot()
test_get_taxlot_columns()
test_get_taxlots()
test_get_taxlots_empty_page()
test_get_taxlots_extra_data()
test_get_taxlots_missing_jurisdiction_tax_lot_id()
test_get_taxlots_multiple_taxlots()
test_get_taxlots_no_cycle_id()
test_get_taxlots_page_not_an_integer()
class seed.tests.test_views.MainViewTests(methodName='runTest')

Bases: django.test.testcases.TestCase

setUp()
test_export_buildings()
test_export_buildings_empty()
test_export_buildings_progress()
test_home()
class seed.tests.test_views.MatchTreeTests(methodName='runTest')

Bases: django.test.testcases.TestCase

Currently only tests _parent_tree_coparents

setUp()
test_get_coparents()
test_parent_tree_coparents()

Tests that _parent_tree_coparents returns what we expect

class seed.tests.test_views.ReportViewsTests(methodName='runTest')

Bases: django.test.testcases.TestCase

setUp()
test_get_aggregated_building_report_data(*args, **kwargs)
test_get_aggregated_inventory_report_data(*args, **kwargs)
test_get_building_report_data(*args, **kwargs)
test_get_building_summary_report_data()
test_get_inventory_report_data(*args, **kwargs)
class seed.tests.test_views.SearchBuildingSnapshotsViewTests(methodName='runTest')

Bases: django.test.testcases.TestCase

setUp()
test_search_mapping_results(*args, **kwargs)
class seed.tests.test_views.SearchViewTests(methodName='runTest')

Bases: django.test.testcases.TestCase

Tests of the SEED search_buildings

setUp()
test_search_active_canonicalbuildings(*args, **kwargs)

tests the search_buildings method used throughout the app for only returning active CanonicalBuilding BuildingSnapshot instances.

test_search_case_insensitive_exact_match(*args, **kwargs)

Tests search_buildings method when called with a case insensitive exact match.

test_search_empty_column(*args, **kwargs)

Tests search_buildings method when called with an empty column query.

test_search_exact_exclude_filter(*args, **kwargs)
test_search_exact_match(*args, **kwargs)

Tests search_buildings method when called with an exact match.

test_search_exclude_filter(*args, **kwargs)
test_search_extra_data(*args, **kwargs)

tests the search_buildings method used throughout the app for only returning active CanonicalBuilding BuildingSnapshot instances.

test_search_extra_data_empty_column(*args, **kwargs)

Empty column query on extra_data key should match key’s value being empty in JsonField.

test_search_extra_data_exact_exclude_filter(*args, **kwargs)
test_search_extra_data_exact_match(*args, **kwargs)

Exact match on extra_data json keys

test_search_extra_data_exclude_filter(*args, **kwargs)
test_search_extra_data_non_empty_column(*args, **kwargs)

Not-empty column query on extra_data key.

test_search_extra_data_non_existent_column(*args, **kwargs)

Empty column query on extra_data key should match key not existing in JsonField.

test_search_filter_date_range_ISO8601(*args, **kwargs)
test_search_filter_range()

Tests search_buildings method when called with a range.

test_search_not_empty_column(*args, **kwargs)

Tests search_buildings method when called with a not-empty column query.

test_search_sort(*args, **kwargs)

tests the search_buildings method used throughout the app for only returning active CanonicalBuilding BuildingSnapshot instances.

test_sort_extra_data(*args, **kwargs)

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()
test_get_column_mapping_suggestions_pm_file()
test_get_column_mapping_suggestions_with_columns()
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(*args, **kwargs)

Test good case for resetting mapping.

test_reset_mapped_w_matching_done(*args, **kwargs)

Make sure we don’t delete buildings that have been merged.

test_reset_mapped_w_previous_matches(*args, **kwargs)

Ensure we ignore mapped buildings with children BuildingSnapshots.

test_save_column_mappings()
test_save_column_mappings_idempotent()

We need to make successive calls to save_column_mappings.

Tests

class seed.tests.tests.ComplianceTestCase(methodName='runTest')

Bases: django.test.testcases.TestCase

test_basic_compliance_creation()
class seed.tests.tests.ProjectTestCase(methodName='runTest')

Bases: django.test.testcases.TestCase

test_basic_project_creation()
class seed.tests.tests.UtilsTests(methodName='runTest')

Bases: django.test.testcases.TestCase

setUp()
test_get_buildings_count_for_user()

Utils

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_property(import_file, init_data, bs_type, is_canon=False, org=None)

For making fake mapped PropertyState to test matching against.