def test_simple_get_many_objects(self): search_spec = search.SearchSpec(self.ctx) r = self.store.get_many(objects.Organization, search_spec) self.assertEqual(2, len(r)) # mocks.UUID2 < mocks.UUID1 r1 = r[1] r2 = r[0] self.assertEqual(mocks.UUID1, r1.uuid) self.assertEqual(helpers.utf8_text('my org'), r1.name) self.assertEqual(mocks.CREATED_ON_ISO8601, r1.created_on) self.assertEqual(mocks.UUID2, r2.uuid) self.assertEqual(helpers.utf8_text('my other org'), r2.name) self.assertEqual(mocks.CREATED_ON_ISO8601, r2.created_on)
def to_storage(self, subject): if subject is None: return None if isinstance(subject, (six.integer_types, float)): return six.text_type(subject) return helpers.utf8_text(subject)
def test_simple_get_object(self): filters = { 'uuid': mocks.UUID1, } search_spec = search.SearchSpec(self.ctx, filters=filters) r = self.store.get_one(objects.Organization, search_spec) self.assertEqual(mocks.UUID1, r.uuid) self.assertEqual(helpers.utf8_text('my org'), r.name)
def test_utf8_text_success_py3k(self): vals = [ (six.binary_type("The quick brown fox"), six.text_type("The quick brown fox")), (six.text_type("The quick brown fox"), six.text_type("The quick brown fox")), (six.text_type("The quick brown fox").encode("ascii"), six.text_type("The quick brown fox")), ] for v, coerced in vals: self.assertEqual(coerced, helpers.utf8_text(v))