示例#1
0
 def test_config_override(self):
     config = ProjectConfig.ProjectConfig(StringIO.StringIO(testconfig))
     self.assertEqual(config.getloglevel('Analyze', 'log_level'),
                      logging.DEBUG)
     config.set('Analyze', 'log_level', 'CRITICAL')
     self.assertEqual(config.getloglevel('Analyze', 'log_level'),
                      logging.CRITICAL)
示例#2
0
    def test_clearcase(self):
        configstr = '[ClearCase]\n'\
                    'path_to_cleartool:   cleartool\n'

        config = ProjectConfig.ProjectConfig(StringIO.StringIO(configstr))
        self.assertEqual(config.get_vcs(), 'ClearCase')
        self.assertEqual(config.get('ClearCase', 'path_to_cleartool'),
                         'cleartool')
示例#3
0
    def test_all_values_in_template(self):
        realfile = repo_root + "/project.config.template"
        self.assertTrue(os.path.isfile(realfile))
        parser = ProjectConfig.ProjectConfig(config=realfile)

        for def_section, def_options in ProjectConfig.defaults.iteritems():
            self.assertIn(def_section, parser.sections())
            for def_option, _ in def_options.iteritems():
                self.assertTrue(parser.has_option(def_section, def_option))
示例#4
0
    def test_git(self):
        configstr = '[Git]\n'\
                    'path_to_git:   path_to_git\n'\
                    'repo:   some_repo_path\n'

        config = ProjectConfig.ProjectConfig(StringIO.StringIO(configstr))
        self.assertEqual(config.get_vcs(), 'Git')
        self.assertEqual(config.get('Git', 'path_to_git'), 'path_to_git')
        self.assertEqual(config.get('Git', 'repo'), 'some_repo_path')
示例#5
0
    def test_multiline_config(self):
        config = ProjectConfig.ProjectConfig(
            StringIO.StringIO(testmultioption))
        self.assertEqual(config.getlist('Filter', 'filter'),
                         ['option1', 'option2', 'option3'])
        self.assertEqual(config.get('Filter', 'other_option'), 'option4')

        self.assertEqual(config.getboolean('OtherSection', 'boolean_option'),
                         True)
        self.assertEqual(config.getint('OtherSection', 'int_option'), 42)
示例#6
0
    def OKButtonClicked(self):

        ConfigFile = self.ProjectFileLayout.LineEdit.text()

        Config = ProjectConfig.ProjectConfig()

        if (Config.ConfigExists(ConfigFile)):
            print("Already exists, read, mod, write !")
        else:
            Config.AddSectionAndData("General Project", "Project Name",
                                     self.ProjectNameLayout.LineEdit.text())

            Config.AddSectionAndData("General Project", "Test Bench Name",
                                     self.TestBenchNameLayout.LineEdit.text())

            Config.WriteFile()

        self.accept()
        return
示例#7
0
    def test_complete_config(self):
        config = ProjectConfig.ProjectConfig(StringIO.StringIO(testconfig))

        self.assertEqual(config.getint('Analyze', 'threads'), 5)
        self.assertEqual(config.get('Analyze', 'dbtype'), 'sqlite')
        self.assertEqual(config.getboolean('Analyze', 'lookup_email'), False)
        self.assertEqual(config.getloglevel('Analyze', 'log_level'),
                         logging.DEBUG)
        self.assertEqual(config.get('Analyze', 'log_path'),
                         './some_path_to_log.log')
        self.assertEqual(config.get('Analyze', 'log_format'),
                         '%(asctime)s <%(levelname)s>: %(message)s')
        self.assertEqual(
            config.getlist('Analyze', 'code_transformer'),
            ['.sbs: some_path arg1 arg2', '.random: some_other_path arg1'])
        self.assertEqual(config.getlist('General', 'filefilters'),
                         ['*.a', '*.so', '*.so.*', '*Some/path*'])
        self.assertEqual(config.get('General', 'defect_modification_regexp'),
                         '*[bug:*|*fix[es]?:*')

        self.assertEqual(config.get('MetricsViewer', 'dbtype'), 'sqlite')
示例#8
0
import requests
import json
import unittest
import ProjectConfig

# Initialize Base URL
base_URL = ProjectConfig.intialize_appurl()


class ErrorData(unittest.TestCase):
    def test_get_Error_User_Response(self):
        # Send GET request for 11th user
        response_users = requests.get(base_URL + "/users/11")

        # Check Response for 11th /users
        total_users = len(response_users.json())
        print("Total number of users is more than zero")
        self.assertFalse(len(response_users.json()) > 0)

    def test_get_Error_Album_Response(self):
        # Send GET request for /Albums
        response_album = requests.get(base_URL + "/albums/115")

        # Check Response for 115th /Albums
        total_users = len(response_album.json())
        print("Total number of albums is more than zero")
        self.assertFalse(len(response_album.json()) > 0)


if __name__ == '__main__':
    unittest.main()
示例#9
0
 def test_overridden_default(self):
     config = ProjectConfig.ProjectConfig(StringIO.StringIO(testconfig))
     self.assertEqual(config.get('Analyze', 'unknown_attribute', 100), 100)
     self.assertRaises(ConfigParser.NoOptionError, config.get, 'Analyze',
                       'unknown_attribute')
示例#10
0
# You should have received a copy of the GNU General Public License
# along with Reqy.  If not, see <http://www.gnu.org/licenses/>.

import Utility
from ProjectConfig import *
import os
import gettext
import locale
import sys

def init_localization():
	'''prepare l10n'''
	locale_str = locale.getdefaultlocale()[0]
	l10n_file = "%s/requirements/l10n/%s.mo" % (sys.path[0], locale_str)

	try:
		trans = gettext.GNUTranslations(open( l10n_file, "rb" ) )
	except IOError:
		if locale_str != 'en_US':
			Utility.report_warning('Unable to find translation for %s, using default (en_US)' % (locale_str))
		trans = gettext.NullTranslations()

	trans.install(unicode=1)

init_localization()

project = ProjectConfig()
project.load_config_from_file(os.path.join(Utility.get_repo_dir(), 'project.conf'))