예제 #1
0
    def cogitation(self):
        """ Papy will fill the following fields :
            - palce
            - location
            - maps
            - wiki """

        parser = Parser(self.question)
        self.place = parser.get_place()

        if self.place:
            maps_api = MapsApi(self.place)
            wiki_api = WikiApi(self.place)

            self.location = maps_api.get_location()
            self.wiki = wiki_api.get_wiki()

            if not self.location:
                self.errors.append("NO_LOCATION")

            if not self.wiki:
                self.errors.append("NO_WIKI")

        else:
            self.errors.append("BAD_QUESTION")

            self.location = None
            self.wiki = [None, None]
예제 #2
0
    def test_get_place_bad_question(self):
        """ If the question have not place, Parser will raise an error """

        parser = Parser(self.BAD_QUESTION)

        assert parser.get_place() == None
예제 #3
0
    def test_get_place(self):
        """ If all is OK, Parser will return the name of the place. """

        parser = Parser(self.GOOD_QUESTION)
        assert parser.get_place() == self.PLACE