Beispiel #1
0
 def test_update_file_changed_item_name(self):
     item_config = read_file(self.project_sodocu_path + '/idea/ThisIsAFileWriterTest.txt')
     idea1 = create_item(self.config, item_config, self.project_sodocu_path + '/idea/ThisIsAFileWriterTest.txt')
     assert idea1.get_filename is not None
     idea1.set_name('this is a file update test')
     self.fileHandler.update_file(idea1)
     item_config = read_file(self.project_sodocu_path + '/idea/ThisIsAFileUpdateTest.txt')
     idea2 = create_item(self.config, item_config, self.project_sodocu_path + '/idea/ThisIsAFileUpdateTest.txt')
     assert idea1.get_id() == idea2.get_id()
     assert idea1.get_name() == idea2.get_name()
     assert idea1.get_filename() != idea2.get_filename()
Beispiel #2
0
 def read_all_items(self, sodocu_config):
     directoryWalker = DirectoryWalker(self.get_path())
     log.debug('directoryWalker.get_filenames(): ' + str(directoryWalker.get_filenames()))
     for filename in directoryWalker.get_filenames():
         item_config = read_file(filename)
         item = create_item(sodocu_config, item_config, filename)
         self.add_item(item)
Beispiel #3
0
 def read_glossary(self):
     self.clear_entries()
     log.debug('sodocu_path: ' + str(self.sodocu_path))
     conf_file = os.path.join(self.sodocu_path, 'glossary.txt')
     log.debug('conf_file: ' + conf_file)
     config = read_file(conf_file)
     
     for option in config.options(Glossary.SECTION_NAME):
         self.add_entry(option, config.get(Glossary.SECTION_NAME, option))
Beispiel #4
0
    def test_create_file(self):
        idea1 = Idea(ItemType('idea', ''), 'idea-99', 'this is a file writer test')
#         print "hasattr(idea1, 'description'): " + str(hasattr(idea1, 'description'))
#         print "hasattr(idea1, 'inventedBy'): " + str(hasattr(idea1, 'inventedBy'))
#         print 'idea1.get_description(): ' + str(idea1.get_description())
#         print 'idea1.get_invented_by(): ' + str(idea1.get_invented_by())
        self.fileHandler.create_file(idea1)
#         print self.project_sodocu_path + '/sodocu/idea/ThisIsAFileWriterTest.txt'
        item_config = read_file(self.project_sodocu_path + '/idea/ThisIsAFileWriterTest.txt')
        idea2 = create_item(self.config, item_config, self.project_sodocu_path + '/idea/ThisIsAFileWriterTest.txt')
        assert idea1.get_id() == idea2.get_id()
Beispiel #5
0
    def read_config(self):
        conf_file = os.path.join(self.get_project_path(), 'sodocu.conf')
        log.debug('conf_file: ' + conf_file)
        config = read_file(conf_file)
        self.set_sodocu_path(os.path.join(self.get_project_path(), config.get('main', 'path')))

        # fill all item options        
        self.clear_item_types()
        for section in config.sections():
            if section != 'main':
                # fix options
                item_type = ItemType(section, config.get(section, 'path'))
                item_type.set_menu_position(config.get(section, 'menu_position'))
                item_type.set_img_url(config.get(section, 'img_url'))
                item_type.set_form_template(config.get(section, 'form_template'))
                item_type.set_table_template(config.get(section, 'table_template'))
                
                # variable relations options
                for option in config.options(section):
                    if option not in Config.FIX_OPTIONS and (option.endswith('_by') or option.endswith('_from')):
                        item_type.add_valid_relation(option, config.get(section, option))
                        
                self.add_item_type(item_type)
Beispiel #6
0
 def test_update_file_new_item(self):
     idea = Idea(ItemType('idea', ''), 'idea-88', 'idea-88')
     assert self.fileHandler.update_file(idea)
     config = read_file(self.project_sodocu_path + '/idea/Idea-88.txt')
     assert 'idea' in config.sections()
Beispiel #7
0
 def test_read_file_failure(self):
     with self.assertRaises(ValueError):
         read_file(self.project_sodocu_path + '/idea/ThisFileDoesNotExists.txt')
Beispiel #8
0
    def test_read_file(self):
#         print self.project_sodocu_path + '/idea/useVCSforRequirements.txt'
        config = read_file(self.project_sodocu_path + '/idea/ThisIsAFileWriterTest.txt')
        assert 'meta' in config.sections()