Beispiel #1
0
class TestBookFetcher(unittest.TestCase):
    def setUp(self):
        # self.book = Book(1283)
        self.test_book_dir = './gitenberg/tests/test_data/test_book'
        self.remote_path = '1234/1234.txt'
        mock_book = MagicMock()
        mock_book.local_path = self.test_book_dir
        mock_book.remote_path = self.remote_path
        self.fetcher = BookFetcher(mock_book)

    @patch('os.makedirs')
    @patch('os.chmod')
    def test_make_local_path(self, mock_chmod, mock_makedirs):
        self.fetcher.make_local_path()
        mock_makedirs.assert_called_once_with(self.test_book_dir)
        mock_chmod.assert_called_once_with(self.test_book_dir, 0o777)

    @patch('sh.rsync')
    def test_remote_fetch(self, mock_rsync):
        self.fetcher.fetch_remote_book_to_local_path()
        mock_rsync.assert_called_once_with(
            '-rvhz',
            '[email protected]::gutenberg/1234/1234.txt',
            self.test_book_dir + '/',
            '--exclude-from=exclude.txt'
        )
Beispiel #2
0
 def setUp(self):
     # self.book = Book(1283)
     self.test_book_dir = './gitenberg/tests/test_data/test_book'
     self.remote_path = '1234/1234.txt'
     mock_book = MagicMock()
     mock_book.local_path = self.test_book_dir
     mock_book.remote_path = self.remote_path
     self.fetcher = BookFetcher(mock_book)
Beispiel #3
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()
Beispiel #4
0
class TestBookFetcher(unittest.TestCase):
    def setUp(self):
        # self.book = Book(1283)
        self.test_book_dir = './gitenberg/tests/test_data/test_book'
        self.remote_path = '1234/1234.txt'
        mock_book = MagicMock()
        mock_book.local_path = self.test_book_dir
        mock_book.remote_path = self.remote_path
        self.fetcher = BookFetcher(mock_book)

    @patch('sh.rsync')
    def test_remote_fetch(self, mock_rsync):
        self.fetcher.fetch_remote_book_to_local_path()
        mock_rsync.assert_called_once_with('-rvhz',
                                           '{}1234/1234.txt'.format(PG_RSYNC),
                                           self.test_book_dir + '/',
                                           '--exclude-from=exclude.txt')
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()
Beispiel #6
0
 def setUp(self):
     # self.book = Book(1283)
     self.test_book_dir = './gitenberg/tests/test_data/test_book'
     self.remote_path = '1234/1234.txt'
     mock_book = MagicMock()
     mock_book.local_path = self.test_book_dir
     mock_book.remote_path = self.remote_path
     self.fetcher = BookFetcher(mock_book)
Beispiel #7
0
class TestBookFetcher(unittest.TestCase):
    def setUp(self):
        # self.book = Book(1283)
        self.test_book_dir = './gitenberg/tests/test_data/test_book'
        self.remote_path = '1234/1234.txt'
        mock_book = MagicMock()
        mock_book.local_path = self.test_book_dir
        mock_book.remote_path = self.remote_path
        self.fetcher = BookFetcher(mock_book)

    @patch('sh.rsync')
    def test_remote_fetch(self, mock_rsync):
        self.fetcher.fetch_remote_book_to_local_path()
        mock_rsync.assert_called_once_with(
            '-rvhz',
            '{}1234/1234.txt'.format(PG_RSYNC),
            self.test_book_dir + '/',
            '--exclude-from=exclude.txt'
        )
Beispiel #8
0
class TestBookFetcher(unittest.TestCase):
    def setUp(self):
        # self.book = Book(1283)
        self.test_book_dir = './gitenberg/tests/test_data/test_book'
        self.remote_path = '1234/1234.txt'
        mock_book = MagicMock()
        mock_book.local_path = self.test_book_dir
        mock_book.remote_path = self.remote_path
        self.fetcher = BookFetcher(mock_book)

    @patch('os.makedirs')
    @patch('os.chmod')
    def test_make_local_path(self, mock_chmod, mock_makedirs):
        self.fetcher.make_local_path()
        mock_makedirs.assert_called_once_with(self.test_book_dir)
        mock_chmod.assert_called_once_with(self.test_book_dir, 0o777)

    @patch('sh.rsync')
    def test_remote_fetch(self, mock_rsync):
        self.fetcher.fetch_remote_book_to_local_path()
        mock_rsync.assert_called_once_with(
            '-rvhz', '[email protected]::gutenberg/1234/1234.txt',
            self.test_book_dir + '/', '--exclude-from=exclude.txt')
Beispiel #9
0
 def setUp(self):
     self.book = Book(1283, library_path='./test/library')
     self.fetcher = BookFetcher(self.book)
 def setUp(self):
     self.book = Book(1283, library_path='./test/library')
     self.fetcher = BookFetcher(self.book)
Beispiel #11
0
 def setUp(self):
     self.book = Book(1283)
     self.fetcher = BookFetcher(self.book)
Beispiel #12
0
 def setUp(self):
     self.book = Book(1283)
     self.fetcher = BookFetcher(self.book)