Blame tests/test_progitlibgit.py

Pierre-Yves Chibon a945ba
# -*- coding: utf-8 -*-
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
"""
Pierre-Yves Chibon a945ba
 (c) 2015 - Copyright Red Hat Inc
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
 Authors:
Pierre-Yves Chibon a945ba
   Pierre-Yves Chibon <pingou@pingoured.fr></pingou@pingoured.fr>
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
"""
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
__requires__ = ['SQLAlchemy >= 0.8']
Pierre-Yves Chibon a945ba
import pkg_resources
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
import unittest
Pierre-Yves Chibon a945ba
import shutil
Pierre-Yves Chibon a945ba
import sys
Pierre-Yves Chibon a945ba
import os
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
from mock import patch
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
sys.path.insert(0, os.path.join(os.path.dirname(
Pierre-Yves Chibon a945ba
    os.path.abspath(__file__)), '..'))
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
import progit.lib.git
Pierre-Yves Chibon a945ba
import tests
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
class ProgitLibGittests(tests.Modeltests):
Pierre-Yves Chibon a945ba
    """ Tests for progit.lib.git """
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
    def test_write_gitolite_acls(self):
Pierre-Yves Chibon a945ba
        """ Test the write_gitolite_acls function of progit.lib.git. """
Pierre-Yves Chibon a945ba
        tests.create_projects(self.session)
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
        here = os.path.join(os.path.dirname(os.path.abspath(__file__)))
Pierre-Yves Chibon a945ba
        outputconf = os.path.join(here, 'test_gitolite.conf')
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
        progit.lib.git.write_gitolite_acls(self.session, outputconf)
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
        self.assertTrue(os.path.exists(outputconf))
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
        with open(outputconf) as stream:
Pierre-Yves Chibon a945ba
            data = stream.read()
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
        self.assertEqual(
Pierre-Yves Chibon a945ba
            data,
Pierre-Yves Chibon a945ba
            'repo test\n  R   = @all\n  RW+ = pingou\n\n'
Pierre-Yves Chibon a945ba
            'repo docs/test\n  R   = @all\n  RW+ = pingou\n\n'
Pierre-Yves Chibon a945ba
            'repo tickets/test\n  R   = @all\n  RW+ = pingou\n\n'
Pierre-Yves Chibon a945ba
            'repo test2\n  R   = @all\n  RW+ = pingou\n\n'
Pierre-Yves Chibon a945ba
            'repo docs/test2\n  R   = @all\n  RW+ = pingou\n\n'
Pierre-Yves Chibon a945ba
            'repo tickets/test2\n  R   = @all\n  RW+ = pingou\n\n')
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon 22e4bd
        os.unlink(outputconf)
Pierre-Yves Chibon 22e4bd
        self.assertFalse(os.path.exists(outputconf))
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
Pierre-Yves Chibon a945ba
if __name__ == '__main__':
Pierre-Yves Chibon a945ba
    SUITE = unittest.TestLoader().loadTestsFromTestCase(ProgitLibGittests)
Pierre-Yves Chibon a945ba
    unittest.TextTestRunner(verbosity=2).run(SUITE)