def test_add(self): loc = '/'.join((HERE, 'testfiles', 'contents', 'app')) contents = Contents(loc, package='test', version='1.0') OUT.color_off() contents.add('file', 'config_owned', destination=loc, path='/test1', real_path=loc + '/test1', relative=True) # Now trigger an error by adding a file that doesn't exist! contents.add('file', 'config_owned', destination=loc, path='/test0', real_path=loc + '/test0', relative=True) output = sys.stdout.getvalue().strip('\n') self.assertTrue('WebappConfig/tests/testfiles/contents/app/test0 to '\ 'add it as installation content. This should not '\ 'happen!' in output) # Test adding hardlinks: contents.add('hardlink', 'config_owned', destination=loc, path='/test2', real_path=loc + '/test2', relative=True) self.assertTrue( 'file 1 config_owned "test2" ' in contents.entry(loc + '/test2')) # Test adding dirs: contents.add('dir', 'default_owned', destination=loc, path='/dir1', real_path=loc + '/dir1', relative=True) self.assertTrue( 'dir 1 default_owned "dir1" ' in contents.entry(loc + '/dir1')) # Test adding symlinks: contents.add('sym', 'virtual', destination=loc, path='/test3', real_path=loc + '/test3', relative=True) self.assertTrue('sym 1 virtual "test3" ' in contents.entry(loc + '/test3')) # Printing out the db after adding these entries: contents.db_print() output = sys.stdout.getvalue().split('\n') self.assertTrue('file 1 config_owned "test1" ' in output[1])
def test_add_pretend(self): loc = '/'.join((HERE, 'testfiles', 'contents', 'app')) contents = Contents(loc, package = 'test', version = '1.0', pretend = True) OUT.color_off() contents.add('file', 'config_owned', destination = loc, path = '/test1', real_path = loc + '/test1', relative = True) output = sys.stdout.getvalue().strip('\n') self.assertEqual(output, '* pretending to add: file 1 config_owned "test1"')
def test_add_pretend(self): loc = '/'.join((HERE, 'testfiles', 'contents', 'app')) contents = Contents(loc, package='test', version='1.0', pretend=True) OUT.color_off() contents.add('file', 'config_owned', destination=loc, path='/test1', real_path=loc + '/test1', relative=True) output = sys.stdout.getvalue().strip('\n') self.assertEqual( output, '* pretending to add: file 1 config_owned "test1"')
def test_add(self): loc = '/'.join((HERE, 'testfiles', 'contents', 'app')) contents = Contents(loc, package = 'test', version = '1.0') OUT.color_off() contents.add('file', 'config_owned', destination = loc, path = '/test1', real_path = loc + '/test1', relative = True) # Now trigger an error by adding a file that doesn't exist! contents.add('file', 'config_owned', destination = loc, path = '/test0', real_path = loc + '/test0', relative = True) output = sys.stdout.getvalue().strip('\n') self.assertTrue('WebappConfig/tests/testfiles/contents/app/test0 to '\ 'add it as installation content. This should not '\ 'happen!' in output) # Test adding hardlinks: contents.add('hardlink', 'config_owned', destination = loc, path = '/test2', real_path = loc + '/test2', relative = True) self.assertTrue('file 1 config_owned "test2" ' in contents.entry(loc + '/test2')) # Test adding dirs: contents.add('dir', 'default_owned', destination = loc, path = '/dir1', real_path = loc + '/dir1', relative = True) self.assertTrue('dir 1 default_owned "dir1" ' in contents.entry(loc + '/dir1')) # Test adding symlinks: contents.add('sym', 'virtual', destination = loc, path = '/test3', real_path = loc + '/test3', relative = True) self.assertTrue('sym 1 virtual "test3" ' in contents.entry(loc + '/test3')) # Printing out the db after adding these entries: contents.db_print() output = sys.stdout.getvalue().split('\n') self.assertTrue('file 1 config_owned "test1" ' in output[1])