Esempio n. 1
0
 def test_matches(self, tmpdir):
     filename = "aardvark-4-reporting-for-duty.txt"
     tmpdir.mkdir("tmp").join(filename).write("###")
     f = File(join(str(tmpdir), filename))
     e = Entity('avaricious', 'aardvark-(\d+)')
     result = e.match_file(f)
     assert result == '4'
Esempio n. 2
0
 def test_matches(self, tmpdir):
     filename = "aardvark-4-reporting-for-duty.txt"
     tmpdir.mkdir("tmp").join(filename).write("###")
     f = File(os.path.join(str(tmpdir), filename))
     e = Entity('avaricious', 'aardvark-(\d+)')
     e.matches(f)
     assert 'avaricious' in f.entities
     assert f.entities['avaricious'] == '4'
Esempio n. 3
0
 def test_init(self):
     e = Entity('avaricious', 'aardvark-(\d+)')
     assert e.name == 'avaricious'
     assert e.pattern == 'aardvark-(\d+)'
     assert not e.mandatory
     assert e.directory is None
     assert e.files == {}
Esempio n. 4
0
 def test_unique_and_count(self):
     e = Entity('prop', '-(\d+)')
     e.files = {
         'test1-10.txt': '10',
         'test2-7.txt': '7',
         'test3-7.txt': '7'
     }
     assert sorted(e.unique()) == ['10', '7']
     assert e.count() == 2
     assert e.count(files=True) == 3
Esempio n. 5
0
 def test_add_file(self):
     e = Entity('prop', '-(\d+)')
     e.add_file('a', '1')
     assert e.files['a'] == '1'