Пример #1
0
 def test_get_reserved_books_no_table(self):
     with patch(
             "mmlibrary.html_parser.HtmlParser._get_books_table") as method:
         method.return_value = None
         books = HtmlParser.get_reserved_books(None)
         assert isinstance(books, ReservedBooks)
         assert books.len == 0
Пример #2
0
 def _get_reserved_books(
         self,
         user: User,
         type: str = BookFilter.TYPE_RESERVED_NORMAL) -> ReservedBooks:
     html = self._html_page.fetch_login_page(Library.LIBRALY_HOME_URL, user)
     all_books = HtmlParser.get_reserved_books(html)
     filtered_books = BookFilter.do(all_books, type=type)
     return filtered_books
Пример #3
0
 def _get_rental_books(self,
                       user: User,
                       type: str = BookFilter.TYPE_RENTAL_NORMAL,
                       param: Dict = {}) -> RentalBooks:
     html = self._html_page.fetch_login_page(Library.LIBRALY_HOME_URL, user)
     all_books = HtmlParser.get_rental_books(html)
     filtered_books = BookFilter.do(all_books, type=type, param=param)
     return filtered_books
Пример #4
0
 def test_create_books(self):
     books = HtmlParser._create_books(type="hoge")
     assert isinstance(books, Books)
Пример #5
0
 def test_get_table_empty(self):
     result = HtmlParser._get_table("<html></html>", "empty")
     assert result is None
Пример #6
0
 def test_get_books_table_empty(self):
     HtmlParser._get_books_table(None, type="hoge")
Пример #7
0
 def test_get_books_table(self, type, table_name):
     with patch("mmlibrary.html_parser.HtmlParser._get_table") as mock:
         HtmlParser._get_books_table(None, type)
         mock.assert_called_once_with(None, table_name)
Пример #8
0
 def test_get_rental_books(self):
     page = HtmlPage()
     user = User(os.environ["USER1"])
     html = page.fetch_login_page(Library.LIBRALY_HOME_URL, user)
     HtmlParser.get_rental_books(html)
     page.release_resource()