
Create the channel.

  >>> from tests import *
  >>> from smart.channel import createChannel
  >>> channel = createChannel("alias",
  ...                         {"type": "urpmi",
  ...                          "baseurl": "file://%s/urpmi" % TESTDATADIR,
  ...                          "hdlurl": "synthesis.hdlist.cz"})
  >>> channel
  <smart.channels.urpmi.URPMIChannel object at ...>


We need a progress and a fetcher.

  >>> from smart.progress import Progress
  >>> from smart.fetcher import Fetcher
  >>> progress = Progress()
  >>> fetcher = Fetcher()


Fetch channel data.

  >>> # Force cache to NEVER so we fetch reconfig.urpmi
  >>> from smart.const import NEVER
  >>> fetcher.setCaching(NEVER)
  >>> channel.fetch(fetcher, progress)
  True
  >>> channel.getLoaders()
  [<smart.backends.rpm.synthesis.URPMISynthesisLoader object at ...>]


Let's create a cache to put the loader in, so that we can test it.

  >>> from smart.cache import Cache
  >>> loader = channel.getLoaders()[0]
  >>> cache = Cache()
  >>> cache.addLoader(loader)


The setup is ready. Now we can load the data into the cache.

  >>> cache.load()


This should give us one package with the data we already know.

  >>> packages = sorted(cache.getPackages())
  >>> packages
  [name1-version1-release1@noarch, name2-version2-release2@noarch]

  >>> pkg = packages[0]
  >>> type(pkg)
  <class 'smart.backends.rpm.base.RPMPackage'>


Let's inspect the package data.

  >>> pkg.name
  'name1'
  >>> pkg.version
  'version1-release1@noarch'

  >>> sorted(pkg.provides)
  [name1 = version1-release1@noarch, providename1 = provideversion1]
  >>> [type(x).__name__ for x in sorted(pkg.provides)]
  ['RPMNameProvides', 'RPMProvides']

  >>> sorted(pkg.requires)
  [/bin/sh, prerequirename1 = prerequireversion1, requirename1 = requireversion1]
  >>> # XXX pre-requires are broken in createrepo
  >>> [type(x).__name__ for x in sorted(pkg.requires)]
  ['RPMPreRequires', 'RPMPreRequires', 'RPMRequires']

  >>> sorted(pkg.upgrades)
  [name1 < version1-release1@noarch, obsoletesname1 = obsoletesversion1]
  >>> [type(x).__name__ for x in sorted(pkg.upgrades)]
  ['RPMObsoletes', 'RPMObsoletes']

  >>> sorted(pkg.conflicts)
  [conflictsname1 = conflictsversion1, obsoletesname1 = obsoletesversion1]
  >>> [type(x).__name__ for x in sorted(pkg.conflicts)]
  ['RPMConflicts', 'RPMObsoletes']


Now let's ask the loader for a PackageInfo instance, and inspect it.

  >>> info = loader.getInfo(pkg)
  >>> info
  <smart.backends.rpm.synthesis.URPMISynthesisPackageInfo object at ...>

  >>> info.getGroup()
  'Group1'
  >>> info.getSummary()
  'Summary1'
  >>> # There is no description with synthesis. Uncomment when using full hdlist.
  >>> # info.getDescription()
  >>> # 'Description1'

vim:ft=doctest
