예제 #1
0
 def test_parallel_parse_one(self):
     filelist = [testdir+testfileone]
     parsed_output = parse.parallel_parse(filelist)
     self.assertTrue(isinstance(parsed_output,list))
     self.assertTrue(len(parsed_output) == 1)
     self.assertTrue(isinstance(parsed_output[0], str))
     self.assertTrue(regex.match(parsed_output[0]))
예제 #2
0
 def test_parse_patent(self):
     patentroot = '.'
     testdir = [os.path.join(basedir, './fixtures/xml')]
     xmlregex = r'ipg120327.one.xml'
     filelist = parse.list_files(testdir, patentroot, xmlregex)
     grant_list = parse.parallel_parse(filelist)
     parsed_grants = parse.parse_patent(grant_list)
     self.assertTrue(len(list(parsed_grants)) == len(grant_list)*len(xmlclasses))
예제 #3
0
 def test_use_parallel_parse_two(self):
     filelist = [testdir+testfiletwo]
     parsed_output = parse.parallel_parse(filelist)
     parsed_xml = []
     for us_patent_grant in parsed_output:
         self.assertTrue(isinstance(us_patent_grant, str))
         for xmlclass in xmlclasses:
             parsed_xml.append(xmlclass(us_patent_grant))
     self.assertTrue(len(parsed_xml) == 2 * len(xmlclasses))
     self.assertTrue(all(parsed_xml))
예제 #4
0
sys.path.append('..')
from couch_patent import *

sys.path.append('../lib/')
from patXML import *

import parse

basedir = os.path.join(os.curdir, '../test')
testdir = os.path.join(basedir, 'fixtures/xml/')
testfile = XMLPatentBase(open(testdir + 'ipg120327.one.xml').read())
patentroot = '.'
xmlregex = r'ipg120327.one.xml'
filelist = parse.list_files([testdir], patentroot, xmlregex)
grant_list = parse.parallel_parse(filelist)
parsed_grants = list(parse.parse_patent(grant_list))


class TestCouchPatent(unittest.TestCase):
    def setUp(self):
        self.assertTrue(testfile)

    def test_get_doc_metadata(self):
        """
        Tests that get_metadata retrieves the requisite information from a
        parsed xml file
        """
        metadata = get_metadata(parsed_grants[0])
        self.assertTrue(isinstance(metadata, dict))
        self.assertTrue(metadata['publication_id'] == parsed_grants[0].patent)
예제 #5
0
 def test_use_parallel_parse_one(self):
     filelist = [testdir+testfileone]
     parsed_output = parse.parallel_parse(filelist)
     parsed_xml = [xmlclass(parsed_output[0]) for xmlclass in xmlclasses]
     self.assertTrue(len(parsed_xml) == len(xmlclasses))
     self.assertTrue(all(parsed_xml))
예제 #6
0
sys.path.append('..')
from couch_patent import *

sys.path.append('../lib/')
from patXML import *

import parse

basedir = os.path.join(os.curdir, '../test')
testdir = os.path.join(basedir, 'fixtures/xml/')
testfile = XMLPatentBase(open(testdir+'ipg120327.one.xml').read())
patentroot = '.'
xmlregex = r'ipg120327.one.xml'
filelist = parse.list_files([testdir], patentroot, xmlregex)
grant_list = parse.parallel_parse(filelist)
parsed_grants = list(parse.parse_patent(grant_list))

class TestCouchPatent(unittest.TestCase):

    def setUp(self):
        self.assertTrue(testfile)

    def test_get_doc_metadata(self):
        """
        Tests that get_metadata retrieves the requisite information from a
        parsed xml file
        """
        metadata = get_metadata(parsed_grants[0])
        self.assertTrue(isinstance(metadata, dict))
        self.assertTrue(metadata['publication_id'] == parsed_grants[0].patent)