コード例 #1
0
    def setUp(self):
        self.vamu = VamuClient()
        self.bibtex_content = """@Misc{CppUnit:01,
  Author         = {{Michael Feathers}},
  Title          = {Cpp{U}nit - the unit testing library},
  HowPublished   = {http://cppunit.sourceforge.net/doc/lastest/cppunit\_cookbook.html},
  Note           = {[Online; accessed 13-June-2011]},
  url            = {http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html}
}

@Article{dyba,
  Author         = "Tore Dybå and Torgeir Dingsøyr",
  Title          = "Empirical studies of agile software development: A
                   systematic review",
  Journal        = "Information and Software Technology",
  Volume         = "50",
  Number         = "9-10",
  Pages          = "833 - 859",
  doi            = "DOI: 10.1016/j.infsof.2008.01.006",
  issn           = "0950-5849",
  keywords       = "Scrum",
  url            = "{http://www.sciencedirect.com/science/article/B6V0B-4RRFN8D-1/2/e209a925b491379481755341b2ebb91c}",
  year           = 2008
}

@Misc{DJUT1,
  Author         = {{Adolfo Neto}},
  Title          = {Dojo-{UTFPR} - {G}it{H}ub},
  HowPublished   = {https://github.com/adolfont/Dojo-UTFPR/tree/master/experimental/20110223},
  Note           = {Dispon\'{i}vel em:
                   \url{https://github.com/adolfont/Dojo-UTFPR/tree/master/experimental/20110223}.
                   Acessado em: 18 de abril de 2011.},
  acessado       = {14 de abril de 2011},
  url            = {https://github.com/adolfont/Dojo-UTFPR/tree/master/experimental/20110223},
  year           = 2011
}

@Misc{MichaelFeathers:03,
  Author         = {Feathers, Michael},
  Title          = {Source{F}orge.net: cppunit what is},
  HowPublished   = {http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main\_Page\&oldid=50\#What\_is\_CppUnit.3F},
  Note           = {[Online; accessed 13-June-2011]},
  url            = {http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main_Page&oldid=50#What_is_CppUnit.3F}
}"""

        self.bibtex_urls = [
            "http://cppunit.sourceforge.net/" "doc/lastest/cppunit\\_cookbook.html",
            "http://cppunit.sourceforge.net/" "doc/lastest/cppunit_cookbook.html",
            "http://www.sciencedirect.com/science/" "article/B6V0B-4RRFN8D-1/2/e209a925b49" "1379481755341b2ebb91c",
            "https://github.com/adolfont/Dojo-UTFPR/" "tree/master/experimental/20110223",
            "https://github.com/adolfont/Dojo-UTFPR/" "tree/master/experimental/20110223",
            "https://github.com/adolfont/Dojo-UTFPR/" "tree/master/experimental/20110223",
            "http://sourceforge.net/apps/mediawiki/"
            "cppunit/index.php?title=Main\_Page\&"
            "oldid=50\#What\_is\_CppUnit.3F",
            "http://sourceforge.net/apps/mediawiki/" "cppunit/index.php?title=Main_Page&" "oldid=50#What_is_CppUnit.3F",
        ]
