Skip to content
This repository was archived by the owner on Nov 22, 2020. It is now read-only.

Commit 4d65649

Browse files
committed
Add a test for Issue LibraryOfCongress#75
1 parent 7684c79 commit 4d65649

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test.py

+33
Original file line numberDiff line numberDiff line change
@@ -570,5 +570,38 @@ def test_unicode_in_tags(self):
570570
bag = bagit.Bag(self.tmpdir)
571571
self.assertEqual(bag.info['test'], '♡')
572572

573+
574+
class TestTagFiles(unittest.TestCase):
575+
"""Test Issue #75: The selection of tag files is thoroughly broken.
576+
"""
577+
578+
def setUp(self):
579+
self.tmpdir = tempfile.mkdtemp()
580+
if os.path.isdir(self.tmpdir):
581+
shutil.rmtree(self.tmpdir)
582+
self.bagdir = j(self.tmpdir, 'test-data')
583+
shutil.copytree('test-data', self.bagdir)
584+
585+
def tearDown(self):
586+
if os.path.isdir(self.tmpdir):
587+
shutil.rmtree(self.tmpdir)
588+
589+
def test_make_bag(self):
590+
info = {'Bagging-Date': '1970-01-01', 'Contact-Email': '[email protected]'}
591+
bagit.make_bag(self.bagdir, bag_info=info)
592+
593+
# data dir should've been created
594+
self.assertTrue(os.path.isdir(j(self.bagdir, 'data')))
595+
596+
# check tagmanifest-md5.txt
597+
self.assertTrue(os.path.isfile(j(self.bagdir, 'tagmanifest-md5.txt')))
598+
with open(j(self.bagdir, 'tagmanifest-md5.txt'), 'rt') as tm:
599+
tagmanifest_txt = tm.readlines()
600+
self.assertTrue('9e5ad981e0d29adc278f6a294b8c2aca bagit.txt\n' in tagmanifest_txt)
601+
self.assertTrue('a0ce6631a2a6d1a88e6d38453ccc72a5 manifest-md5.txt\n' in tagmanifest_txt)
602+
self.assertTrue('bfe59ad8af1a227d27c191b4178c399f bag-info.txt\n' in tagmanifest_txt)
603+
self.assertEqual(len(tagmanifest_txt), 3)
604+
605+
573606
if __name__ == '__main__':
574607
unittest.main()

0 commit comments

Comments
 (0)