def test_find_encyclopedic_informations(self): # Create several definitions def1 = Definition() def2 = Definition() self.sense.definition = [def1, def2] # Create several statements with different encyclopedic informations and languages state1 = Statement().set_encyclopedicInformation("info1", "eng") state2 = Statement().set_encyclopedicInformation("info2", "fra") state3 = Statement().set_encyclopedicInformation("info3", "eng") self.sense.definition[0].statement = [state1, state2] self.sense.definition[1].statement = [state3] # Test find encyclopedic informations self.assertListEqual(self.sense.find_encyclopedic_informations("fra"), [state2.encyclopedicInformation]) # List is randomly ordered => create a set to avoid random results self.assertEqual( set(self.sense.find_encyclopedic_informations("eng")), set([ state1.encyclopedicInformation, state3.encyclopedicInformation ])) # Release created instances del self.sense.definition[0].statement[:] del self.sense.definition[1].statement[:] del state1, state2, state3 del self.sense.definition[:] del def1, def2
def test_add_statement(self): # Create statements state1 = Statement() state2 = Statement() # Test add statements to the definition self.assertIs(self.definition.add_statement(state1), self.definition) self.assertListEqual(self.definition.statement, [state1]) self.assertIs(self.definition.add_statement(state2), self.definition) self.assertListEqual(self.definition.statement, [state1, state2]) # Release Statement instances del self.definition.statement[:] del state1, state2
def test_get_statements(self): # List of Statement instances is empty self.assertListEqual(self.definition.get_statements(), []) # Create Statement instances and add them to the list state1 = Statement() state2 = Statement() self.definition.statement = [state1, state2] # Test get statements self.assertListEqual(self.definition.get_statements(), [state1, state2]) # Delete Statement instances del self.definition.statement[:] del state1, state2
def test_get_etymology_comment(self): comment = "etymology" # Create definition and add it to the sense definition = Definition() self.sense.definition = [definition] # Create a statement and add it to the definition state = Statement() self.sense.definition[0].statement = [state] # Set etymology self.sense.definition[0].statement[0].etymologyComment = comment # Test get etymology self.assertEqual(self.sense.get_etymology_comment(), comment) # Test with a language filter language = "eng" self.sense.definition[0].statement[0].termSourceLanguage = language self.assertIsNone( self.sense.get_etymology_comment(term_source_language="fra")) self.assertEqual( self.sense.get_etymology_comment(term_source_language=language), comment) # Release created instances del self.sense.definition[0].statement[:] del state del self.sense.definition[:] del definition
def test_find_restrictions(self): # Create several statements with different restrictions and languages state1 = Statement().set_restriction("only1", "eng") state2 = Statement().set_restriction("only2", "fra") state3 = Statement().set_restriction("only3", "eng") state4 = Statement().set_restriction("only4") # Add statements to the definition self.definition.statement = [state1, state2, state3, state4] # Test find usage notes self.assertListEqual(self.definition.find_restrictions("fra"), [state2.restriction]) # List is randomly ordered => create a set to avoid random results self.assertEqual(set(self.definition.find_restrictions("eng")), set([state1.restriction, state3.restriction])) # Release Statement instances del self.definition.statement[:] del state1, state2, state3, state4
def test_find_notes(self): # Create several statements with different notes, types and languages state1 = Statement().set_note("note1", "comparison", "eng") state2 = Statement().set_note("note2", "general", "fra") state3 = Statement().set_note("note3", "comparison") state4 = Statement().set_note("note4", "history") # Add statements to the definition self.definition.statement = [state1, state2, state3, state4] # Test find notes self.assertListEqual(self.definition.find_notes("general"), [state2.note]) # List is randomly ordered => create a set to avoid random results self.assertEqual(set(self.definition.find_notes("comparison")), set([state1.note, state3.note])) # Release Statement instances del self.definition.statement[:] del state1, state2, state3, state4
def test_find_encyclopedic_informations(self): # Create several statements with different encyclopedic informations and languages state1 = Statement().set_encyclopedicInformation("info1", "eng") state2 = Statement().set_encyclopedicInformation("info2", "fra") state3 = Statement().set_encyclopedicInformation("info3", "eng") state4 = Statement().set_encyclopedicInformation("info4") # Add statements to the definition self.definition.statement = [state1, state2, state3, state4] # Test find usage notes self.assertListEqual( self.definition.find_encyclopedic_informations("fra"), [state2.encyclopedicInformation]) # List is randomly ordered => create a set to avoid random results self.assertEqual( set(self.definition.find_encyclopedic_informations("eng")), set([ state1.encyclopedicInformation, state3.encyclopedicInformation ])) # Release Statement instances del self.definition.statement[:] del state1, state2, state3, state4
def test_find_notes(self): # Create several definitions def1 = Definition() def2 = Definition() self.sense.definition = [def1, def2] # Create several statements with different notes and types state1 = Statement().set_note("note1", "comparison") state2 = Statement().set_note("note2", "general") state3 = Statement().set_note("note3", "comparison") self.sense.definition[0].statement = [state1, state2] self.sense.definition[1].statement = [state3] # Test find notes self.assertListEqual(self.sense.find_notes("general"), [state2.note]) # List is randomly ordered => create a set to avoid random results self.assertEqual(set(self.sense.find_notes("comparison")), set([state1.note, state3.note])) # Release created instances del self.sense.definition[0].statement[:] del self.sense.definition[1].statement[:] del state1, state2, state3 del self.sense.definition[:] del def1, def2
def test_get_etymology_source(self): source = "etymology" # Create a statement state = Statement() # Add statement to the definition self.definition.statement = [state] # Set etymology source self.definition.statement[0].etymologySource = source # Test get etymology source self.assertEqual(self.definition.get_etymology_source(), source) # Release Statement instance del self.definition.statement[:] del state
def test_get_scientific_name(self): name = "Maximus" # Create a statement state = Statement() # Add statement to the definition self.definition.statement = [state] # Set scientific name self.definition.statement[0].scientificName = name # Test get scientific name self.assertEqual(self.definition.get_scientific_name(), name) # Release Statement instance del self.definition.statement[:] del state
def test_get_writtenForm(self): form = "written" # Create a statement state = Statement() # Add statement to the definition self.definition.statement = [state] # Set written form self.definition.statement[0].writtenForm = form # Test get written form self.assertEqual(self.definition.get_written_form(), form) # Release Statement instance del self.definition.statement[:] del state
def test_get_etymology_gloss(self): gloss = "GLOSS" # Create a statement state = Statement() # Add statement to the definition self.definition.statement = [state] # Set etymology gloss self.definition.statement[0].etymologyGloss = gloss # Test get etymology gloss self.assertEqual(self.definition.get_etymology_gloss(), gloss) # Release Statement instance del self.definition.statement[:] del state
def test_get_etymology(self): etymology = "etymology" # Create a statement state = Statement() # Add statement to the definition self.definition.statement = [state] # Set etymology self.definition.statement[0].etymology = etymology # Test get etymology self.assertEqual(self.definition.get_etymology(), etymology) # Release Statement instance del self.definition.statement[:] del state
def test_get_borrowed_word(self): word = "borrowed" # Create a statement state = Statement() # Add statement to the definition self.definition.statement = [state] # Set borrowed word self.definition.statement[0].borrowedWord = word # Test get borrowed word self.assertEqual(self.definition.get_borrowed_word(), word) # Release Statement instance del self.definition.statement[:] del state
def test_find_usage_notes(self): # Create several definitions def1 = Definition() def2 = Definition() self.sense.definition = [def1, def2] # Create several statements with different usage notes and languages state1 = Statement().set_usageNote("note1", "eng") state2 = Statement().set_usageNote("note2", "fra") state3 = Statement().set_usageNote("note3", "eng") self.sense.definition[0].statement = [state1, state2] self.sense.definition[1].statement = [state3] # Test find usage notes self.assertListEqual(self.sense.find_usage_notes("fra"), [state2.usageNote]) # List is randomly ordered => create a set to avoid random results self.assertEqual(set(self.sense.find_usage_notes("eng")), set([state1.usageNote, state3.usageNote])) # Release created instances del self.sense.definition[0].statement[:] del self.sense.definition[1].statement[:] del state1, state2, state3 del self.sense.definition[:] del def1, def2
def test_get_borrowed_word(self): word = "borrowed" # Create definition and add it to the sense definition = Definition() self.sense.definition = [definition] # Create a statement and add it to the definition state = Statement() self.sense.definition[0].statement = [state] # Set borrowed word self.sense.definition[0].statement[0].borrowedWord = word # Test get borrowed word self.assertEqual(self.sense.get_borrowed_word(), word) # Release created instances del self.sense.definition[0].statement[:] del state del self.sense.definition[:] del definition
def test_get_writtenForm(self): form = "written" # Create definition and add it to the sense definition = Definition() self.sense.definition = [definition] # Create a statement and add it to the definition state = Statement() self.sense.definition[0].statement = [state] # Set written form self.sense.definition[0].statement[0].writtenForm = form # Test get written form self.assertEqual(self.sense.get_written_form(), form) # Release created instances del self.sense.definition[0].statement[:] del state del self.sense.definition[:] del definition
def test_get_etymology_gloss(self): gloss = "GLOSS" # Create definition and add it to the sense definition = Definition() self.sense.definition = [definition] # Create a statement and add it to the definition state = Statement() self.sense.definition[0].statement = [state] # Set etymology self.sense.definition[0].statement[0].etymologyGloss = gloss # Test get etymology self.assertEqual(self.sense.get_etymology_gloss(), gloss) # Release created instances del self.sense.definition[0].statement[:] del state del self.sense.definition[:] del definition
def test_get_etymology_source(self): source = "etymology" # Create definition and add it to the sense definition = Definition() self.sense.definition = [definition] # Create a statement and add it to the definition state = Statement() self.sense.definition[0].statement = [state] # Set etymology self.sense.definition[0].statement[0].etymologySource = source # Test get etymology self.assertEqual(self.sense.get_etymology_source(), source) # Release created instances del self.sense.definition[0].statement[:] del state del self.sense.definition[:] del definition
def test_get_scientific_name(self): name = "Nameus" # Create definition and add it to the sense definition = Definition() self.sense.definition = [definition] # Create a statement and add it to the definition state = Statement() self.sense.definition[0].statement = [state] # Set scientific name self.sense.definition[0].statement[0].scientificName = name # Test get scientific name self.assertEqual(self.sense.get_scientific_name(), name) # Release created instances del self.sense.definition[0].statement[:] del state del self.sense.definition[:] del definition
def test_get_etymology_comment(self): comment = "etymology" # Create a statement state = Statement() # Add statement to the definition self.definition.statement = [state] # Set etymology comment self.definition.statement[0].etymologyComment = comment # Test get etymology comment self.assertEqual(self.definition.get_etymology_comment(), comment) # Test with a language filter language = "eng" self.definition.statement[0].termSourceLanguage = language self.assertIsNone( self.definition.get_etymology_comment(term_source_language="fra")) self.assertEqual( self.definition.get_etymology_comment( term_source_language=language), comment) # Release Statement instance del self.definition.statement[:] del state
def setUp(self): # Instantiate a Statement object self.statement = Statement()
def create_statement(self): """! @brief Create a Statement instance. @return Statement instance. """ return Statement()