class TestLocalRepo(unittest.TestCase): def setUp(self): library_path = "./test/library" self.book = Book(13529, library_path=library_path) # TODO: Mock fetch_remote_book_to_local_path to # copy test_data/sea_ppwer to 13529 def copy_test_book(): # FIXME: use filesystem for this, cp fails silently? sh.cp("./gitenberg/tests/test_data/13529", library_path) self.book.fetch_remote_book_to_local_path = copy_test_book self.book.fetch() def test_init(self): l_r = LocalRepo(self.book) self.assertEqual(l_r.book, self.book) def test_init_repo(self): l_r = LocalRepo(self.book) l_r.add_all_files() self.assertTrue(os.path.exists("./test/library/13529/.git")) def tearDown(self): self.book.remove()
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'))
class TestLocalRepo(unittest.TestCase): def setUp(self): library_path = './test/library' self.book = Book(13529, library_path=library_path) # TODO: Mock fetch_remote_book_to_local_path to # copy test_data/sea_ppwer to 13529 def copy_test_book(): sh.cp('./gitenberg/test_data/13529', library_path) self.book.fetch_remote_book_to_local_path = copy_test_book self.book.fetch() def test_init(self): l_r = LocalRepo(self.book) self.assertEqual( l_r.book, self.book ) def test_init_repo(self): l_r = LocalRepo(self.book) l_r.add_all_files() self.assertTrue( os.path.exists('./test/library/13529/.git') ) def tearDown(self): self.book.remove()
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
class TestLocalRepo(unittest.TestCase): def setUp(self): self.book = Book(13529) # TODO: Mock fetch_remote_book_to_local_path to # copy test_data/sea_ppwer to 13529 def copy_test_book(): # FIXME: use filesystem for this, cp fails silently? sh.cp('./gitenberg/tests/test_data/1234', library_path) self.book.fetch_remote_book_to_local_path = copy_test_book self.book.fetch() def test_init(self): l_r = LocalRepo(self.book) self.assertEqual( l_r.book, self.book ) def test_init_repo(self): l_r = LocalRepo(self.book) l_r.add_all_files() self.assertTrue( os.path.exists(config.data['library_path']+'/13529/.git') ) def tearDown(self): self.book.remove()
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'))
class TestBookPath(unittest.TestCase): def setUp(self): self.test_book_dir = 'test_book' 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) def test_remote_path(self): self.assertEqual(self.book.remote_path, "1/2/3/1234/") def test_local_path(self): self.assertTrue(self.book.local_path.endswith("/1234")) def test_remote_path_below_ten(self): with patch('github3.login'): self.book = Book(7) self.assertEqual(self.book.remote_path, "7/") @patch('os.makedirs') @patch('os.chmod') def test_make_local_path(self, mock_chmod, mock_makedirs): self.book.set_existing_local_path(self.test_book_dir) mock_makedirs.assert_called_once() mock_chmod.assert_called_once()
def setUp(self): self.test_book_dir = 'test_book' 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)
def setUp(self): self.book = Book(13529) # TODO: Mock fetch_remote_book_to_local_path to # copy test_data/sea_ppwer to 13529 def copy_test_book(): # FIXME: use filesystem for this, cp fails silently? sh.cp('./gitenberg/tests/test_data/1234', library_path) self.book.fetch_remote_book_to_local_path = copy_test_book self.book.fetch()
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)
class TestNewFileHandler(): def setUp(self): self.book = Book(333, library_path='./test/library') self.book.fetch() self.file_handler = NewFilesHandler(self.book) def test_readme(self): self.file_handler.template_readme() self.assertTrue( os.path.exists('./test/library/333/README.rst') ) def tearDown(self): self.book.remove()
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
class TestNewFileHandler(): def setUp(self): self.book = Book(333, library_path='./test/library') self.book.fetch_remote_book_to_local_path = null self.book.fetch() self.file_handler = NewFilesHandler(self.book) def test_readme(self): self.file_handler.template_readme() self.assertTrue( os.path.exists('./test/library/333/README.rst') ) def tearDown(self): self.book.remove()
class TestBookFetcher(unittest.TestCase): def setUp(self): self.book = Book(1283, library_path='./test/library') self.fetcher = BookFetcher(self.book) def test_make_local_path(self): # creates a folder in the specified test dir self.fetcher.make_local_path() self.assertTrue(os.path.exists('./test/library/1283')) def test_remote_fetch(self): self.fetcher.fetch_remote_book_to_local_path() self.assertTrue(os.path.exists('./test/library/1283/1283.txt')) def tearDown(self): self.book.remove()
def setUp(self): library_path = './test/library' self.book = Book(13529, library_path=library_path) # TODO: Mock fetch_remote_book_to_local_path to # copy test_data/sea_ppwer to 13529 def copy_test_book(): sh.cp('./gitenberg/test_data/13529', library_path) self.book.fetch_remote_book_to_local_path = copy_test_book self.book.fetch()
class TestLocalRepo(unittest.TestCase): def setUp(self): self.book = Book(333, library_path='./test/library') self.book.fetch() def test_init(self): l_r = LocalRepo(self.book) self.assertEqual( l_r.book, self.book ) def test_init_repo(self): l_r = LocalRepo(self.book) l_r.add_all_files() self.assertTrue( os.path.exists('./test/library/333/.git') ) def tearDown(self): self.book.remove()
def setUp(self): book = Book(1234) self.rdf_library = config.data['rdf_library'] self.meta = BookMetadata(book, rdf_library=self.rdf_library)
def setUp(self): self.book = Book(7)
def setUp(self): self.book = Book(3456)
def setUp(self): self.book = Book(333, library_path='./test/library') self.book.fetch() self.file_handler = NewFilesHandler(self.book)
def setUp(self): self.book = Book(333, library_path='./test/library') self.book.fetch_remote_book_to_local_path = null self.book.fetch() self.file_handler = NewFilesHandler(self.book)
def test_remote_path_below_ten(self): with patch('github3.login'): self.book = Book(7) self.assertEqual(self.book.remote_path, "7/")
def setUp(self): self.book = Book(1283, library_path='./test/library') self.fetcher = BookFetcher(self.book)
def setUp(self): self.book = Book(1283) self.fetcher = BookFetcher(self.book)
def setUp(self): book = Book(1234) self.meta = BookMetadata(book)
def setUp(self): self.book = Book(333, library_path='./test/library') self.book.fetch()