From 08fe58926f9d6ae54f1dd423a7d08a5483f6ed04 Mon Sep 17 00:00:00 2001
From: Dmitry Shelepnev <mitshel@mail.ru>
Date: Thu, 16 Mar 2017 21:55:06 +0300
Subject: [PATCH] Fix tests for series

---
 opds_catalog/sopdscan.py        | 2 +-
 opds_catalog/tests/test_scan.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/opds_catalog/sopdscan.py b/opds_catalog/sopdscan.py
index fbf5f68..e61dc1a 100644
--- a/opds_catalog/sopdscan.py
+++ b/opds_catalog/sopdscan.py
@@ -243,7 +243,7 @@ class opdsScanner:
 
                     if book_data.series_info:
                         ser = opdsdb.addseries(book_data.series_info['title'])
-                        ser_no = book_data.series_info['index']
+                        ser_no = book_data.series_info['index']  or '0'
                         ser_no = int(ser_no) if ser_no.isdigit() else 0
                         opdsdb.addbseries(book,ser,ser_no)
             else:
diff --git a/opds_catalog/tests/test_scan.py b/opds_catalog/tests/test_scan.py
index 49c618f..66ea091 100644
--- a/opds_catalog/tests/test_scan.py
+++ b/opds_catalog/tests/test_scan.py
@@ -166,5 +166,5 @@ class scanTestCase(TestCase):
         self.assertEquals(Book.objects.all().count(), 6)
         self.assertEquals(Author.objects.all().count(), 6)
         self.assertEquals(Genre.objects.all().count(), 5)
-        self.assertEquals(Series.objects.all().count(), 0)
+        self.assertEquals(Series.objects.all().count(), 1)
         self.assertEquals(Catalog.objects.all().count(), 2)
-- 
GitLab