Exemplo n.º 1
0
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()
Exemplo n.º 2
0
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()
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
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()
Exemplo n.º 5
0
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()
Exemplo n.º 6
0
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()
Exemplo n.º 7
0
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()
Exemplo n.º 8
0
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()