コード例 #2
0
class VamuClientTest(unittest.TestCase):
    def setUp(self):
        self.vamu = VamuClient()
        self.bibtex_content = """@Misc{CppUnit:01,
  Author         = {{Michael Feathers}},
  Title          = {Cpp{U}nit - the unit testing library},
  HowPublished   = {http://cppunit.sourceforge.net/doc/lastest/cppunit\_cookbook.html},
  Note           = {[Online; accessed 13-June-2011]},
  url            = {http://cppunit.sourceforge.net/doc/lastest/cppunit_cookbook.html}
}

@Article{dyba,
  Author         = "Tore Dybå and Torgeir Dingsøyr",
  Title          = "Empirical studies of agile software development: A
                   systematic review",
  Journal        = "Information and Software Technology",
  Volume         = "50",
  Number         = "9-10",
  Pages          = "833 - 859",
  doi            = "DOI: 10.1016/j.infsof.2008.01.006",
  issn           = "0950-5849",
  keywords       = "Scrum",
  url            = "{http://www.sciencedirect.com/science/article/B6V0B-4RRFN8D-1/2/e209a925b491379481755341b2ebb91c}",
  year           = 2008
}

@Misc{DJUT1,
  Author         = {{Adolfo Neto}},
  Title          = {Dojo-{UTFPR} - {G}it{H}ub},
  HowPublished   = {https://github.com/adolfont/Dojo-UTFPR/tree/master/experimental/20110223},
  Note           = {Dispon\'{i}vel em:
                   \url{https://github.com/adolfont/Dojo-UTFPR/tree/master/experimental/20110223}.
                   Acessado em: 18 de abril de 2011.},
  acessado       = {14 de abril de 2011},
  url            = {https://github.com/adolfont/Dojo-UTFPR/tree/master/experimental/20110223},
  year           = 2011
}

@Misc{MichaelFeathers:03,
  Author         = {Feathers, Michael},
  Title          = {Source{F}orge.net: cppunit what is},
  HowPublished   = {http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main\_Page\&oldid=50\#What\_is\_CppUnit.3F},
  Note           = {[Online; accessed 13-June-2011]},
  url            = {http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main_Page&oldid=50#What_is_CppUnit.3F}
}"""

        self.bibtex_urls = [
            "http://cppunit.sourceforge.net/" "doc/lastest/cppunit\\_cookbook.html",
            "http://cppunit.sourceforge.net/" "doc/lastest/cppunit_cookbook.html",
            "http://www.sciencedirect.com/science/" "article/B6V0B-4RRFN8D-1/2/e209a925b49" "1379481755341b2ebb91c",
            "https://github.com/adolfont/Dojo-UTFPR/" "tree/master/experimental/20110223",
            "https://github.com/adolfont/Dojo-UTFPR/" "tree/master/experimental/20110223",
            "https://github.com/adolfont/Dojo-UTFPR/" "tree/master/experimental/20110223",
            "http://sourceforge.net/apps/mediawiki/"
            "cppunit/index.php?title=Main\_Page\&"
            "oldid=50\#What\_is\_CppUnit.3F",
            "http://sourceforge.net/apps/mediawiki/" "cppunit/index.php?title=Main_Page&" "oldid=50#What_is_CppUnit.3F",
        ]

    def test_set_default_url(self):
        self.vamu.set_url("http://www.google.com")
        result = "http://va.mu/api/create?url=http%3A//www.google.com"
        self.assertEqual(self.vamu.resource, result)

    def test_set_url_with_canonical(self):
        self.vamu.options["canonical"] = "1"
        self.vamu.set_url("http://www.google.com")
        result = "http://va.mu/api/create?url=http%3A//www.google.com&canonical=1"
        self.assertEqual(self.vamu.resource, result)

    def test_set_url_with_exclusive(self):
        self.vamu.options["exclusive"] = "1"
        self.vamu.set_url("http://www.google.com")
        result = "http://va.mu/api/create?url=http%3A//www.google.com&exclusive=1"
        self.assertEqual(self.vamu.resource, result)

    def test_set_url_with_confirmation(self):
        self.vamu.options["confirmation"] = "1"
        self.vamu.set_url("http://www.google.com")
        result = "http://va.mu/api/create?url=http%3A//www.google.com&confirmation=1"
        self.assertEqual(self.vamu.resource, result)

    def test_set_url_with_type(self):
        self.vamu.options["type"] = "json"
        self.vamu.set_url("http://www.google.com")
        result = "http://va.mu/api/create?url=http%3A//www.google.com&type=json"
        self.assertEqual(self.vamu.resource, result)

    def test_handle_default_options(self):
        self.vamu.handle_options()
        self.assertEqual(self.vamu.options, {"size": 42})

    def test_set_valid_canonical(self):
        self.vamu.options["canonical"] = "1"
        self.assertEqual(self.vamu.options.get("canonical"), "1")

    def test_set_invalid_canonical(self):
        self.assertRaises(InvalidValueError, self.vamu.options.update, canonical="10")

    def test_set_valid_exclusive(self):
        self.vamu.options["exclusive"] = "1"
        self.assertEqual(self.vamu.options.get("exclusive"), "1")

    def test_set_invalid_exclusive(self):
        self.assertRaises(InvalidValueError, self.vamu.options.update, exclusive=1)

    def test_set_valid_confirmation(self):
        self.vamu.options["confirmation"] = "1"
        self.assertEqual(self.vamu.options.get("confirmation"), "1")

    def test_set_invalid_confirmation(self):
        self.assertRaises(InvalidValueError, self.vamu.options.update, confirmation=True)

    def test_set_valid_type(self):
        self.vamu.options["type"] = "xml"
        self.assertEqual(self.vamu.options.get("type"), "xml")

    def test_findall_bibtex_urls(self):
        urls = self.vamu.findall_bibtex_urls(self.bibtex_content)
        self.assertEqual(urls, self.bibtex_urls)

    def test_handle_bibtex_urls(self):
        replaces = self.vamu.handle_bibtex_urls(self.bibtex_urls)
        self.assertEqual(
            replaces,
            [
                (
                    "http://cppunit.sourceforge.net/" "doc/lastest/cppunit\\_cookbook.html",
                    "http://cppunit.sourceforge.net/" "doc/lastest/cppunit_cookbook.html",
                ),
                (
                    "http://cppunit.sourceforge.net/" "doc/lastest/cppunit_cookbook.html",
                    "http://cppunit.sourceforge.net/" "doc/lastest/cppunit_cookbook.html",
                ),
                (
                    "http://www.sciencedirect.com/science/"
                    "article/B6V0B-4RRFN8D-1/2/e209a925b49"
                    "1379481755341b2ebb91c",
                    "http://www.sciencedirect.com/science/"
                    "article/B6V0B-4RRFN8D-1/2/e209a925b49"
                    "1379481755341b2ebb91c",
                ),
                (
                    "https://github.com/adolfont/Dojo-UTFPR/" "tree/master/experimental/20110223",
                    "https://github.com/adolfont/Dojo-UTFPR/" "tree/master/experimental/20110223",
                ),
                (
                    "https://github.com/adolfont/Dojo-UTFPR/" "tree/master/experimental/20110223",
                    "https://github.com/adolfont/Dojo-UTFPR/" "tree/master/experimental/20110223",
                ),
                (
                    "https://github.com/adolfont/Dojo-UTFPR/" "tree/master/experimental/20110223",
                    "https://github.com/adolfont/Dojo-UTFPR/" "tree/master/experimental/20110223",
                ),
                (
                    "http://sourceforge.net/apps/mediawiki/"
                    "cppunit/index.php?title=Main\_Page\&"
                    "oldid=50\#What\_is\_CppUnit.3F",
                    "http://sourceforge.net/apps/mediawiki/"
                    "cppunit/index.php?title=Main_Page&"
                    "oldid=50#What_is_CppUnit.3F",
                ),
                (
                    "http://sourceforge.net/apps/mediawiki/"
                    "cppunit/index.php?title=Main_Page&"
                    "oldid=50#What_is_CppUnit.3F",
                    "http://sourceforge.net/apps/mediawiki/"
                    "cppunit/index.php?title=Main_Page&"
                    "oldid=50#What_is_CppUnit.3F",
                ),
            ],
        )

    def test_set_invalid_type(self):
        self.assertRaises(InvalidValueError, self.vamu.options.update, type="pdf")

    def test_set_invalid_option(self):
        self.assertRaises(InvalidOptionError, self.vamu.options.update, noname="1")