def test_FromJSONEmptyObject(self): lmap = LanguageMap.from_json('{}') self.assertIsInstance(lmap, LanguageMap) self.assertEqual(lmap, {})
def test_FromJSONExceptionBadJSON(self): with self.assertRaises(ValueError): LanguageMap.from_json('{"bad JSON"}')
def test_FromJSONExceptionNestedObject(self): with self.assertRaises(TypeError): LanguageMap.from_json( '{"fr-CA": "test", "en-US": {"nested": "object"}}')
def test_ToJSONFromJSON(self): json_str = '{"fr-CA": "CA-test", "en-US": "US-test", "fr-FR": "FR-test"}' lmap = LanguageMap.from_json(json_str) self.mapVerificationHelper(lmap) self.assertEqual(lmap.to_json(), json_str)
def test_FromJSON(self): lmap = LanguageMap.from_json( '{"en-US": "US-test", "fr-CA": "CA-test", "fr-FR": "FR-test"}') self.mapVerificationHelper(lmap)
def test_FromJSONExceptionNestedObject(self): with self.assertRaises(TypeError): LanguageMap.from_json('{"fr-CA": "test", "en-US": {"nested": "object"}}')
def test_FromJSON(self): lmap = LanguageMap.from_json('{"en-US": "US-test", "fr-CA": "CA-test", "fr-FR": "FR-test"}') self.mapVerificationHelper(lmap)