示例#1
0
文件: base.py 项目: beirving/dnddata
    def create_or_update(self, label: str, data: dict, context: Transaction):
        self.create_node(label=label, name=data['name'])

        check_node = self.get_node(self.node())
        exits = False
        if type(check_node) is Node:
            exits = True
            self.node(check_node)

        self.assign_attributes(data)

        if exits is False:
            context.create(self.node())
            print(f"Created {label}")
        else:
            context.push(self.node())
            print(f"Updated {label}")
示例#2
0
def test_should_fail_on_tx_push_object():
    tx = Transaction(FakeGraph())
    with raises(TypeError):
        tx.push(object())