def test_set_methods(self):
        """ this tests all of the set methods since they need to work together """
        save_config_file = config.ConfigObject.CONFIG_FILE

        # Test the default with no file is 'unittest'
        config.reset()
        config.ConfigObject.CONFIG_FILE = 'badfile.xxx'
        self.assertEqual(config.get_environment(), 'unittest')

        config.ConfigObject.CONFIG_FILE = save_config_file

        # test that if we the database name we have an unknown environmentwe
        config.reset()
        config.set_database_name('MyTest.db')
        self.assertEqual(config.get_environment(), '????')
        os.remove('MyTest.db')

        # test that if we the database name we have an unknown environmentwe
        config.reset()
        config.set_enviornment('test')
        self.assertTrue(config.get_database_name())

        # test that we have an instance and database
        config.reset()
        self.assertTrue(config.get_environment(
        ))  # All these values must be set... Can't test to what though
        self.assertTrue(config.get_database_name())
        self.assertTrue(config.get_database_instance())
        self.assertTrue(config.get_database())
 def test_set_methods(self):
     """ this tests all of the set methods since they need to work together """
     save_config_file = config.ConfigObject.CONFIG_FILE 
     
     # Test the default with no file is 'unittest'
     config.reset()
     config.ConfigObject.CONFIG_FILE = 'badfile.xxx'
     self.assertEqual(config.get_environment(), 'unittest')
     
     config.ConfigObject.CONFIG_FILE = save_config_file
     
     # test that if we the database name we have an unknown environmentwe
     config.reset()
     config.set_database_name(':memory:')
     self.assertEqual(config.get_environment(), '????')
     
     # test that if we the database name we have an unknown environmentwe
     config.reset()
     config.set_enviornment('test')
     self.assertTrue(config.get_database_name())
     
     # test that we have an instance and database
     config.reset()
     self.assertTrue(config.get_environment()) # All these values must be set... Can't test to what though
     self.assertTrue(config.get_database_name())
     self.assertTrue(config.get_database_instance())
     self.assertTrue(config.get_database())
Exemple #3
0
def get_link_row():
    utils = Utils()
    db = config.get_database()
    try:
        print('AppServer.get_link_row running', request.method)
        print('Instance:', config.get_database_name(),
              config.get_environment())
        print('Tables', config.get_database_instance().get_table_names())
        data = utils.json_decode(request)
        link = db.select("LinkTab",
                         TabName=data['TabName'],
                         AttrName=data['AttrName'])
        print('link', link)
        if not link:
            data['ID'] = 0
            data['LinkName'] = ''
            data['BaseTab'] = 0
            data['ShowAttrs'] = ''
        else:
            data['ID'] = link[0].ID
            data['LinkName'] = link[0].LinkName
            data['BaseTab'] = link[0].BaseTab
            data['ShowAttrs'] = link[0].ShowAttrs

        return json.dumps(data)

    except Exception as e:
        print('AppServer.link: ***Error:', e)
        traceback.print_exc(file=sys.stdout)
def get_link_row():
    utils = Utils()
    db = config.get_database()
    try:
        print('AppServer.get_link_row running', request.method)
        print('Instance:', config.get_database_name(), config.get_environment())
        print('Tables', config.get_database_instance().get_table_names())
        data = utils.json_decode(request)
        link = db.select("LinkTab", TabName=data['TabName'], AttrName=data['AttrName'])
        print('link', link)
        if not link:
            data['ID'] = 0
            data['LinkName'] = ''
            data['BaseTab'] = 0
            data['ShowAttrs'] = ''
        else:
            data['ID'] = link[0].ID
            data['LinkName'] = link[0].LinkName
            data['BaseTab'] = link[0].BaseTab
            data['ShowAttrs'] = link[0].ShowAttrs

        return json.dumps(data)

    except Exception as e:
        print('AppServer.link: ***Error:', e)
        traceback.print_exc(file=sys.stdout)
Exemple #5
0
 def create_db(self, db_name):
     if db_name is None:
         return self.mongodb_client[config.get_database_name()]
     return self.mongodb_client[db_name]
Exemple #6
0
 def test_get_database_name(self):
     expected_db_name = self.expected_config.get('database', 'name')
     db_name = config.get_database_name()
     self.assertEqual(expected_db_name, db_name)