Beispiel #1
0
def test_should_list_media_from_all_apps():
    ctx = Context(root_dir)
    ctx.load_settings(join(root_dir,'config.ini'))
    ctx.load_apps()
    
    all_media = ctx.list_all_media()
    assert '/js/readme.rst' in all_media, all_media
Beispiel #2
0
    def execute(self, current_dir, options, args):
        if not args:
            msg = 'You must specify the path to drop the files at' + \
                  ' as an argument.'
            raise RuntimeError(msg)

        target_dir = args[0]

        ini_files = locate("config.ini", root=current_dir)

        if not ini_files:
            raise RuntimeError("No files called config.ini were found" + \
                               "in the current directory structure")

        root_dir = abspath(dirname(ini_files[0]))

        context = Context(root_dir)
        context.load_settings(ini_files[0])
        context.load_apps()
        
        medias = context.list_all_media()
        
        if not exists(target_dir):
            os.mkdir(target_dir)
        
        for media in medias.keys():
            filename = join(target_dir, media.strip("/"))
            if not exists(dirname(filename)):
                os.makedirs(dirname(filename))
            shutil.copyfile(medias[media], filename)
        
        print "All files properly packaged."
Beispiel #3
0
def test_media_js_retrieves_the_right_media_file():
    ctx = Context(root_dir)
    ctx.load_settings(join(root_dir,'config.ini'))
    ctx.load_apps()

    all_media = ctx.list_all_media()
    
    test_file = open(all_media['/js/readme.rst'], 'r')
    file_contents =  test_file.read()
    assert 'main app' in file_contents, file_contents