[geneagrapher] 225/226: Handling error returned when attempting to retrieve "long" IDs.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Sat Jul 11 17:11:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository geneagrapher.

commit 036bec11ac63771ec5dab6a22f3175853a5b2bfe
Author: David Alber <alber.david at gmail.com>
Date:   Wed Jul 4 15:24:27 2012 -0700

    Handling error returned when attempting to retrieve "long" IDs.
    
    IDs that are very long do not appear to be numeric to the Math
    Genealogy website and result in a different error page than shorter
    bad IDs. This commit adds code to handle the errors returned when
    requesting long IDs.
    
    This fixes #17.
---
 src/geneagrapher/grabber.py                            | 4 ++++
 tests/geneagrapher/test_geneagrapher_methods.py        | 9 +++++++++
 tests/geneagrapher/testdata/999999999999999999999.html | 1 +
 3 files changed, 14 insertions(+)

diff --git a/src/geneagrapher/grabber.py b/src/geneagrapher/grabber.py
index d3b79fb..b66b42c 100644
--- a/src/geneagrapher/grabber.py
+++ b/src/geneagrapher/grabber.py
@@ -51,6 +51,10 @@ def get_record_from_tree(soup, id):
 def has_record(soup):
     """Return True if the input tree contains a mathematician record and False
     otherwise."""
+    if str(soup) == "Non-numeric id supplied. Aborting.":
+        # This is received, for instance, by going to
+        # http://genealogy.math.ndsu.nodak.edu/id.php?id=999999999999999999999.
+        return False
     return not soup.firstText().text == u"You have specified an ID that does \
 not exist in the database. Please back up and try again."
 
diff --git a/tests/geneagrapher/test_geneagrapher_methods.py b/tests/geneagrapher/test_geneagrapher_methods.py
index 8809963..38e1d54 100644
--- a/tests/geneagrapher/test_geneagrapher_methods.py
+++ b/tests/geneagrapher/test_geneagrapher_methods.py
@@ -136,6 +136,15 @@ geneagrapher: error: too few arguments
         self.assertRaises(ValueError, self.ggrapher.build_graph_complete,
                           LocalDataGrabber)
 
+    def test_build_graph_complete_only_self_verbose_error_long(self):
+        """Graph building with no ancestors or descendants given a bad
+        ID of the long variety."""
+        self.ggrapher.verbose = True
+        self.ggrapher.seed_ids.append(999999999999999999999)
+
+        self.assertRaises(ValueError, self.ggrapher.build_graph_complete,
+                          LocalDataGrabber)
+
     def test_build_graph_complete_only_self_verbose(self):
         """Graph building with no ancestors or descendants."""
         self.ggrapher.verbose = True
diff --git a/tests/geneagrapher/testdata/999999999999999999999.html b/tests/geneagrapher/testdata/999999999999999999999.html
new file mode 100644
index 0000000..97fc074
--- /dev/null
+++ b/tests/geneagrapher/testdata/999999999999999999999.html
@@ -0,0 +1 @@
+Non-numeric id supplied. Aborting.
\ No newline at end of file

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/geneagrapher.git



More information about the debian-science-commits mailing list