Example #1
0
def test_add_node():
    """
    add_node should add an S3File to a node if it is a file
    """
    # When I have a node
    node = S3Dir("")

    # And I have a boto key
    key = BotoKey("foo")

    # When I add the key to the node
    add_key(node, key, key.name)

    # Then It adds an S3File
    node.files[0].name.should.equal("foo")
Example #2
0
def test_add_node_nested():
    """
    add_node should add nested nodes if given nested keys
    """
    # When I have a node
    node = S3Dir("")

    # And I have a boto key
    key = BotoKey("top/middle/foo")

    # When I add the key to the node
    add_key(node, key, key.name)

    # Then It adds the appropriate nodes
    node.dirs[0].name.should.equal("top")
    node.dirs[0].dirs[0].name.should.equal("middle")
    node.dirs[0].dirs[0].files[0].name.should.equal("foo")
Example #3
0
def test_add_multiple_files_to_directory():
    """
    add_node should add directories with multiple sub files
    """
    # When I have a node
    node = S3Dir("")

    # And I have a boto key
    key = BotoKey("middle/aa")
    key2 = BotoKey("middle/zz")

    # When I add the key to the node
    add_key(node, key, key.name)
    add_key(node, key2, key2.name)

    # Then It adds the appropriate nodes
    node.dirs[0].name.should.equal("middle")
    node.dirs[0].files[0].name.should.equal("aa")
    node.dirs[0].files[1].name.should.equal("zz")
Example #4
0
def test_add_directory_with_multiple_sub_directories():
    """
    add_node should add directories with multiple sub directories
    """
    # When I have a node
    node = S3Dir("")

    # And I have a boto key
    key = BotoKey("top/top/aa")
    key2 = BotoKey("top/bottom/zz")

    # When I add the key to the node
    add_key(node, key, key.name)
    add_key(node, key2, key2.name)

    # Then It adds the appropriate nodes
    node.dirs[0].name.should.equal("top")
    node.dirs[0].dirs[0].name.should.equal("top")
    node.dirs[0].dirs[1].name.should.equal("bottom")
    node.dirs[0].dirs[0].files[0].name.should.equal("aa")
    node.dirs[0].dirs[1].files[0].name.should.equal("zz")