Exemplo n.º 1
0
    def test_fill_placeholder(self):
        holder_cfile = CFile(test_path + 'cfile_holder.css')
        referrer_path = test_path + 'referrer.txt'
        holder_cfile.update_referrer(referrer_path)

        with open(referrer_path) as handler:
            self.assertTrue(handler.read().find('.a{') > -1)
Exemplo n.º 2
0
    def add_by_path(self, path, url_base=None, url_map=dict(), scss_root=None):
        # directory
        if path.endswith(os.sep):
            for dirpath, dirname, filenames in os.walk(path):
                # only walk top fold level
                if dirpath != path:
                    continue
                for f in filenames:
                    if f.endswith('.js') or f.endswith('.css'):
                        path = normalize_path(dirpath + os.sep + f)
                        cfile = CFile(path,
                                      url_base=url_base,
                                      url_map=url_map,
                                      scss_root=scss_root)
                        self.add(cfile)

        else:
            self.add(CFile(path, url_base=url_base, url_map=url_map))
Exemplo n.º 3
0
    def setUp(self):
        try:
            os.mkdir(root_path + 'lib')
        except:
            pass

        try:
            with open(test_path + 'module_1.js', 'w') as handler:
                handler.write(MODULE_1_CONTENT)
        except:
            pass

        try:
            with open(root_path + 'module_2.js', 'w') as handler:
                handler.write(MODULE_2_CONTENT)
        except:
            pass

        try:
            with open(root_path + 'lib/module_3.js', 'w') as handler:
                handler.write(MODULE_3_CONTENT)
        except:
            pass

        try:
            with open(root_path + 'lib/module_4.js', 'w') as handler:
                handler.write(MODULE_4_CONTENT)
        except:
            pass

        try:
            with open(test_path + 'cfile.js', 'w') as handler:
                handler.write(CFILE_CONTENT)
        except:
            pass

        try:
            with open(test_path + 'referrer.txt', 'w') as handler:
                handler.write(REFERRER_CONTENT)
        except:
            pass

        try:
            with open(test_path + 'cfile.css', 'w') as handler:
                handler.write(CFILE_CSS_CONTENT)
        except:
            pass

        try:
            with open(test_path + 'a.css', 'w') as handler:
                handler.write(CSS_A_CONTENT)
        except:
            pass

        try:
            with open(test_path + 'b.css', 'w') as handler:
                handler.write(CSS_B_CONTENT)
        except:
            pass

        try:
            with open(test_path + 'c.css', 'w') as handler:
                handler.write(CSS_C_CONTENT)
        except:
            pass

        try:
            with open(test_path + 'cfile_holder.css', 'w') as handler:
                handler.write(CFILE_HOLDER_CONTENT)
        except:
            pass

        self.cfile = CFile(test_path + 'cfile.js',
                           url_map={'root': normalize_path('../')})
Exemplo n.º 4
0
    def test_css(self):
        cfile = CFile(test_path + 'cfile.css')
        content = ''.join(cfile.dump())

        self.assertTrue('red' in content and 'blue' in content and \
            'yellow' in content)