def test_AddNewElementsUnicode(self): ps = DBUpdate() existingResults = {"SearchKey": ["Random Game"]} newResults = { "Description": [ u"'Super Keirin (スーパー競輪, Super Keirin) is a Japan-exclusive video game" ] } existingResults = ps.addNewElements(existingResults, newResults) self.assertEqual( existingResults.get("Description")[0], u"'Super Keirin (スーパー競輪, Super Keirin) is a Japan-exclusive video game", "Expected Unicode string to be handled when adding new search result element" )
def test_AddNewElements(self): ps = DBUpdate() existingResults = {"SearchKey": ["Tekken 2"], "Publisher": []} newResults = { "SearchKey": ["Tekken 3"], "Description": ["Tekken 2 description & history"], "Publisher": ["Namco"] } existingResults = ps.addNewElements(existingResults, newResults) self.assertIn("Description", existingResults, "Expected to add Description") self.assertEqual( existingResults.get("SearchKey")[0], "Tekken 2", "Expected existing field SearchKey to not be overwritten (now {0})" .format(existingResults.get("SearchKey")[0])) self.assertEqual( existingResults.get("Publisher")[0], "Namco", "Expected existing but empty field Publisher to be overwritten")