Cleansing Package

Inheritance

Inheritance diagram of seed.cleansing.models

Submodules

Models

class seed.cleansing.models.Cleansing(organization, *args, **kwargs)

Bases: object

static cache_key(file_pk)

Static method to return the location of the cleansing results from redis.

Parameters:file_pk – Import file primary key
Returns:
cleanse(record_type, data)

Send in data as a queryset from the BuildingSnapshot ids. :param record_type: one of property/taxlot :param data: rows of data to be cleansed :return:

data_type_check(datum)

Check the data types of the fields. These should never be wrong as these are the data in the database.

This chunk of code is currently ignored.

Parameters:datum – Database record containing the BS version of the fields populated
Returns:None
get_fieldnames(record_type)

Get fieldnames to apply to results.

in_range_checking(datum)

Check for errors in the min/max of the values.

Parameters:datum – Database record containing the BS version of the fields populated
Returns:None
static initialize_cache(file_pk)

Initialize the cache for storing the results. This is called before the celery tasks are chunked up.

Parameters:file_pk – Import file primary key
Returns:
missing_matching_field(datum)

Look for fields in the database that are not matched. Missing is defined as a None in the database

Parameters:datum – Database record containing the BS version of the fields populated
Returns:None

# TODO: NL: Should we check the extra_data field for the data?

missing_values(datum)

Look for fields in the database that are empty. Need to know the list of fields that are part of the cleansing section.

The original intent of this method would be very intensive to run (looking at all fields except the ignored). This method was changed to check for required values.

Parameters:datum – Database record containing the BS version of the fields populated
Returns:None

# TODO: Check the extra_data field for the data?

prune_data()

Prune the results will remove any entries that have zero cleansing_results

Returns:None
reset_results()
save_to_cache(file_pk)

Save the results to the cache database. The data in the cache are stored as a list of dictionaries. The data in this class are stored as a dict of dict. This is important to remember because the data from the cache cannot be simply loaded into the above structure.

Parameters:file_pk – Import file primary key
Returns:None
class seed.cleansing.models.Rules(id, org, field, enabled, category, type, min, max, severity, units)

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception Rules.MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

static Rules.delete_rules(organization)
Rules.get_category_display(*moreargs, **morekwargs)
Rules.get_severity_display(*moreargs, **morekwargs)
Rules.get_type_display(*moreargs, **morekwargs)
static Rules.initialize_rules(organization)
Rules.objects = <django.db.models.manager.Manager object>
Rules.org

Accessor to the related object on the forward side of a many-to-one or one-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

child.parent is a ForwardManyToOneDescriptor instance.

static Rules.restore_defaults(organization)

Tasks

Tests

class seed.cleansing.tests.CleansingDataSample(methodName='runTest')

Bases: django.test.testcases.TestCase

setUp()
test_cleanse()
class seed.cleansing.tests.CleansingDataTestCoveredBuilding(methodName='runTest')

Bases: django.test.testcases.TestCase

setUp()
test_cleanse(*args, **kwargs)
test_simple_login()
class seed.cleansing.tests.CleansingDataTestPM(methodName='runTest')

Bases: django.test.testcases.TestCase

setUp()
test_cleanse()
class seed.cleansing.tests.CleansingViewTests(methodName='runTest')

Bases: django.test.testcases.TestCase

setUp()
test_get_cleansing_results()
test_get_csv()
test_get_progress()

URLs

Views