示例#1
0
    def test_list_installs(self):
        OUT.color_off()
        db = WebappDB(root = '/'.join((HERE, 'testfiles', 'webapps')))

        db.listinstalls()
        output = sys.stdout.getvalue().split('\n')
        self.assertEqual(output[1], '/var/www/localhost/htdocs/horde')

        # Now test the verbosity:
        db = WebappDB(root = '/'.join((HERE, 'testfiles', 'webapps')),
                      verbose = True)
        db.listinstalls()
        output = sys.stdout.getvalue().split('\n')
        self.assertEqual(output[5], '* Installs for horde-3.0.5')
示例#2
0
    def test_add_rm(self):
        OUT.color_off()
        db = WebappDB(root = '/'.join((HERE, 'testfiles', 'webapps')),
                      pretend = True, package = 'horde', version = '3.0.5')
        # Test adding:
        db.add('/'.join(('/screwy', 'wonky', 'foobar', 'horde', 'hierarchy')),
               user = '******', group = 'me')
        output = sys.stdout.getvalue().split('\n')
        self.assertEqual(output[0], '* Pretended to append installation '\
                                    '/screwy/wonky/foobar/horde/hierarchy')

        # Test deleting a webapp that is actually in the database:
        db.remove('/'.join(('/var', 'www', 'localhost', 'htdocs', 'horde')))
        output = sys.stdout.getvalue().split('\n')
        self.assertEqual(output[6], '* ')

        # And now test deleting one that isn't:
        db.remove('/'.join(('/screwy', 'wonky', 'foobar', 'horde', 'hierarchy')))
        output = sys.stdout.getvalue().split('\n')
        self.assertEqual(output[11], '* 1124612110 root root '\
                                     '/var/www/localhost/htdocs/horde')
示例#3
0
    def test_list_locations(self):
        OUT.color_off()
        db = WebappDB(root = '/'.join((HERE, 'testfiles', 'webapps')))

        sorted_db = [i[1] for i in db.list_locations().items()]
        sorted_db.sort(key=lambda x: x[0]+x[1]+x[2])

        self.assertEqual(sorted_db[1], ['', 'gallery', '2.0_rc2'])

        # Now test with a specific package and version:
        db = WebappDB(root = '/'.join((HERE, 'testfiles', 'webapps')),
                      package = 'horde', version = '3.0.5')
        sorted_db = [i[1] for i in db.list_locations().items()]
        self.assertEqual(sorted_db, [['', 'horde', '3.0.5']])

        # Now test with an install file that doesn't exist:
        db = WebappDB(root = '/'.join((HERE, 'testfiles', 'webapps')),
                      package = 'nihil', version = '3.0.5')
        sorted_db = [i[1] for i in db.list_locations().items()]
        self.assertEqual(sorted_db, [])