示例#1
0
def test_request_do_update_all(test_dao, test_common_dao, test_configuration):
    """ request_do_update_all() should return False on success. """
    DUT = dtcOptions(
        test_dao, test_configuration, site_dao=test_common_dao, test='True')
    DUT.request_do_select_all(site=True, program=True)

    assert not DUT.request_do_update()
示例#2
0
def test_create_options_data_controller(test_dao, test_common_dao,
                                        test_configuration):
    """ __init__() should return instance of Options data controller. """
    DUT = dtcOptions(
        test_dao, test_configuration, site_dao=test_common_dao, test='True')

    assert isinstance(DUT, dtcOptions)
    assert isinstance(DUT._dtm_data_model, dtmOptions)
示例#3
0
def test_request_set_options_program(test_dao, test_common_dao, test_configuration):
    """ request_set_options() should return False when successfully setting program options. """
    DUT = dtcOptions(
        test_dao, test_configuration, site_dao=test_common_dao, test='True')
    DUT.request_do_select_all(site=True, program=True)

    _options = DUT.request_get_options(site=False, program=True)
    _options['function_active'] == 0

    (_error_code, _msg) = DUT.request_set_options(_options, site=False, program=True)

    assert _error_code == 0
    assert _msg == 'RAMSTK SUCCESS: Updating RAMSTKProgramInfo attributes.'
示例#4
0
def test_request_get_options_site(test_dao, test_common_dao, test_configuration):
    """ request_get_options() should return a dict of site option:value pairs. """
    DUT = dtcOptions(
        test_dao, test_configuration, site_dao=test_common_dao, test='True')
    DUT.request_do_select_all(site=True, program=True)

    _options = DUT.request_get_options(site=True, program=False)

    assert isinstance(_options, dict)
    assert _options['function_enabled'] == 0
    assert _options['requirement_enabled'] == 0
    assert _options['hardware_enabled'] == 0
    assert _options['vandv_enabled'] == 0
    assert _options['fmea_enabled'] == 0
示例#5
0
def test_request_get_options_program(test_dao, test_common_dao, test_configuration):
    """ request_get_options() should return a dict of program option:value pairs. """
    DUT = dtcOptions(
        test_dao, test_configuration, site_dao=test_common_dao, test='True')
    DUT.request_do_select_all(site=True, program=True)

    _options = DUT.request_get_options(site=False, program=True)

    assert isinstance(_options, dict)
    assert _options['function_active'] == 1
    assert _options['requirement_active'] == 1
    assert _options['hardware_active'] == 1
    assert _options['vandv_active'] == 1
    assert _options['fmea_active'] == 1
    assert _options['created_by'] == ''
    assert _options['created_on'] == date.today()
    assert _options['last_saved_by'] == ''
    assert _options['last_saved'] == date.today()
    assert _options['method'] == 'STANDARD'
