Commits

Konstantine Rybnikov committed 9e26f3e

get rid of self.config

  • Participants
  • Parent commits d302a63

Comments (0)

Files changed (2)

 class HgFileMerge():
     
     def __init__(self):
-        self.config = None
-        
+        self.base_path = '.'
+        self.merge_groups = []
+    
     def configure_from_dict(self, d):
-        if not isinstance(self.config, dict):
-            self.config = {}
         if 'base_path' in d:
-            self.config['base_path'] = d['base_path']
+            self.base_path = d['base_path']
         if 'merge_groups' in d:
-            if not isinstance(self.config.get('merge_groups'), list):
-                self.config['merge_groups'] = []
             for group in d['merge_groups']:
                 valid_group = {}
                 valid_group['name'] = group['name']
                         log.warning(u'File %s is not a file (directory maybe?)' % file_path)
                     else:
                         valid_group['files'].append(file_)
-                self.config['merge_groups'].append(valid_group)
+                self.merge_groups.append(valid_group)
     
     def configure_from_file(self, path):
         import codecs
         
     def get_merge_groups(self):
         pass
-
     

File tests/test_main.py

 from hgfilemerge import HgFileMerge
 
 class TestYmlConfigParser(unittest.TestCase):
-
-    def test_simple_yml_config(self):
-        merger = HgFileMerge()
-        merger.configure_from_file('tests/testfiles/conf.yml')
+    def setUp(self):
+        self.merger = HgFileMerge()
+        self.merger.configure_from_file('tests/testfiles/conf.yml')
         
-        self.assertEqual(merger.config,
-                         {'base_path': 'tests/testfiles/test_yml_config_parser/',
-                          'merge_groups':
-                              [{'name': 'merged_most_popular.css',
-                                'files':
-                                    ['1.css', '2.css',]},
-                               {'name': 'merged_site.css',
-                                'files':
-                                    ['3.css',]}]})
+    def test_simple_yml_base_path(self):
+        self.assertEqual(self.merger.base_path,
+                         'tests/testfiles/test_yml_config_parser/')
+    
+    def test_simple_yml_merge_groups(self):
+        self.assertEqual(self.merger.merge_groups,
+                         [{'name': 'merged_most_popular.css',
+                            'files':
+                                ['1.css', '2.css',]},
+                           {'name': 'merged_site.css',
+                            'files':
+                                ['3.css',]}])
 
 class TestSimple(unittest.TestCase):
-
     def setUp(self):
         import codecs