Beispiel #1
0
 def test_default_action(self):
     rule_set = FileRuleSet()
     rule_set.add_rule_by_string("exclude: size > 1024000")
     self.assertEqual(rule_set.test(self.file_entry),
                      rule_set.default_action)
     rule_set = FileRuleSet(default_action="laf")
     rule_set.add_rule_by_string("exclude: size > 1024000")
     self.assertEqual(rule_set.test(self.file_entry), "laf")
Beispiel #2
0
 def test_walk_tree_with_rule(self):
     clear_folder(self.directory_path)
     prepare_filetree(self.directory_path, '''
         ignore/b/c:1
         ignore/bb:2
         include/d/e: 3
         include/dd: 4
         whatever_file: 5
     ''')
     rule_set = FileRuleSet()
     rule_set.add_rule_by_string("ignore: name eq ignore")
     filetree = FileTree.from_fs(self.directory_path, rule_set=rule_set)
     self.assertEqual(len(filetree.files()), 3)
     self.assertEqual(len(filetree.folders()), 2)
Beispiel #3
0
 def test_default_action(self):
     rule_set = FileRuleSet()
     rule_set.add_rule_by_string("exclude: size > 1024000")
     self.assertEqual(rule_set.test(self.file_entry), rule_set.default_action)
     rule_set = FileRuleSet(default_action="laf")
     rule_set.add_rule_by_string("exclude: size > 1024000")
     self.assertEqual(rule_set.test(self.file_entry), "laf")
Beispiel #4
0
 def test_walk_tree_with_rule(self):
     clear_folder(self.directory_path)
     prepare_filetree(
         self.directory_path, '''
         ignore/b/c:1
         ignore/bb:2
         include/d/e: 3
         include/dd: 4
         whatever_file: 5
     ''')
     rule_set = FileRuleSet()
     rule_set.add_rule_by_string("ignore: name eq ignore")
     filetree = FileTree.from_fs(self.directory_path, rule_set=rule_set)
     self.assertEqual(len(filetree.files()), 3)
     self.assertEqual(len(filetree.folders()), 2)
Beispiel #5
0
 def test_eq(self):
     tmp = self.file_entry.pathname
     f = FileRuleSet.parse("exclude: name eq .git")
     self.file_entry.pathname = ".gitignore"
     self.assertEqual(f.test(self.file_entry), None)
     self.file_entry.pathname = tmp
Beispiel #6
0
 def test_match_pattern(self):
     f = FileRuleSet.parse("exclude: name match *_not_sync")
     self.assertEqual(f.action, "exclude")
     self.assertEqual(f.attr, "name")
     self.assertEqual(f.op, "match")
     self.assertEqual(f.value, "*_not_sync")
Beispiel #7
0
 def test_parse_with_action(self):
     f = FileRuleSet.parse("size > 1024", "exclude")
     self.assertEqual(f.action, "exclude")
     self.assertEqual(f.attr, "size")
     self.assertEqual(f.op, "gt")
     self.assertEqual(f.value, 1024)
Beispiel #8
0
 def test_basic_parse_with_quotes(self):
     rule_set = FileRuleSet()
     rule_set.add_rule_by_string("size > '1024'", "include")
     rule_set.add_rule_by_string("path = \""+self.file_entry.pathname+"\"",
                                 "exclude")
     self.assertEqual(rule_set.test(self.file_entry), "exclude")
Beispiel #9
0
 def test_basic_parse(self):
     rule_set = FileRuleSet()
     rule_set.add_rule_by_string("size > 1024", "include")
     rule_set.add_rule_by_string("path = "+self.file_entry.pathname,
                                 "exclude")
     self.assertEqual(rule_set.test(self.file_entry), "exclude")
Beispiel #10
0
 def test_basic(self):
     rule_set = FileRuleSet()
     rule_set.add("size", ">", 1024, "include")
     rule_set.add("path", "eq", self.file_entry.pathname, "exclude")
     self.assertEqual(rule_set.test(self.file_entry), "exclude")
Beispiel #11
0
 def test_eq(self):
     tmp = self.file_entry.pathname
     f = FileRuleSet.parse("exclude: name eq .git")
     self.file_entry.pathname = ".gitignore"
     self.assertEqual(f.test(self.file_entry), None)
     self.file_entry.pathname = tmp
Beispiel #12
0
 def test_match_pattern(self):
     f = FileRuleSet.parse("exclude: name match *_not_sync")
     self.assertEqual(f.action, "exclude")
     self.assertEqual(f.attr, "name")
     self.assertEqual(f.op, "match")
     self.assertEqual(f.value, "*_not_sync")
Beispiel #13
0
 def test_parse_with_action(self):
     f = FileRuleSet.parse("size > 1024", "exclude")
     self.assertEqual(f.action, "exclude")
     self.assertEqual(f.attr, "size")
     self.assertEqual(f.op, "gt")
     self.assertEqual(f.value, 1024)
Beispiel #14
0
 def test_basic_parse_with_quotes(self):
     rule_set = FileRuleSet()
     rule_set.add_rule_by_string("size > '1024'", "include")
     rule_set.add_rule_by_string(
         "path = \"" + self.file_entry.pathname + "\"", "exclude")
     self.assertEqual(rule_set.test(self.file_entry), "exclude")
Beispiel #15
0
 def test_basic_parse(self):
     rule_set = FileRuleSet()
     rule_set.add_rule_by_string("size > 1024", "include")
     rule_set.add_rule_by_string("path = " + self.file_entry.pathname,
                                 "exclude")
     self.assertEqual(rule_set.test(self.file_entry), "exclude")
Beispiel #16
0
 def test_basic(self):
     rule_set = FileRuleSet()
     rule_set.add("size", ">", 1024, "include")
     rule_set.add("path", "eq", self.file_entry.pathname, "exclude")
     self.assertEqual(rule_set.test(self.file_entry), "exclude")