Ejemplo n.º 1
0
Archivo: test.py Proyecto: edsu/dflat
 def test_export(self):
     home = 'dflat-test'
     dflat.init(home)
     # create v002
     dflat.checkout(home)
     with open('dflat-test/v002/full/producer/reddspec.html', 'a') as f1:
         f1.write('mod')
     # commit v002
     dflat.commit(home)
     # create v003
     dflat.checkout(home)
     with open('dflat-test/v003/full/producer/new file.txt', 'w') as f2:
         f2.write('new file')
     # commit v003
     dflat.commit(home)
     # create v004
     dflat.checkout(home)
     remove('dflat-test/v004/full/producer/dflatspec.pdf')
     # commit v004
     dflat.commit(home)
     # create v005
     dflat.checkout(home)
     # commit v005
     dflat.commit(home)
     # export an invalid version
     self.assertRaises(Exception, dflat.export, home, 'v000') 
     # export v004 and check it
     dflat.export(home, "v004")
     self.assertTrue(isdir('dflat-test/export-v004'))
     self.assertFalse(isfile('dflat-test/export-v004/full/producer/dflatspec.pdf'))
     with open('dflat-test/export-v004/full/producer/reddspec.html') as f3:
         with open('dflat-test/v005/full/producer/reddspec.html') as f4:
             self.assertEqual(f3.read(), f4.read())
     # export v003 and check it
     dflat.export(home, "v003")
     self.assertTrue(isdir('dflat-test/export-v003'))
     self.assertTrue(isfile('dflat-test/export-v003/full/producer/new file.txt'))
     self.assertTrue(isfile('dflat-test/export-v003/full/producer/dflatspec.pdf'))
     with open('dflat-test/export-v003/full/producer/reddspec.html') as f5:
         with open('dflat-test/v005/full/producer/reddspec.html') as f6:
             self.assertEqual(f5.read(), f6.read())
     # export v002 and check it
     dflat.export(home, "v002")
     self.assertTrue(isdir('dflat-test/export-v002'))
     self.assertFalse(isfile('dflat-test/export-v002/full/producer/new file.txt'))
     self.assertTrue(isfile('dflat-test/export-v002/full/producer/dflatspec.pdf'))
     self.assertFileEqual('dflat-test/export-v002/full/producer/reddspec.html',
                          'dflat-test/v005/full/producer/reddspec.html')
     # export v001 and check it
     dflat.export(home, "v001")
     self.assertTrue(isdir('dflat-test/export-v001'))
     self.assertFalse(isfile('dflat-test/export-v001/full/producer/new file.txt'))
     self.assertTrue(isfile('dflat-test/export-v001/full/producer/dflatspec.pdf'))
     with open('dflat-test/export-v001/full/producer/reddspec.html') as f7:
         with open('dflat-test/v005/full/producer/reddspec.html') as f8:
             self.assertNotEqual(f7.read(), f8.read())
Ejemplo n.º 2
0
 def test_export(self):
     home = 'dflat-test'
     dflat.init(home)
     # create v002
     dflat.checkout(home)
     open('dflat-test/v002/full/data/reddspec.html', 'a').write('mod')
     # commit v002
     dflat.commit(home)
     # create v003
     dflat.checkout(home)
     open('dflat-test/v003/full/data/new file.txt', 'w').write('new file')
     # commit v003
     dflat.commit(home)
     # create v004
     dflat.checkout(home)
     remove('dflat-test/v004/full/data/dflatspec.pdf')
     # commit v004
     dflat.commit(home)
     # create v005
     dflat.checkout(home)
     # commit v005
     dflat.commit(home)
     # export an invalid version
     self.assertRaises(Exception, dflat.export, home, 'v000') 
     # export v004 and check it
     dflat.export(home, "v004")
     self.assertTrue(isdir('dflat-test/export-v004'))
     self.assertFalse(isfile('dflat-test/export-v004/full/data/dflatspec.pdf'))
     self.assertEqual(open('dflat-test/export-v004/full/data/reddspec.html').read(), 
                      open('dflat-test/v005/full/data/reddspec.html').read())
     # export v003 and check it
     dflat.export(home, "v003")
     self.assertTrue(isdir('dflat-test/export-v003'))
     self.assertTrue(isfile('dflat-test/export-v003/full/data/new file.txt'))
     self.assertTrue(isfile('dflat-test/export-v003/full/data/dflatspec.pdf'))
     self.assertEqual(open('dflat-test/export-v003/full/data/reddspec.html').read(), 
                      open('dflat-test/v005/full/data/reddspec.html').read())
     # export v002 and check it
     dflat.export(home, "v002")
     self.assertTrue(isdir('dflat-test/export-v002'))
     self.assertFalse(isfile('dflat-test/export-v002/full/data/new file.txt'))
     self.assertTrue(isfile('dflat-test/export-v002/full/data/dflatspec.pdf'))
     self.assertFileEqual('dflat-test/export-v002/full/data/reddspec.html',
                          'dflat-test/v005/full/data/reddspec.html')
     # export v001 and check it
     dflat.export(home, "v001")
     self.assertTrue(isdir('dflat-test/export-v001'))
     self.assertFalse(isfile('dflat-test/export-v001/full/data/new file.txt'))
     self.assertTrue(isfile('dflat-test/export-v001/full/data/dflatspec.pdf'))
     self.assertNotEqual(open('dflat-test/export-v001/full/data/reddspec.html').read(), 
                      open('dflat-test/v005/full/data/reddspec.html').read())
