
Create the channel.

  >>> from tests import *
  >>> from smart.channel import createChannel
  >>> channel = createChannel("alias",
  ...                         {"type": "slack-dir",
  ...                          "path": "/%s/slack" % TESTDATADIR})
  >>> channel
  <smart.channels.slack_dir.SlackDirChannel 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.

  >>> channel.fetch(fetcher, progress)
  True
  >>> channel.getLoaders()
  [<smart.backends.slack.loader.SlackDirLoader 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 two packages with the data we already know.

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

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


Let's inspect the package data.

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


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

  >>> info = loader.getInfo(pkg)
  >>> info
  <smart.backends.slack.loader.SlackPackageInfo object at ...>

  >>> info.getGroup()
  'Slackware'
  >>> info.getLicense()
  'License1'
  >>> info.getSummary()
  'Summary1'
  >>> info.getDescription()
  'Description1\n...'

  >>> info.getURLs()
  ['file:///.../data/slack/name1-version1-noarch-release1.tgz']
  >>> url = info.getURLs()[0]

  >>> info.getSHA(url)
  >>> info.getSize(url)

  >>> info.getPathList()
  ['tmp', 'tmp/file1']
  >>> info.getReferenceURLs()
  ['http://www.example.com/name1']


vim:ft=doctest
