diff --git a/libbmc/isbn.py b/libbmc/isbn.py index a6f3faa..5c5904a 100644 --- a/libbmc/isbn.py +++ b/libbmc/isbn.py @@ -37,7 +37,11 @@ def is_valid(isbn): >>> is_valid("123456789X") True """ - return not isbnlib.notisbn(isbn) + return ( + (not isbnlib.notisbn(isbn)) and ( + isbnlib.get_canonical_isbn(isbn) == isbn or + isbnlib.mask(isbnlib.get_canonical_isbn(isbn)) == isbn) + ) def extract_from_text(text): diff --git a/libbmc/tools.py b/libbmc/tools.py index 3e6e9ed..b278700 100644 --- a/libbmc/tools.py +++ b/libbmc/tools.py @@ -82,7 +82,8 @@ def batch(iterable, size): :params size: Size of the batches. :returns: A new batch of the given size at each time. - # TODO: Unittest + >>> [list(i) for i in batch([1, 2, 3, 4, 5], 2)] + [[1, 2], [3, 4], [5]] """ it = iter(iterable) while True: