from urlparse import urlparse
from addons.osfstorage import settings as osfstorage_settings
from framework.auth.core import Auth

def create_test_file(node, user, filename='test_file', create_guid=True):
    osfstorage = node.get_addon('osfstorage')
    root_node = osfstorage.get_root()
    test_file = root_node.append_file(filename)

    if create_guid:
        test_file.get_guid(create=True)

    test_file.create_version(user, {
        'object': '06d80e',
        'service': 'cloud',
        osfstorage_settings.WATERBUTLER_RESOURCE: 'osf',
    }, {
        'size': 1337,
        'contentType': 'img/png'
    }).save()

    root_node.add_log(
        'osf_storage_file_added',
        auth=Auth(user),
        params={
            'node': root_node._id,
            'project': root_node.parent_id,
            'path': test_file.materialized_path,
            'params_file':  '/project/{}/files/osfstorage/{}/'.format(root_node._id, test_file._id)
        },
    )
    root_node.save()

    return test_file

def urlparse_drop_netloc(url):
    url = urlparse(url)
    if url[4]:
        return url[2] + '?' + url[4]
    return url[2]

@@ -620,29 +620,24 @@
 save()%0A%0A    
-root_
 node.add_log
@@ -734,21 +734,16 @@
 'node': 
-root_
 node._id
@@ -767,21 +767,16 @@
 oject': 
-root_
 node.par
@@ -902,21 +902,16 @@
 .format(
-root_
 node._id
@@ -944,29 +944,24 @@
 ,%0A    )%0A    
-root_
 node.save()%0A

fix test