'Test catalog retrieval.'

@pytest.mark.parametrize((u'methodname1', u'methodname2', u'arg'), [(u'get_catalog', u'get_catalogs', u'foo'), (u'get_catalog_by_url', u'get_catalogs_by_url', u'bar.foo')])
def test_get_catalog(self, methodname1, methodname2, arg):

    method1 = getattr(self.db, methodname1)
    method2 = getattr(self.db, methodname2)
    foo_cat = method1(arg)
    if methodname2.endswith(u'url'):
        foo_iter = method2(arg)
    else:
        foo_iter = method2()
    for (k, v) in foo_iter:
        assert (k == u'foo')
        assert (v._tree == foo_cat._tree == {u'title': u'bar', u'url': u'bar.foo'})
    with pytest.raises(MissingCatalog):
        method1(u'foofoo')
