

def test_expand_pool_spec(self):
    ' Test the function which expands pool spec to SQL.\n        '
    schema = {
        'id': self.schema_attrs['id'],
    }
    self.assertRaises(NipapInputError, self.nipap._expand_pool_spec, 'string')
    self.assertRaises(NipapInputError, self.nipap._expand_pool_spec, 1)
    self.assertRaises(NipapInputError, self.nipap._expand_pool_spec, [])
    self.assertRaises(NipapMissingInputError, self.nipap._expand_pool_spec, {
        
    })
    self.assertRaises(NipapExtraneousInputError, self.nipap._expand_pool_spec, {
        'crap': self.pool_attrs['name'],
    })
    self.assertRaises(NipapExtraneousInputError, self.nipap._expand_pool_spec, {
        'id': self.pool_attrs['id'],
        'schema': self.schema_attrs['id'],
        'crap': 'crap',
    })
    self.assertRaises(NipapValueError, self.nipap._expand_pool_spec, {
        'id': '3',
        'schema': self.schema_attrs['id'],
    })
    self.assertRaises(NipapValueError, self.nipap._expand_pool_spec, {
        'name': 3,
        'schema': self.schema_attrs['id'],
    })
    self.assertRaises(NipapExtraneousInputError, self.nipap._expand_pool_spec, {
        'id': 3,
        'name': '3',
        'schema': self.schema_attrs['id'],
    })
    (where, params) = self.nipap._expand_pool_spec({
        'id': 3,
        'schema': self.schema_attrs['id'],
    })
    self.assertEqual(where, 'po.id = %(spec_id)s AND po.schema = %(spec_schema)s', 'Improperly expanded WHERE clause')
    self.assertEqual(params, {
        'spec_id': 3,
        'spec_schema': self.schema_attrs['id'],
    }, 'Improperly expanded params dict')
    (where, params) = self.nipap._expand_pool_spec({
        'name': 'test',
        'schema': self.schema_attrs['id'],
    })
    self.assertEqual(where, 'po.name = %(spec_name)s AND po.schema = %(spec_schema)s', 'Improperly expanded WHERE clause')
    self.assertEqual(params, {
        'spec_name': 'test',
        'spec_schema': self.schema_attrs['id'],
    }, 'Improperly expanded params dict')

dataset/ETHPy150Open SpriteLink/NIPAP/tests/nipapbase.py NipapTest.test_expand_pool_spec/original