'Add a single dir to a TorrentDef'

def test_add_content_dir(self):

    t = TorrentDef()
    dn = os.path.join(TESTS_DATA_DIR, 'contentdir')
    t.add_content(dn, 'dirintorrent')
    t.set_tracker(TRACKER)
    t.finalize()
    exps = 0
    for f in os.listdir(dn):
        if f.startswith('.'):
            continue
        p = os.path.join(dn, f)
        s = os.path.getsize(p)
        exps += s
        self._logger.debug('Expected    size    %s    %d', f, s)
    self._logger.debug('Expected    total    size    of    files    in    torrent    %d', exps)
    metainfo = t.get_metainfo()
    self.general_check(metainfo)
    self.assertEqual(metainfo['info']['name'], 'dirintorrent')
    reals = 0
    for file in metainfo['info']['files']:
        s = file['length']
        self._logger.debug('real    size    %s    %d', file['path'], s)
        reals += s
    self._logger.debug('Real    size    of    files    in    torrent    %d', reals)
    self.assertEqual(exps, reals)
