def test_normalize_path(self): self.assertEqual(utils.normalize_path('foo/bar/../test/'), 'foo/test/') self.assertEqual(utils.normalize_path('C:\\windows\\User\\Desktop\\'), 'C:\\windows\\User\\Desktop\\') self.assertEqual(utils.normalize_path('../test/foo.js'), '../test/foo.js') self.assertEqual(utils.normalize_path('bar.js'), 'bar.js')
def test_normalize_path(self): self.assertEqual(utils.normalize_path('foo/bar/../test/'), 'foo\\test\\') self.assertEqual(utils.normalize_path('C:\\windows\\User\\Desktop\\'), 'c:\\windows\\user\\desktop\\') self.assertEqual(utils.normalize_path('../test/foo.js'), '..\\test\\foo.js') self.assertEqual(utils.normalize_path('bar.js'), 'bar.js')
def setUp(self): workspace = test_path + 'workspace' build = normalize_path(workspace + '/build/') store = normalize_path(workspace + '/store/') os.mkdir(workspace) os.mkdir(build) os.mkdir(store) for filename, file_content in [('c1.js', C1_JS), ('c2.js', C2_JS), ('c3.js', C3_JS), ('c4.css', C4_CSS), ('config.json', CONFIG_CONTENT)]: path = normalize_path(build + filename) with open(path, 'w') as handler: handler.write(file_content) with open(workspace + os.sep + 'referrer.txt', 'w') as handler: handler.write(REFERRER_CONTENT)
def setUp(self): os.mkdir(test_path + 'cfile') for filename, file_content in [('c1.js', C1_JS), ('c2.js', C2_JS), ('c3.js', C3_JS), ('c4.css', C4_CSS)]: path = normalize_path(test_path + 'cfile/' + filename) with open(path, 'w') as handler: handler.write(file_content) group = CFileGroup() group.add_by_path(test_path + 'cfile' + os.sep) self.group = group
def test_batch(self): batch = Batch(normalize_path(test_path + 'workspace/build/config.json')) batch.list() batch.filter([3]) batch.filter([1]) batch.publish() logger.debug('====================================================') group = [item.index for item in batch.group.list(True)] for i in range(10): selected = random.sample(group, 2) print selected batch.filter(selected) batch.publish() logger.debug('====================================================')
def test_batch(self): batch = Batch(normalize_path(test_path + 'workspace/build/config.json')) batch.list() batch.filter([3]) batch.filter([1]) batch.publish() logger.debug('====================================================') group = [item.index for item in batch.group.list(True)] for i in range(10): selected = random.sample(group, 2) print(selected) batch.filter(selected) batch.publish() logger.debug( '====================================================')
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))
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('../') })
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('../')})
def collect_stale(self, direct): return [ normalize_path(direct + item.get_stale_name()) for item in self.list() ]
def collect_stale(self, direct): return [normalize_path(direct + item.get_stale_name()) for item in self.list()]