Example #1
0
def test_addChild(some_node):
    new_child = NodeFactory(name=u"new_child")
    num_children = some_node.children.count()
    new_child_returned = assert_deprecation_warning(some_node.addChild,
                                                    new_child)
    assert new_child is new_child_returned
    assert len(some_node.children) == num_children + 1
Example #2
0
def test_getGroup_id(some_group):
    from core.usergroups import getGroup
    from core import db
    db.session.flush()
    group = assert_deprecation_warning(getGroup, some_group.id)
    assert group == some_group
    
Example #3
0
def test_getMaskFields_first_level(some_mask):
    maskitems = assert_deprecation_warning(some_mask.getMaskFields, first_level_only=True)
    # maskitems is of type InstrumentedList
    assert isinstance(maskitems[0], Maskitem)
Example #4
0
def test_getContentType_container(container_node):
    content_type = assert_deprecation_warning(container_node.getContentType)
    assert content_type == "directory"
Example #5
0
def test_init_deprecation_datadir():
    path = os.path.join(config.settings["paths.datadir"], "testfilename")
    assert_deprecation_warning(File, path, "ni", "spam")
Example #6
0
def test_children_sort_by_fields_desc(some_node_with_sort_children):
    should_be_sorted = assert_deprecation_warning(
        some_node_with_sort_children.children.sort_by_fields, "-sortattr")
    assert_sorted(list(should_be_sorted),
                  key=lambda n: n.attrs["sortattr"],
                  reverse=True)
Example #7
0
def test_children_sort_by_name_desc(some_node_with_sort_children):
    should_be_sorted = assert_deprecation_warning(
        some_node_with_sort_children.children.sort_by_name, direction="down")
    assert_sorted(list(should_be_sorted), key=lambda n: n.name, reverse=True)
Example #8
0
def test_children_sort_by_orderpos_desc(some_node_with_sort_children):
    should_be_sorted = assert_deprecation_warning(
        some_node_with_sort_children.children.sort_by_orderpos, reverse=True)
    assert_sorted(list(should_be_sorted),
                  key=lambda n: n.orderpos,
                  reverse=True)
Example #9
0
def test_children_sort_by_fields_desc(some_node_with_sort_children):
    should_be_sorted = assert_deprecation_warning(some_node_with_sort_children.children.sort_by_fields, "-sortattr")
    assert_sorted(list(should_be_sorted), key=lambda n: n.attrs["sortattr"], reverse=True)
Example #10
0
def test_children_sort_by_fields(child_query_for_some_node):
    should_be_sorted = assert_deprecation_warning(child_query_for_some_node.sort_by_fields, "sortattr")
    assert_sorted(list(should_be_sorted), key=lambda n: n.attrs["sortattr"])
Example #11
0
def test_children_sort_by_name_desc(some_node_with_sort_children):
    should_be_sorted = assert_deprecation_warning(some_node_with_sort_children.children.sort_by_name, direction="down")
    assert_sorted(list(should_be_sorted), key=lambda n: n.name, reverse=True)
Example #12
0
def test_children_sort_by_name(child_query_for_some_node):
    should_be_sorted = assert_deprecation_warning(child_query_for_some_node.sort_by_name)
    assert_sorted(list(should_be_sorted), key=lambda n: n.name)
Example #13
0
def test_children_sort_by_orderpos_desc(some_node_with_sort_children):
    should_be_sorted = assert_deprecation_warning(some_node_with_sort_children.children.sort_by_orderpos, reverse=True)
    assert_sorted(list(should_be_sorted), key=lambda n: n.orderpos, reverse=True)
Example #14
0
def test_setOrderPos(some_node):
    assert_deprecation_warning(some_node.setOrderPos, 2)
    assert some_node.orderpos == 2
Example #15
0
def test_removeAttribute_system(some_node):
    num_attrs = len(some_node.system_attrs)
    assert_deprecation_warning(some_node.removeAttribute, "system.testattr")
    assert len(some_node.system_attrs) == num_attrs - 1
Example #16
0
def test_legacy_getter_deprecation(some_node, legacy_getter):
    assert_deprecation_warning(legacy_getter, some_node)
Example #17
0
def test_parents_sort_by_name(some_node_with_two_parents):
    should_be_sorted = assert_deprecation_warning(some_node_with_two_parents.parents.sort_by_name)
    assert_sorted(list(should_be_sorted), key=lambda n: n.name)
Example #18
0
def test_children_sort_by_name(child_query_for_some_node):
    should_be_sorted = assert_deprecation_warning(
        child_query_for_some_node.sort_by_name)
    assert_sorted(list(should_be_sorted), key=lambda n: n.name)
Example #19
0
def test_addChild(some_node):
    new_child = NodeFactory(name=u"new_child")
    num_children = some_node.children.count()
    new_child_returned = assert_deprecation_warning(some_node.addChild, new_child)
    assert new_child is new_child_returned
    assert len(some_node.children) == num_children + 1
Example #20
0
def test_children_sort_by_fields(child_query_for_some_node):
    should_be_sorted = assert_deprecation_warning(
        child_query_for_some_node.sort_by_fields, "sortattr")
    assert_sorted(list(should_be_sorted), key=lambda n: n.attrs["sortattr"])
Example #21
0
def test_getSchema(content_node):
    schema = assert_deprecation_warning(content_node.getSchema)
    assert schema == "testschema"
Example #22
0
def test_parents_sort_by_name(some_node_with_two_parents):
    should_be_sorted = assert_deprecation_warning(
        some_node_with_two_parents.parents.sort_by_name)
    assert_sorted(list(should_be_sorted), key=lambda n: n.name)
Example #23
0
def test_getContentType_content(content_node):
    content_type = assert_deprecation_warning(content_node.getContentType)
    assert content_type == "document"
Example #24
0
def test_getMaskFields_first_level(some_mask):
    maskitems = assert_deprecation_warning(some_mask.getMaskFields,
                                           first_level_only=True)
    # maskitems is of type InstrumentedList
    assert isinstance(maskitems[0], Maskitem)
Example #25
0
def test_getMaskFields(some_mask):
    from core import db
    db.session.flush()
    maskitems = assert_deprecation_warning(some_mask.getMaskFields)
    # maskitems is of type MtQuery
    assert isinstance(maskitems.first(), Maskitem)
Example #26
0
def test_legacy_getter_deprecation(some_file, legacy_getter):
    assert_deprecation_warning(legacy_getter, some_file)
Example #27
0
def test_removeAttribute_system(some_node):
    num_attrs = len(some_node.system_attrs)
    assert_deprecation_warning(some_node.removeAttribute, "system.testattr")
    assert len(some_node.system_attrs) == num_attrs - 1
Example #28
0
def test_getContainerChildren(some_node):
    container_children = assert_deprecation_warning(some_node.getContainerChildren)
    assert len(container_children) == 1
    assert container_children[0].name == "container"
Example #29
0
def test_setOrderPos(some_node):
    assert_deprecation_warning(some_node.setOrderPos, 2)
    assert some_node.orderpos == 2
Example #30
0
def test_getMaskFields(some_mask):
    from core import db
    db.session.flush()
    maskitems = assert_deprecation_warning(some_mask.getMaskFields)
    # maskitems is of type MtQuery
    assert isinstance(maskitems.first(), Maskitem)
Example #31
0
def test_init_deprecation_datadir():
    path = os.path.join(config.settings["paths.datadir"], "testfilename")
    assert_deprecation_warning(File, path, "ni", "spam")