Example #1
0
def test_date_to_weekly_partition_with_string():
    datestring = '2015-01-09'
    partition_exp = '20150105'

    partition = datetimeutil.datestring_to_weekly_partition(datestring)
    assert partition == partition_exp

    # Is there a better way of testing that we handle 'now' as a date value?
    datestring = 'now'
    date_now = datetime.datetime.now().date()
    partition_exp = (date_now + datetime.timedelta(0 - date_now.weekday())).strftime('%Y%m%d')
    partition = datetimeutil.datestring_to_weekly_partition(datestring)
    assert partition == partition_exp
Example #2
0
def test_date_to_weekly_partition_with_string():
    datestring = '2015-01-09'
    partition_exp = '20150105'

    partition = datetimeutil.datestring_to_weekly_partition(datestring)
    eq_(partition, partition_exp)

    # Is there a better way of testing that we handle 'now' as a date value?
    datestring = 'now'
    date_now = datetime.datetime.now().date()
    partition_exp = (
        date_now +
        datetime.timedelta(0 - date_now.weekday())).strftime('%Y%m%d')
    partition = datetimeutil.datestring_to_weekly_partition(datestring)
    eq_(partition, partition_exp)
Example #3
0
 def _action(self, raw_crash, raw_dumps, processed_crash, processor_meta):
     try:
         date = processed_crash['date_processed']
         # update partition information based on date processed
         sql = self.sql % datestring_to_weekly_partition(date)
         for module in processed_crash['json_dump']['modules']:
             try:
                 if module['missing_symbols']:
                     self.transaction(
                         execute_no_results,
                         sql,
                         (
                             date,
                             module['debug_file'],
                             module['debug_id']
                         )
                     )
             except self.database.ProgrammingError:
                 processor_meta.processor_notes.append(
                     "WARNING: missing symbols rule failed for"
                     " %s" % raw_crash.uuid
                 )
             except KeyError:
                 pass
     except KeyError:
         return False
     return True
 def _action(self, raw_crash, raw_dumps, processed_crash, processor_meta):
     try:
         date = processed_crash['date_processed']
         # update partition information based on date processed
         sql = self.sql % datestring_to_weekly_partition(date)
         for module in processed_crash['json_dump']['modules']:
             try:
                 if module['missing_symbols']:
                     self.transaction(
                         execute_no_results,
                         sql,
                         (
                             date,
                             module['debug_file'],
                             module['debug_id']
                         )
                     )
             except self.database.ProgrammingError as e:
                 processor_meta.processor_notes.append(
                     "WARNING: missing symbols rule failed for"
                     " %s" % raw_crash.uuid
                 )
             except KeyError:
                 pass
     except KeyError:
         return False
     return True
Example #5
0
def test_date_to_weekly_partition_with_datetime():
    proposed_and_expected = (
        (datetime.datetime(2014, 12, 29), '20141229'),
        (datetime.datetime(2014, 12, 30), '20141229'),
        (datetime.datetime(2014, 12, 31), '20141229'),
        (datetime.datetime(2015, 1, 1), '20141229'),
        (datetime.datetime(2015, 1, 2), '20141229'),
        (datetime.datetime(2015, 1, 3), '20141229'),
        (datetime.datetime(2015, 1, 4), '20141229'),
        (datetime.datetime(2015, 1, 5), '20150105'),
        (datetime.datetime(2015, 1, 6), '20150105'),
        (datetime.datetime(2015, 1, 7), '20150105'),
        (datetime.datetime(2015, 1, 8), '20150105'),
        (datetime.datetime(2015, 1, 9), '20150105'),
    )
    for to_be_tested, expected in proposed_and_expected:
        result = datetimeutil.datestring_to_weekly_partition(to_be_tested)
        eq_(result, expected)
Example #6
0
def test_date_to_weekly_partition_with_datetime():
    proposed_and_expected = (
        (datetime.datetime(2014, 12, 29), '20141229'),
        (datetime.datetime(2014, 12, 30), '20141229'),
        (datetime.datetime(2014, 12, 31), '20141229'),
        (datetime.datetime(2015,  1,  1), '20141229'),
        (datetime.datetime(2015,  1,  2), '20141229'),
        (datetime.datetime(2015,  1,  3), '20141229'),
        (datetime.datetime(2015,  1,  4), '20141229'),
        (datetime.datetime(2015,  1,  5), '20150105'),
        (datetime.datetime(2015,  1,  6), '20150105'),
        (datetime.datetime(2015,  1,  7), '20150105'),
        (datetime.datetime(2015,  1,  8), '20150105'),
        (datetime.datetime(2015,  1,  9), '20150105'),
    )
    for to_be_tested, expected in proposed_and_expected:
        result = datetimeutil.datestring_to_weekly_partition(to_be_tested)
        eq_(result, expected)
Example #7
0
 def _action(self, raw_crash, raw_dumps, processed_crash, processor_meta):
     try:
         date = processed_crash['date_processed']
         # update partition information based on date processed
         sql = self.sql % datestring_to_weekly_partition(date)
         for module in processed_crash['json_dump']['modules']:
             try:
                 # First of all, only bother if there are
                 # missing_symbols in this module.
                 # And because it's not useful if either of debug_file
                 # or debug_id are empty, we filter on that here too.
                 if (
                     module['missing_symbols'] and
                     module['debug_file'] and
                     module['debug_id']
                 ):
                     self.transaction(
                         execute_no_results,
                         sql,
                         (
                             date,
                             module['debug_file'],
                             module['debug_id'],
                             # These two use .get() because the keys
                             # were added later in history. If it's
                             # non-existent (or existant and None), it
                             # will proceed and insert as a nullable.
                             module.get('filename'),
                             module.get('code_id'),
                         )
                     )
             except self.database.ProgrammingError:
                 processor_meta.processor_notes.append(
                     "WARNING: missing symbols rule failed for"
                     " %s" % raw_crash.uuid
                 )
             except KeyError:
                 pass
     except KeyError:
         return False
     return True
Example #8
0
def test_date_to_weekly_partition_with_datetime(data, expected):
    assert datetimeutil.datestring_to_weekly_partition(data) == expected
Example #9
0
def test_date_to_weekly_partition_with_datetime(data, expected):
    assert datetimeutil.datestring_to_weekly_partition(data) == expected