Unit test suite for Hydra Platform

class tests.test_network.TestNetwork

Test for network-based functionality

test_add_nodes(session, projectmaker)

Test add new nodes to network

test_consistency_of_update(session, network_with_data)

Test to ensure that updating a network which has not changed does not cause any changes to the network. Procedure: 1 Create a network. 2 Immediately update the network without changing it. 3 Check that the original network and the updated network are identical.

test_get_all_resource_attributes_in_network(session, network_with_data)

Test to retrieve all the resourceattributes relating to the specified attribute ID in the network, regardless of what node, link group etc they belong to.

test_get_extents(session, network_with_data)

Extents test: Test that the min X, max X, min Y and max Y of a network are retrieved correctly.

test_get_network(session, networkmaker)

Test for the potentially likely case of creating a network with two scenarios, then querying for the network without data to identify the scenarios, then querying for the network with data but in only a select few scenarios.

test_get_network_with_template(session, network_with_data)

Test for the potentially likely case of creating a network with two scenarios, then querying for the network without data to identify the scenarios, then querying for the network with data but in only a select few scenarios.

test_get_resources_of_type(session, network_with_data)

Test for the retrieval of all the resources of a specified type within a network.

class tests.test_data.TestTimeSeries

Test for timeseries-based functionality

test_relative_dataframe(session, network, relative_dataframe)

Test for relative timeseries for example, x number of hours from hour 0.

class tests.test_data.TestiUtilities

Test hydra’s internal utilities relating to data transformations etc.

tests.test_data.arbitrary_dataframe()

Create a timeseries which has relative timesteps: 1, 2, 3 as opposed to timestamps

tests.test_data.relative_dataframe()

Create a timeseries which has relative timesteps: 1, 2, 3 as opposed to timestamps

tests.test_data.seasonal_timeseries()

Create a timeseries which has relative timesteps: 1, 2, 3 as opposed to timestamps

class tests.test_units.TestUnits

Test for working with units.

tests.test_units.arr_to_vector(arr)

Reshape a multidimensional array to a vector.

tests.test_units.array_dim(arr)

Return the size of a multidimansional array.

NOTE: All the methods that has SKELETON key in the doc, are not yet implemented partially/fully

class tests.test_attributes.TestAttribute

Test for attribute-based functionality

test_check_attr_dimension(session, new_dataset)

def check_attr_dimension(attr_id, **kwargs):

test_get_attributes(session)

def get_attributes(**kwargs):

test_get_template_attributes(session)

SKELETON def get_template_attributes(template_id, **kwargs):

class tests.test_attributes.TestAttributeGroups

Test for attribute Groups-based functionality

test_add_attribute_group_items(session)

SKELETON def add_attribute_group_items(attributegroupitems, **kwargs):

test_exclusive_add_attribute_group_items(session, projectmaker, network_with_data, attributegroupmaker)

add attributes to a group that are already in an exclusive group

test_get_attribute_group(session)

SKELETON def get_attribute_group(group_id, **kwargs):

test_get_attribute_item_groups(session)

SKELETON def get_attribute_item_groups(network_id, attr_id, **kwargs):

test_get_group_attributegroup_items(session)

SKELETON def get_group_attributegroup_items(network_id, group_id, **kwargs):

test_get_network_attributegroup_items(session)

SKELETON def get_network_attributegroup_items(network_id, **kwargs):

test_reverse_exclusive_add_attribute_group_items(session, projectmaker, network_with_data, attributegroupmaker)

add attributes to an exclusive group that are already in another group

class tests.test_project.TestProject

Test for working with projects in Hydra

test_update(session, network_with_data)

The network here is necessary for a scenario with ID 1 to exist. Under normal circumstances, scenario 1 will always exist, as it’s an initial requirement of the database setup.

class tests.test_templates.TestTemplates

Test for templates

test_type_compatibility(session, mock_template, mock_template_copy)

Check function that thests whether two types are compatible – the overlapping attributes are specified with the same unit. Change the unit associated with an attribute for types in two idencical templates, and test. There should be 1 error returned. THen test comparison of identical types. No errors should return.

class tests.test_users.TestUser

A collection of tests of the User part of the DB.

test_add_perm(session, client, perm_json_object)

Test adding a new permission

test_add_role(session, client, role_json_object)

Test adding a new role

test_add_user(session, client, user_json_object)

Test adding a new user to the DB

test_get_perms(client, session)

Test fetching all the perms

test_get_username(session, client, user_json_object)

Test retrieving a username

test_get_users(session, client, user_json_object)

Test fetching all the users

test_set_role_perm(session, client, role_json_object, perm_json_object)

Test assigning a perm to a user

test_set_user_role(session, client, user_json_object, role_json_object)

Test assigning a role to a user

test_update_user_password(session, client, user_json_object)

Test changing a user’s password