def test_adjective_creation(): word_factory = WordFactory() adjective = word_factory.create_adjective_from_json_object( adjective_sample_obj) assert isinstance(adjective, Adjective) assert adjective.get_basic_form() == "bogaty" assert adjective.get_gender() == "m"
def test_noun_case_forms(): word_factory = WordFactory() word = word_factory.create_noun_from_json_object(noun_sample_obj) assert word.get_case_form('plural', 'accusative') == "ogrodniczki" assert word.get_case_form('singular', 'accusative') == u"ogrodniczkę" assert word.get_case_form('singular', 'instrumental') == u"ogrodniczką" assert word.get_case_form('plural', 'dative') == "ogrodniczkom"
def test_adjective_case_forms(): word_factory = WordFactory() adjective = word_factory.create_adjective_from_json_object( adjective_sample_obj) adjective.set_gender("m pers") assert adjective.get_case_form('singular', 'accusative') == "bogatego" assert adjective.get_case_form('singular', 'dative') == "bogatemu" assert adjective.get_case_form('plural', 'dative') == "bogatym" assert adjective.get_case_form('plural', 'vocative') == "bogaci" adjective.set_gender("n") assert adjective.get_case_form('singular', 'instrumental') == "bogatym" assert adjective.get_case_form('singular', 'genitive') == "bogatego" assert adjective.get_case_form('plural', 'genitive') == "bogatych" assert adjective.get_case_form('plural', 'accusative') == "bogate"
def test_retrieve_adjectives(): dir_path = os.path.dirname(os.path.realpath(__file__)) word_repository = WordRepository(dir_path) word_factory = WordFactory() word_service = WordService(word_repository, word_factory) adjectives = word_service.get_adjective_list() assert len(adjectives) == 3 assert adjectives[0].get_basic_form() == "alternatywny" adjectives[0].set_gender("n") assert adjectives[0].get_case_form( "singular", "genitive") == "alternatywnego" assert adjectives[0].get_case_form("plural", "vocative") == "alternatywne" adjectives[0].set_gender("f") assert adjectives[0].get_case_form( "singular", "genitive") == "alternatywnej" assert adjectives[1].get_basic_form() == u"lśniący" adjectives[1].set_gender("m pers") assert adjectives[1].get_case_form("singular", "locative") == u"lśniącym" assert adjectives[1].get_case_form("plural", "accusative") == u"lśniących" adjectives[1].set_gender("n") assert adjectives[1].get_case_form("singular", "dative") == u"lśniącemu" assert adjectives[2].get_basic_form() == u"poligamiczny" adjectives[2].set_gender("m inan") assert adjectives[2].get_case_form( "singular", "accusative") == u"poligamiczny" assert adjectives[2].get_case_form( "plural", "nominative") == u"poligamiczne" adjectives[2].set_gender("f") assert adjectives[2].get_case_form( "singular", "instrumental") == u"poligamiczną"
def test_retrieve_nouns(): dir_path = os.path.dirname(os.path.realpath(__file__)) word_repository = WordRepository(dir_path) word_factory = WordFactory() word_service = WordService(word_repository, word_factory) nouns = word_service.get_noun_list() assert len(nouns) == 3 assert nouns[0].get_basic_form() == "klucz" assert nouns[0].get_case_form("plural", "instrumental") == "kluczami" assert nouns[1].get_basic_form() == "niewolnictwo" assert nouns[1].get_gender() == "n" assert nouns[1].get_case_form("singular", "dative") == "niewolnictwu" assert not nouns[1].supports("plural", "nominative") assert nouns[2].get_basic_form() == "nora" assert nouns[2].get_case_form("singular", "accusative") == u"norę" assert nouns[2].get_case_form("singular", "instrumental") == u"norą" assert nouns[2].supports("plural", "nominative")
def test_noun_creation(): word_factory = WordFactory() word = word_factory.create_noun_from_json_object(noun_sample_obj) assert isinstance(word, Word) assert word.get_basic_form() == "ogrodniczka" assert word.get_gender() == "f"
def __doc__(self): return "One or more of the following values: ({})".format("|".join( self.allowed_values)) def __call__(self, input_value): as_multiple = super().__call__(input_value) if not all(value in self.allowed_values for value in as_multiple): raise KeyError( "Invalid value passed. The accepted values are: ({0})".format( "|".join(self.allowed_values))) return as_multiple # initialize NounBag word_service = WordService(WordRepository(), WordFactory()) noun_bag = WordBag(word_service.get_noun_list()) adjective_bag = WordBag(word_service.get_adjective_list()) # add the CORS middleware to the module API singleton api = hug.API(__name__) # if called with no arguments except the api, all origins ('*') will be allowed. api.http.add_middleware( hug.middleware.CORSMiddleware(api, allow_credentials=False)) @hug.get("/questions", examples=['numbers=singular&cases=genitive&cases=dative']) def get_question(numbers: OneOrManyOf(NUMBERS_AVAILABLE), cases: OneOrManyOf(CASES_AVAILABLE), num: hug.types.in_range(1, MAX_NUM + 1) = 10):