Ejemplo n.º 3
0
 def test_commit(self):
     dflat.init('dflat-test')
     dflat.checkout('dflat-test')
     self.assertEqual(dflat._current_version('dflat-test'), 'v001')
     open('dflat-test/v002/full/producer/reddspec.html', 'a').write('mod')
     open('dflat-test/v002/full/producer/new file.txt', 'w').write('new file')
     remove('dflat-test/v002/full/producer/dflatspec.pdf')
     delta = dflat.commit('dflat-test')
     self.assertTrue('producer/reddspec.html' in delta['modified'])
     self.assertTrue('producer/new file.txt' in delta['added'])
     self.assertTrue('producer/dflatspec.pdf' in delta['deleted'])
     self.assertTrue(isdir('dflat-test/v001/delta'))
     self.assertTrue(isfile('dflat-test/v001/manifest.txt'))
     self.assertTrue(isfile('dflat-test/v001/d-manifest.txt'))
     self.assertEqual(dflat._current_version('dflat-test'), 'v002')
Ejemplo n.º 4
0
 def test_commit(self):
     dflat.init('dflat-test')
     dflat.checkout('dflat-test')
     self.assertEqual(dflat._current_version('dflat-test'), 'v001')
     with open('dflat-test/v002/full/producer/reddspec.html', 'a') as f1:
         f1.write('mod')
     with open('dflat-test/v002/full/producer/new file.txt', 'w') as f2:
         f2.write('new file')
     remove('dflat-test/v002/full/producer/dflatspec.pdf')
     delta = dflat.commit('dflat-test')
     self.assertTrue('producer/reddspec.html' in delta['modified'])
     self.assertTrue('producer/new file.txt' in delta['added'])
     self.assertTrue('producer/dflatspec.pdf' in delta['deleted'])
     self.assertTrue(isdir('dflat-test/v001/delta'))
     self.assertTrue(isfile('dflat-test/v001/manifest.txt'))
     self.assertTrue(isfile('dflat-test/v001/d-manifest.txt'))
     self.assertEqual(dflat._current_version('dflat-test'), 'v002')
Ejemplo n.º 5
0
 def test_export(self):
     home = 'dflat-test'
     dflat.init(home)
     # create v002
     dflat.checkout(home)
     with open('dflat-test/v002/full/producer/reddspec.html', 'a') as f1:
         f1.write('mod')
     # commit v002
     dflat.commit(home)
     # create v003
     dflat.checkout(home)
     with open('dflat-test/v003/full/producer/new file.txt', 'w') as f2:
         f2.write('new file')
     # commit v003
     dflat.commit(home)
     # create v004
     dflat.checkout(home)
     remove('dflat-test/v004/full/producer/dflatspec.pdf')
     # commit v004
     dflat.commit(home)
     # create v005
     dflat.checkout(home)
     # commit v005
     dflat.commit(home)
     # export an invalid version
     self.assertRaises(Exception, dflat.export, home, 'v000')
     # export v004 and check it
     dflat.export(home, "v004")
     self.assertTrue(isdir('dflat-test/export-v004'))
     self.assertFalse(
         isfile('dflat-test/export-v004/full/producer/dflatspec.pdf'))
     with open('dflat-test/export-v004/full/producer/reddspec.html') as f3:
         with open('dflat-test/v005/full/producer/reddspec.html') as f4:
             self.assertEqual(f3.read(), f4.read())
     # export v003 and check it
     dflat.export(home, "v003")
     self.assertTrue(isdir('dflat-test/export-v003'))
     self.assertTrue(
         isfile('dflat-test/export-v003/full/producer/new file.txt'))
     self.assertTrue(
         isfile('dflat-test/export-v003/full/producer/dflatspec.pdf'))
     with open('dflat-test/export-v003/full/producer/reddspec.html') as f5:
         with open('dflat-test/v005/full/producer/reddspec.html') as f6:
             self.assertEqual(f5.read(), f6.read())
     # export v002 and check it
     dflat.export(home, "v002")
     self.assertTrue(isdir('dflat-test/export-v002'))
     self.assertFalse(
         isfile('dflat-test/export-v002/full/producer/new file.txt'))
     self.assertTrue(
         isfile('dflat-test/export-v002/full/producer/dflatspec.pdf'))
     self.assertFileEqual(
         'dflat-test/export-v002/full/producer/reddspec.html',
         'dflat-test/v005/full/producer/reddspec.html')
     # export v001 and check it
     dflat.export(home, "v001")
     self.assertTrue(isdir('dflat-test/export-v001'))
     self.assertFalse(
         isfile('dflat-test/export-v001/full/producer/new file.txt'))
     self.assertTrue(
         isfile('dflat-test/export-v001/full/producer/dflatspec.pdf'))
     with open('dflat-test/export-v001/full/producer/reddspec.html') as f7:
         with open('dflat-test/v005/full/producer/reddspec.html') as f8:
             self.assertNotEqual(f7.read(), f8.read())