Exemple #1
0
class TestNewFileHandler(unittest.TestCase):
    def setUp(self):
        def here(appname):
            return os.path.join(os.path.dirname(__file__), 'test_data')

        with patch.object(gitenberg.config.appdirs, 'user_config_dir',
                          here) as path:
            with patch('github3.login') as login:
                self.login = login
                self.book = Book(1234)
        self.book.local_repo = LocalRepo(
            os.path.join(os.path.dirname(__file__), 'test_data/1234'))
        self.book.parse_book_metadata()
        self.file_maker = NewFilesHandler(self.book)

    def test_crypto(self):
        self.book.github_repo._repo_token = 'fake_repo_token'
        self.book.github_repo._travis_repo_public_key = mock_travis_response[
            'key']

        key = self.book.github_repo.travis_key()
        self.assertTrue(len(key) == 684)

    def tearDown(self):
        pass
Exemple #2
0
class TestNewFileHandler(unittest.TestCase):
    def setUp(self):
        def here(appname):
            return os.path.join(os.path.dirname(__file__), 'test_data')

        with patch.object(gitenberg.config.appdirs, 'user_config_dir',
                          here) as path:
            with patch('github3.login') as login:
                self.login = login
                self.book = Book(1234)
        self.book.local_path = os.path.join(os.path.dirname(__file__),
                                            'test_data/1234')
        self.book.local_repo = LocalRepo(self.book.local_path)
        self.book.parse_book_metadata()
        self.file_maker = NewFilesHandler(self.book)

    def test_readme(self):
        self.file_maker.template_readme()
        self.assertTrue(
            os.path.exists(
                os.path.join(os.path.dirname(__file__),
                             'test_data/1234/README.rst')))

    @patch.object(LocalRepo, 'travis_key', new='fake_travis_key')
    def test_travis_files(self):
        #LocalRepo.travis_key = 'fake_travis_key'
        self.file_maker.travis_files()
        self.assertTrue(
            os.path.exists(
                os.path.join(os.path.dirname(__file__),
                             'test_data/1234/.travis.yml')))
        self.assertTrue(
            os.path.exists(
                os.path.join(os.path.dirname(__file__),
                             'test_data/1234/.travis.deploy.api_key.txt')))

    def tearDown(self):
        if os.path.exists(
                os.path.join(os.path.dirname(__file__),
                             'test_data/1234/.git')):
            shutil.rmtree(
                os.path.join(os.path.dirname(__file__), 'test_data/1234/.git'))
        if os.path.exists(
                os.path.join(os.path.dirname(__file__),
                             'test_data/1234/README.rst')):
            os.remove(
                os.path.join(os.path.dirname(__file__),
                             'test_data/1234/README.rst'))
        if os.path.exists(
                os.path.join(os.path.dirname(__file__),
                             'test_data/1234/.travis.yml')):
            os.remove(
                os.path.join(os.path.dirname(__file__),
                             'test_data/1234/.travis.yml'))
        if os.path.exists(
                os.path.join(os.path.dirname(__file__),
                             'test_data/1234/.travis.deploy.api_key.txt')):
            os.remove(
                os.path.join(os.path.dirname(__file__),
                             'test_data/1234/.travis.deploy.api_key.txt'))
Exemple #3
0
class TestNewFileHandler(unittest.TestCase):

    def setUp(self):
        def here(appname):
            return os.path.join(os.path.dirname(__file__),'test_data')
        with patch.object(gitenberg.config.appdirs, 'user_config_dir', here) as path:
            with patch('github3.login') as login:
                self.login = login
                self.book = Book(1234)
        self.book.local_path = os.path.join(os.path.dirname(__file__),'test_data/1234')
        self.book.local_repo = LocalRepo(self.book.local_path)
        self.book.parse_book_metadata()
        self.file_maker = NewFilesHandler(self.book)

    def test_readme(self):
        self.file_maker.template_readme()
        self.assertTrue(
            os.path.exists(os.path.join(os.path.dirname(__file__),'test_data/1234/README.rst'))
        )
    
    def tearDown(self):
        if os.path.exists(os.path.join(os.path.dirname(__file__),'test_data/1234/.git')):
            shutil.rmtree(os.path.join(os.path.dirname(__file__),'test_data/1234/.git'))
        if os.path.exists(os.path.join(os.path.dirname(__file__),'test_data/1234/README.rst')):
            os.remove(os.path.join(os.path.dirname(__file__),'test_data/1234/README.rst'))
Exemple #4
0
class TestNewFileHandler(unittest.TestCase):

    def setUp(self):
        def here(appname):
            return os.path.join(os.path.dirname(__file__),'test_data')
        with patch.object(gitenberg.config.appdirs, 'user_config_dir', here) as path:
            with patch('github3.login') as login:
                self.login = login
                self.book = Book(1234)
        self.book.local_repo = LocalRepo(os.path.join(os.path.dirname(__file__),'test_data/1234'))
        self.book.parse_book_metadata()
        self.file_maker = NewFilesHandler(self.book)

    def tearDown(self):
        pass
Exemple #5
0
class TestNewFileHandler(unittest.TestCase):
    def setUp(self):
        def here(appname):
            return os.path.join(os.path.dirname(__file__), 'test_data')

        with patch.object(gitenberg.config.appdirs, 'user_config_dir',
                          here) as path:
            with patch('github3.login') as login:
                self.login = login
                self.book = Book(1234)
        self.book.local_repo = LocalRepo(
            os.path.join(os.path.dirname(__file__), 'test_data/1234'))
        self.book.parse_book_metadata()
        self.file_maker = NewFilesHandler(self.book)

    def tearDown(self):
        pass