示例#6
0
    def __init__(self, **kwargs):
        """Initialize an instance of the RAMSTK data controller."""
        # Read the site configuration file.
        self.RAMSTK_CONFIGURATION.set_site_variables()
        if self.RAMSTK_CONFIGURATION.set_user_variables():
            _prompt = _(
                u"A user-specific configuration directory could not "
                u"be found at {0:s}.  You will be given the option to "
                u"create and populate this directory.  If you choose "
                u"not to, you will recieve this prompt every time you "
                u"execute RAMSTK.  Would you like to create and populate "
                u"a user-specific configuration directory?").format(
                    self.RAMSTK_CONFIGURATION.RAMSTK_HOME_DIR +
                    "/.config/RAMSTK")
            _dialog = ramstk.RAMSTKMessageDialog(_prompt, '', 'question')
            _response = _dialog.do_run()
            _dialog.do_destroy()

            if _response == gtk.RESPONSE_YES:
                self.RAMSTK_CONFIGURATION.create_user_configuration()

            self.RAMSTK_CONFIGURATION.set_user_variables(first_run=False)

        self.RAMSTK_CONFIGURATION.get_user_configuration()

        # Create loggers.
        (self.RAMSTK_CONFIGURATION.RAMSTK_DEBUG_LOG,
         self.RAMSTK_CONFIGURATION.RAMSTK_USER_LOG,
         self.RAMSTK_CONFIGURATION.RAMSTK_IMPORT_LOG) = \
            _initialize_loggers(self.RAMSTK_CONFIGURATION)

        # Initialize private dictionary instance attributes.

        # Initialize private list instance attributes.
        self.__test = kwargs['test']
        self._lst_modules = [
            'requirement', 'function', 'hardware', 'validation'
        ]

        # Initialize private scalar instance attributes.

        # Initialize public dictionary instance attributes.
        self.dic_controllers = {
            'options': None,
            'allocation': None,
            'definition': None,
            'function': None,
            'revision': None,
            'requirement': None,
            'hardware': None,
            'validation': None,
            'matrices': None,
            'profile': None,
            'ffmea': None,
            'fmea': None,
            'stakeholder': None,
            'hazard': None,
            'similaritem': None,
            'pof': None,
            'imports': None,
            'exports': None,
        }
        self.dic_books = {
            'listbook': None,
            'modulebook': None,
            'workbook': None
        }

        # Define public list attributes.

        # Define public scalar attributes.
        self.icoStatus = gtk.StatusIcon()
        self.loaded = False

        # Connect to the RAMSTK Common database.
        _database = None
        if self.RAMSTK_CONFIGURATION.RAMSTK_COM_BACKEND == 'sqlite':
            _database = self.RAMSTK_CONFIGURATION.RAMSTK_COM_BACKEND + \
                        ':///' + \
                        self.RAMSTK_CONFIGURATION.RAMSTK_COM_INFO['database']
        _dao = DAO()
        _dao.db_connect(_database)

        # Create an instance of the RAMSTK Data Model and load global constants.
        self.ramstk_model = Model(_dao, DAO())
        self.request_do_load_globals()

        # Create an Options module instance and read the Site options.
        self.dic_controllers['options'] = dtcOptions(
            self.ramstk_model.program_dao,
            self.RAMSTK_CONFIGURATION,
            site_dao=_dao,
            test=False)
        self.dic_controllers['options'].request_do_select_all(site=True,
                                                              program=False)

        # Create a Preferences module instance and read the user preferences.
        self.dic_controllers['preferences'] = dtcPreferences(
            self.ramstk_model.program_dao,
            self.RAMSTK_CONFIGURATION,
            site_dao=_dao,
            test=False)
        self.dic_controllers['preferences'].request_do_select_all(site=True,
                                                                  user=True)

        # Create an Import module instance.
        self.dic_controllers['imports'] = dtcImports(
            self.ramstk_model.program_dao,
            self.RAMSTK_CONFIGURATION,
            test=False)

        # Create an Export module instance.
        self.dic_controllers['exports'] = dtcExports(
            self.ramstk_model.program_dao,
            self.RAMSTK_CONFIGURATION,
            test=False)

        # Validate the license.
        # if self._validate_license():
        #    sys.exit(2)

        # Create RAMSTK Books.  These need to be initialized after reading the
        # configuration.
        if self.RAMSTK_CONFIGURATION.RAMSTK_GUI_LAYOUT == 'basic':  # Single window.
            pass
        else:  # Multiple windows.
            self.dic_books['listbook'] = ListBook(self)
            self.dic_books['modulebook'] = ModuleBook(self)
            self.dic_books['workbook'] = WorkBook(self)

        _icon = self.RAMSTK_CONFIGURATION.RAMSTK_ICON_DIR + \
            '/32x32/db-disconnected.png'
        _icon = gtk.gdk.pixbuf_new_from_file_at_size(_icon, 22, 22)
        self.icoStatus.set_from_pixbuf(_icon)
        self.icoStatus.set_tooltip(
            _(u"RAMSTK is not currently connected to a "
              u"project database."))
示例#7
0
def test_request_do_select_all(test_dao, test_common_dao, test_configuration):
    """ request_do_select_all() should return a Tree of RAMSTKOptions data models. """
    DUT = dtcOptions(
        test_dao, test_configuration, site_dao=test_common_dao, test='True')

    assert not DUT.request_do_select_all(site=True, program=True)