def test_metadata_item_copied(self):
     restore_files(
         ReplacedFile.objects.filter(
             name__in=['file_four.nc', 'file_five.nc']))
     data_files = DataFile.objects.order_by('name')
     self.assertEqual('v12345678', data_files.last().version)
     self.assertEqual('v87654321', data_files.first().version)
 def test_checksum(self):
     restore_files(
         ReplacedFile.objects.filter(
             name__in=['file_four.nc', 'file_five.nc']))
     data_file = DataFile.objects.get(name='file_five.nc')
     self.assertEqual(1, data_file.checksum_set.count())
     self.assertEqual('76543210',
                      data_file.checksum_set.first().checksum_value)
     self.assertEqual('ADLER32',
                      data_file.checksum_set.first().checksum_type)
def main(args):
    """
    Main entry point
    """
    files = ReplacedFile.objects.filter(
        climate_model__short_name='EC-Earth3P-HR',
        experiment__short_name='highresSST-future',
        rip_code='r1i1p1f1',
        version='v20190514',
    )
    if files.count() != 7454:
        logger.error('{} affected files found'.format(files.count()))
    else:
        logger.debug('{} affected files found'.format(files.count()))

    restore_files(files)
Beispiel #4
0
def main(args):
    """
    Main entry point
    """
    # first add in two missing checksums
    rf = ReplacedFile.objects.get(
        name='tasmin_day_HadGEM3-GC31-LL_highres-future_r1i1p1f1_gn_'
        '20390101-20391230.nc',
        size=20933155)
    rf.checksum_value = '974051111'
    rf.checksum_type = 'ADLER32'
    rf.save()
    rf = ReplacedFile.objects.get(
        name='tasmax_day_HadGEM3-GC31-LL_highres-future_r1i1p1f1_gn_'
        '20390101-20391230.nc',
        size=20657477)
    rf.checksum_value = '739424075'
    rf.checksum_type = 'ADLER32'
    rf.save()

    # now find the files required and restore them
    files = ReplacedFile.objects.filter(
        climate_model__short_name__startswith='HadGEM3-GC31',
        variable_request__table_name='day',
        variable_request__cmor_name__in=['tasmax', 'tasmin']).exclude(
            climate_model__short_name='HadGEM3-GC31-HH',
            experiment__short_name='hist-1950',
            version='v20171213').exclude(
                climate_model__short_name='HadGEM3-GC31-HM',
                experiment__short_name='hist-1950',
                version='v20171024').exclude(
                    climate_model__short_name='HadGEM3-GC31-HM',
                    experiment__short_name='control-1950',
                    version='v20171025')
    logger.debug('{} affected files found'.format(files.count()))

    restore_files(files)
 def test_metadata_foreign_key_copied(self):
     restore_files(
         ReplacedFile.objects.filter(
             name__in=['file_four.nc', 'file_five.nc']))
     data_file = DataFile.objects.get(name='file_four.nc')
     self.assertEqual('experiment', data_file.experiment.short_name)
 def test_files_restored(self):
     restore_files(
         ReplacedFile.objects.filter(
             name__in=['file_four.nc', 'file_five.nc']))
     self.assertEqual(0, ReplacedFile.objects.count())
     self.assertEqual(5, DataFile.objects.count())