Esempio n. 1
0
def test_dailyUrlDump():
    """test_dailyUrlDump - test the thing that ropes them all together"""
    conf = sutil.DotDict()
    conf.day = dt.date(2011, 1, 25)
    conf.product = 'Firefloozy,Thunderthigh'
    conf.version = ''
    sql_param = sutil.DotDict()
    sql_param.now_str = "2011-01-26"
    sql_param.yesterday_str = "2011-01-25"
    sql_param.prod_phrase = "and r.product in ('Firefloozy','Thunderthigh')"
    sql_param.ver_phrase = ""
    expected_sql = dailyUrl.sql % sql_param

    fake_logger = exp.DummyObjectWithExpectations()
    fake_logger.expect('debug', ("config.day = %s; now = %s; yesterday = %s",
                                 conf.day, "2011-01-26", "2011-01-25"), {})
    fake_logger.expect('debug', ("SQL is: %s", expected_sql), {})

    fake_database_module = exp.DummyObjectWithExpectations()
    fake_database_pool = exp.DummyObjectWithExpectations()
    fake_database_module.expect('DatabaseConnectionPool',
                                (conf, fake_logger), {}, fake_database_pool)
    fake_database_connection = exp.DummyObjectWithExpectations()
    fake_database_cursor = exp.DummyObjectWithExpectations()
    fake_database_pool.expect('connectionCursorPair', (), {},
                              (fake_database_connection, fake_database_cursor))
    def fake_gzipped_file_context_manager(config):
        yield (1, 2)
    fake_IdCache = exp.DummyObjectWithExpectations()
    fake_IdCache.expect('__call__', (fake_database_cursor,), {}, 'id_cache')
    fake_database_module.expect('execute', (fake_database_cursor, expected_sql),
                                {}, [1,2,3])
    fake_write_row = exp.DummyObjectWithExpectations()
    fake_database_cursor.expect('description', returnValue=['col','col2'])
    fake_write_row.expect('__call__', ((1,2), ['col','col2']), {})

    fake_process_crash = exp.DummyObjectWithExpectations()
    fake_process_crash.expect('__call__', (1, fake_IdCache), {}, [1, 1, 1])
    fake_write_row.expect('__call__', ((1,2), [1, 1, 1]), {})
    fake_process_crash.expect('__call__', (2, fake_IdCache), {}, [2, 2, 2])
    fake_write_row.expect('__call__', ((1,2), [2, 2, 2]), {})
    fake_process_crash.expect('__call__', (3, fake_IdCache), {}, [3, 3, 3])
    fake_write_row.expect('__call__', ((1,2), [3, 3, 3]), {})

    fake_database_pool.expect('cleanup', (), {})

    dailyUrl.dailyUrlDump(conf,
                          sdb=fake_database_module,
                          gzipped_csv_files=fake_gzipped_file_context_manager,
                          IdCache=fake_IdCache,
                          write_row=fake_write_row,
                          process_crash=fake_process_crash,
                          logger=fake_logger)
Esempio n. 2
0
try:
  import config.dailyurlconfig as configModule
except ImportError:
  import dailyurlconfig as configModule

import socorro.lib.ConfigurationManager as configurationManager
import socorro.cron.dailyUrl as url
import socorro.lib.util as sutil

try:
  config = configurationManager.newConfiguration(configurationModule=configModule, applicationName="Daily URL Dump 0.1")
except configurationManager.NotAnOptionError, x:
  print >>sys.stderr, x
  print >>sys.stderr, "for usage, try --help"
  sys.exit()

logger = logging.getLogger("dailyUrlDump")
logger.setLevel(logging.DEBUG)

sutil.setupLoggingHandlers(logger, config)
sutil.echoConfig(logger, config)

try:
  url.dailyUrlDump(config)
finally:
  logger.info("done.")



Esempio n. 3
0
import logging
import logging.handlers

try:
    import config.dailyurlconfig as configModule
except ImportError:
    import dailyurlconfig as configModule

import socorro.lib.ConfigurationManager as configurationManager
import socorro.cron.dailyUrl as url
import socorro.lib.util as sutil

try:
    config = configurationManager.newConfiguration(
        configurationModule=configModule, applicationName="Daily URL Dump 0.1")
except configurationManager.NotAnOptionError, x:
    print >> sys.stderr, x
    print >> sys.stderr, "for usage, try --help"
    sys.exit()

logger = logging.getLogger("dailyUrlDump")
logger.setLevel(logging.DEBUG)

sutil.setupLoggingHandlers(logger, config)
sutil.echoConfig(logger, config)

try:
    url.dailyUrlDump(config)
finally:
    logger.info("done.")