2016-04-30 21:49:20 +00:00
|
|
|
# -*- coding: utf8 -*-
|
|
|
|
#
|
|
|
|
# Copyright (c) 2016 Linux Documentation Project
|
2016-02-29 18:47:48 +00:00
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
2016-03-27 09:14:10 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2016-02-29 18:47:48 +00:00
|
|
|
|
|
|
|
import unittest
|
|
|
|
from argparse import Namespace
|
|
|
|
|
|
|
|
# -- SUT
|
|
|
|
from tldp.config import collectconfiguration
|
|
|
|
|
|
|
|
|
|
|
|
class TestConfigWorks(unittest.TestCase):
|
|
|
|
|
|
|
|
def test_basic(self):
|
|
|
|
config, args = collectconfiguration('tag', [])
|
|
|
|
self.assertIsInstance(config, Namespace)
|
|
|
|
self.assertIsInstance(args, list)
|
|
|
|
|
|
|
|
def test_singleoptarg(self):
|
|
|
|
config, args = collectconfiguration('tag', ['--pubdir', '.'])
|
2016-03-15 03:14:24 +00:00
|
|
|
self.assertEqual(config.pubdir, '.')
|
2016-02-29 18:47:48 +00:00
|
|
|
|
2016-03-28 18:11:22 +00:00
|
|
|
def test_nonexistent_directory(self):
|
|
|
|
argv = ['--pubdir', '/path/to/nonexistent/directory']
|
|
|
|
with self.assertRaises(ValueError) as ecm:
|
|
|
|
config, args = collectconfiguration('tag', argv)
|
|
|
|
e = ecm.exception
|
|
|
|
self.assertTrue("/path/to/nonexistent/directory" in e.args[0])
|
|
|
|
|
2016-02-29 18:47:48 +00:00
|
|
|
#
|
|
|
|
# -- end of file
|