def test_many_bad_search(self):
     filters = {
         'id': mocks.UUID1,
     }
     search_spec = search.SearchSpec(self.ctx, filters=filters)
     with testtools.ExpectedException(ValueError):
         organization.many(self.engine.connect(), search_spec)
    def test_many_all(self):
        search_spec = search.SearchSpec(self.ctx)
        r = organization.many(self.engine.connect(), search_spec)

        uuid1_no_dash = mocks.UUID1.replace('-', '')
        uuid2_no_dash = mocks.UUID2.replace('-', '')
        expected = [
            # Note that mocks.UUID2 is alphabetically first and therefore
            # without specifying any sort order, the default for organizations
            # is created_on DESC, uuid ASC
            {
                'uuid': uuid2_no_dash,
                'name': helpers.utf8_bytes('my other org'),
                'slug': helpers.utf8_bytes('my-other-org'),
                'root_organization_uuid': uuid2_no_dash,
                'parent_organization_uuid': None,
                'created_on': mocks.CREATED_ON_NAIVE,
                'generation': 1,
                'left_sequence': 1,
                'right_sequence': 2,
            },
            {
                'uuid': uuid1_no_dash,
                'name': helpers.utf8_bytes('my org'),
                'slug': helpers.utf8_bytes('my-org'),
                'root_organization_uuid': uuid1_no_dash,
                'parent_organization_uuid': None,
                'created_on': mocks.CREATED_ON_NAIVE,
                'generation': 1,
                'left_sequence': 1,
                'right_sequence': 2,
            },
        ]
        self.assertEqual(expected, r)
 def test_many_empty_list(self):
     filters = {
         'uuid': mocks.NO_EXIST_UUID,
     }
     search_spec = search.SearchSpec(self.ctx, filters=filters)
     r = organization.many(self.engine.connect(), search_spec)
     self.assertEqual([], r)