def _check_schema_version(version, es, warning_text, caplog, warning_type=None): entities = { entity.id: serialize.entity_to_description(entity) for entity in es.entities } relationships = [ relationship.to_dictionary() for relationship in es.relationships ] dictionary = { 'schema_version': version, 'id': es.id, 'entities': entities, 'relationships': relationships, } if warning_type == 'log' and warning_text: logger = logging.getLogger('featuretools') logger.propagate = True deserialize.description_to_entityset(dictionary) assert warning_text in caplog.text logger.propagate = False elif warning_type == 'warn' and warning_text: with pytest.warns(UserWarning) as record: deserialize.description_to_entityset(dictionary) assert record[0].message.args[0] == warning_text else: deserialize.description_to_entityset(dictionary)
def test_entity_descriptions(es): _es = EntitySet(es.id) for entity in es.metadata.entities: description = serialize.entity_to_description(entity) deserialize.description_to_entity(description, _es) _entity = _es[description['id']] _entity.last_time_index = entity.last_time_index assert entity.__eq__(_entity, deep=True)
def _check_schema_version(version, es, error_text): entities = {entity.id: serialize.entity_to_description(entity) for entity in es.entities} relationships = [relationship.to_dictionary() for relationship in es.relationships] dictionary = { 'schema_version': version, 'id': es.id, 'entities': entities, 'relationships': relationships, } if error_text: with pytest.raises(RuntimeError) as excinfo: deserialize.description_to_entityset(dictionary) assert error_text == str(excinfo.value) else: deserialize.description_to_entityset(dictionary)
def _check_schema_version(version, es, warning_text): entities = { entity.id: serialize.entity_to_description(entity) for entity in es.entities } relationships = [ relationship.to_dictionary() for relationship in es.relationships ] dictionary = { 'schema_version': version, 'id': es.id, 'entities': entities, 'relationships': relationships, } if warning_text: with pytest.warns(UserWarning) as record: deserialize.description_to_entityset(dictionary) assert record[0].message.args[0] == warning_text else: deserialize.description_to_entityset(dictionary)
def test_empty_dataframe(es): for entity in es.entities: description = serialize.entity_to_description(entity) dataframe = deserialize.empty_dataframe(description) assert dataframe.empty