from testutils import make_test_suite, run_test_suite, \
    test_web_page_content, merge_error_messages, test_web_page_existence

class BibClassifyWebPagesAvailabilityTest(unittest.TestCase):
    """Check BibClassify web pages whether they are up or not."""

    def test_availability_bibclassify_admin_guide(self):
        """Tests the availability of BibClassify Admin Guide page."""
        self.assertEqual([], test_web_page_content(CFG_SITE_URL +
            '/help/admin/bibclassify-admin-guide',
            expected_text="BibClassify Admin Guide"))
        return

    def test_availability_bibclassify_hacking_pages(self):
        """Tests the availability of BibClassify Hacking Guide pages"""
        self.assertEqual([], test_web_page_content(CFG_SITE_URL +
            '/help/hacking/bibclassify-internals',
            expected_text="BibClassify Internals"))
        self.assertEqual([], test_web_page_content(CFG_SITE_URL +
            '/help/hacking/bibclassify-hep-taxonomy',
            expected_text="The HEP taxonomy: rationale and extensions"))
        self.assertEqual([], test_web_page_content(CFG_SITE_URL +
            '/help/hacking/bibclassify-extraction-algorithm',
            expected_text="The code behind BibClassify: the extraction algorithm"))
        return

TEST_SUITE = make_test_suite(BibClassifyWebPagesAvailabilityTest)

if __name__ == "__main__":
    run_test_suite(TEST_SUITE, warn_user=True)
        pass

    def xtest_get_single_keywords(self):
        """test the function returns {<keyword>: [ [spans...] ] }"""

    def xtest_get_composite_keywords(self):
        """test the function returns {<keyword>: [ [spans...], [correct component counts] ] }"""





def suite(cls=BibClassifyTest):
    tests = []
    for x in sys.argv[1:]:
        if x[0:4] == 'test':
            tests.append(x)
    if len(tests) < 1:
        raise Exception('You must specify tests to run')

    return unittest.TestSuite(map(cls, tests))

if 'custom' in sys.argv:
    TEST_SUITE = suite(BibClassifyTest)
else:
    TEST_SUITE = make_test_suite(BibClassifyTest)


if __name__ == '__main__':
    run_test_suite(TEST_SUITE)
示例#3
0
    <subfield code="9">BibClassify/HEP</subfield>
</datafield>

</record>
 """
    return check_pdf(result, output)


def check_pdf(result, output):
    for line in output.splitlines():
        line = line.strip()
        if line:
            if line not in result:
                return (False, "\nGot: %s\nMissing: \"%s\"" % (result,line))
    return (True, True)



def suite():
    tests = ['test_cache_accessibility']
    return unittest.TestSuite(map(BibClassifyTest, tests))

if 'custom' in sys.argv:
    TEST_SUITE = suite()
else:
    TEST_SUITE = make_test_suite(BibClassifyTest)


if __name__ == '__main__':
    run_test_suite(TEST_SUITE)