Ejemplo n.º 1
0
class TestBase(unittest.TestCase):

    def setUp(self):
        config = {'sparams': {'bing': 'q', 'google': 'q', 'yahoo': 'p'},
                  'urlmap': {
                    'index': 'index', 'keywordcloud.json': 'keywordcloud',
                    'cleardata': 'cleardata', 'component': 'get_component',
                    'hitmonitor.json': 'hitmonitor',
                    'randomdata': 'randomdata', 'dummydata': 'dummydata',
                    'deviators.json': 'deviators', 'image.gif': 'log_hit'},
                  'dbtype': 'sqlite',
                  'dbfile': ':memory:',
                  'dbhost': 'localhost',
                  'dbuser': '******',
                  'dbpass': '******',
                  'dbname': 'popiview',
                  'recenthits_size': '200',
                  'title_strip': '| brusselnieuws.be',
                  'whitelist_lvl1': '',
                  'keyword_ignorelist': 'brussel, nieuws',
                 }
        self._conf = config
        self._storage = SQLStorage(config)
        self._storage._setup()
        self.now = int(time.time())

    def tearDown(self):
        self._storage._close_connection()
Ejemplo n.º 2
0
def cleanup():
    options, args = parser.parse_args()
    if not options.config_file:
        print "Required option: --config-file"
        exit(1)
    if not os.path.isfile(options.config_file):
        print "Invalid value for option --config-file"
        exit(1)
    config = appconfig('config:' + options.config_file, relative_to=os.getcwd())
    config = ConfigParser(config)
    storage = SQLStorage(config)
    storage.clear_hits(int(options.days))