chainlib-eth

Ethereum implementation of the chainlib interface
Info | Log | Files | Refs | README | LICENSE

test_cli.py (1196B)


      1 # standard imports
      2 import unittest
      3 import os
      4 import logging
      5 
      6 # external imports
      7 from aiee.arg import process_args
      8 
      9 # local imports
     10 #from chainlib.cli.base import argflag_std_base
     11 from chainlib.eth.cli.arg import (
     12         ArgFlag,
     13         Arg,
     14         ArgumentParser,
     15         )
     16 from chainlib.eth.cli.config import (
     17         Config,
     18         process_config,
     19         )
     20 script_dir = os.path.dirname(os.path.realpath(__file__))
     21 data_dir = os.path.join(script_dir, 'testdata')
     22 config_dir = os.path.join(data_dir, 'config')
     23 
     24 logging.basicConfig(level=logging.DEBUG)
     25 
     26 
     27 class TestCli(unittest.TestCase):
     28 
     29     def setUp(self):
     30         self.flags = ArgFlag()
     31         self.arg = Arg(self.flags)
     32 
     33 
     34     def test_args_process_single(self):
     35         ap = ArgumentParser()
     36         flags = self.flags.VERBOSE | self.flags.CONFIG
     37         process_args(ap, self.arg, flags)
     38 
     39         argv = [
     40             '-vv',
     41             '-n',
     42             'foo',
     43                 ]
     44         args = ap.parse_args(argv)
     45         config = Config(config_dir)
     46         config = process_config(config, self.arg, args, flags)
     47         self.assertEqual(config.get('CONFIG_USER_NAMESPACE'), 'foo')
     48 
     49 
     50 if __name__ == '__main__':
     51     unittest.main()