Ejemplo n.º 1
0
def test_context_load_settings():
    ctx = Context(root_dir="some")

    ctx.settings = Fake('settings')
    ctx.settings.expects('load').with_args('config.ini')

    ctx.load_settings('config.ini')
Ejemplo n.º 2
0
    def execute(self, current_dir, options, args, complement_dir=None):
        config_file = locate('config.ini')
        if not config_file:
            raise RuntimeError('Could not find config.ini file in this project, thus can\'t run unit tests')
        config_file = config_file[0]

        root_dir = dirname(config_file)
        
        context = Context(root_dir)
        context.load_settings('config.ini')

        sys.path.append(os.curdir)
        sys.path.append(root_dir)
        
        tests_dirs = []
        for app in context.apps:
            module = imp(app)

            if not module:
                log('Cannot import module [%s]' % app)
                sys.exit(0)

            module_path = dirname(inspect.getfile(module))
            
            if complement_dir:
                tests_dirs.append(join(module_path, "tests", complement_dir))
            else:
                tests_dirs.append(join(module_path, "tests"))

        self.run_nose(context.apps,
                      join(dirname(config_file), 'nose.cfg'),
                      tests_dirs, 
                      os.path.split(current_dir)[-1])
Ejemplo n.º 3
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
Ejemplo n.º 4
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."
Ejemplo n.º 5
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