Exemplo n.º 1
0
 def test_datetime_is_iso(self):
     """
     Test that ISO 8601 dates are properly parsed, and non ISO 8601 dates
     are excluded
     """
     good_datetime = '2011-01-21T02:30:11Z'
     self.assertTrue(util.datetime_is_iso(good_datetime)[0])
     # we need to fail on non-ISO 8601 compliant dates
     bad_datetime = '21 Dec 2015 10:02 PM'
     self.assertFalse(util.datetime_is_iso(bad_datetime)[0])
Exemplo n.º 2
0
 def test_datetime_is_iso(self):
     """
     Test that ISO 8601 dates are properly parsed, and non ISO 8601 dates
     are excluded
     """
     good_datetime = '2011-01-21T02:30:11Z'
     self.assertTrue(util.datetime_is_iso(good_datetime)[0])
     # we need to fail on non-ISO 8601 compliant dates
     bad_datetime = '21 Dec 2015 10:02 PM'
     self.assertFalse(util.datetime_is_iso(bad_datetime)[0])
Exemplo n.º 3
0
 def check_date_created(self, ds):
     #Check if date created is ISO
     if not hasattr(ds, u'date_created'):
         return
     date_created_check, msgs = datetime_is_iso(getattr(ds, u'date_created'))
     return Result(BaseCheck.MEDIUM, date_created_check,
                   'date_created_is_iso', msgs)
Exemplo n.º 4
0
 def check_date_issued_is_iso(self, ds):
     #Checks if date issued field is ISO compliant
     if not hasattr(ds, u'date_issued'):
         return
     date_issued_check, msgs = datetime_is_iso(getattr(ds, u'date_issued'))
     return Result(BaseCheck.MEDIUM, date_issued_check,
                   'date_issued_is_iso', msgs)
Exemplo n.º 5
0
 def check_date_created(self, ds):
     #Check if date created is ISO
     if not hasattr(ds, u'date_created'):
         return
     date_created_check, msgs = datetime_is_iso(getattr(
         ds, u'date_created'))
     return Result(BaseCheck.MEDIUM, date_created_check,
                   'date_created_is_iso', msgs)
Exemplo n.º 6
0
 def _check_attr_is_iso_date(attr, ds):
     result_name = "{}_is_iso".format(attr)
     if not hasattr(ds, attr):
         return ratable_result((0, 2), result_name,
                               ["Attr {} is not present".format(attr)])
     else:
         iso_check, msgs = datetime_is_iso(getattr(ds, attr))
         return ratable_result((1 + iso_check, 2), result_name, msgs)
Exemplo n.º 7
0
 def _check_attr_is_iso_date(attr, ds):
     result_name = "{}_is_iso".format(attr)
     if not hasattr(ds, attr):
         return ratable_result((0,2), result_name,
                               ["Attr {} is not present".format(attr)])
     else:
         iso_check, msgs = datetime_is_iso(getattr(ds, attr))
         return ratable_result((1 + iso_check, 2),
                               result_name, msgs)
Exemplo n.º 8
0
    def check_date_metadata_modified_is_iso(self, ds):
        '''
        Checks if date metadata modified field is ISO compliant

        :param netCDF4.Dataset ds: An open netCDF dataset
        '''
        if not hasattr(ds, u'date_metadata_modified'):
            return
        date_metadata_modified_check, msgs = datetime_is_iso(getattr(ds, u'date_metadata_modified'))
        return Result(BaseCheck.MEDIUM, date_metadata_modified_check, 'date_metadata_modified_is_iso', msgs)
Exemplo n.º 9
0
    def check_date_metadata_modified_is_iso(self, ds):
        '''
        Checks if date metadata modified field is ISO compliant

        :param netCDF4.Dataset ds: An open netCDF dataset
        '''
        if not hasattr(ds, u'date_metadata_modified'):
            return
        date_metadata_modified_check, msgs = datetime_is_iso(getattr(ds, u'date_metadata_modified'))
        return Result(BaseCheck.MEDIUM, date_metadata_modified_check, 'date_metadata_modified_is_iso', msgs)
Exemplo n.º 10
0
    def check_date_created(self, ds):
        '''
        Check if date created is ISO-8601

        :param netCDF4.Dataset ds: An open netCDF dataset
        '''
        if not hasattr(ds, u'date_created'):
            return
        date_created_check, msgs = datetime_is_iso(getattr(ds, u'date_created'))
        return Result(BaseCheck.MEDIUM, date_created_check,
                      'date_created_is_iso', msgs)
Exemplo n.º 11
0
    def check_date_created(self, ds):
        '''
        Check if date created is ISO-8601

        :param netCDF4.Dataset ds: An open netCDF dataset
        '''
        if not hasattr(ds, u'date_created'):
            return
        date_created_check, msgs = datetime_is_iso(getattr(ds, u'date_created'))
        return Result(BaseCheck.MEDIUM, date_created_check,
                      'date_created_is_iso', msgs)
Exemplo n.º 12
0
 def check_date_metadata_modified_is_iso(self, ds):
     #Checks if date metadata modified field is ISO compliant
     if not hasattr(ds, u'date_metadata_modified'):
         return
     date_metadata_modified_check, msgs = datetime_is_iso(getattr(ds, u'date_metadata_modified'))
     return Result(BaseCheck.MEDIUM, date_metadata_modified_check, 'date_metadata_modified_is_iso', msgs)
Exemplo n.º 13
0
    def test_datetime_is_iso(self):
        """
        Test that ISO 8601 dates are properly parsed, and non ISO 8601 dates
        are excluded
        """
        good_datetime = "2011-01-21T02:30:11Z"
        self.assertTrue(util.datetime_is_iso(good_datetime)[0])

        good_date = "2017-02-01"
        self.assertTrue(util.datetime_is_iso(good_date)[0])

        good_date = "20170201"
        self.assertTrue(util.datetime_is_iso(good_date)[0])

        good_datetime = "2017-09-19T23:06:17+00:00"
        self.assertTrue(util.datetime_is_iso(good_datetime)[0])

        good_datetime = "20170919T230617Z"
        self.assertTrue(util.datetime_is_iso(good_datetime)[0])

        good_date = "2017-W38"
        self.assertTrue(util.datetime_is_iso(good_date)[0])

        good_date = "2017-W38-2"
        self.assertTrue(util.datetime_is_iso(good_date)[0])

        good_date = "2017-262"
        self.assertTrue(util.datetime_is_iso(good_date)[0])

        # we need to fail on non-ISO 8601 compliant dates
        bad_datetime = "21 Dec 2015 10:02 PM"
        self.assertFalse(util.datetime_is_iso(bad_datetime)[0])

        # Month first is not ISO-8601 compliant
        bad_datetime = "09192017T230617Z"
        self.assertFalse(util.datetime_is_iso(bad_datetime)[0])

        bad_date = "09192017"
        self.assertFalse(util.datetime_is_iso(bad_datetime)[0])
Exemplo n.º 14
0
    def test_datetime_is_iso(self):
        """
        Test that ISO 8601 dates are properly parsed, and non ISO 8601 dates
        are excluded
        """
        good_datetime = '2011-01-21T02:30:11Z'
        self.assertTrue(util.datetime_is_iso(good_datetime)[0])

        good_date = '2017-02-01'
        self.assertTrue(util.datetime_is_iso(good_date)[0])

        good_date = '20170201'
        self.assertTrue(util.datetime_is_iso(good_date)[0])

        good_datetime = '2017-09-19T23:06:17+00:00'
        self.assertTrue(util.datetime_is_iso(good_datetime)[0])

        good_datetime = '20170919T230617Z'
        self.assertTrue(util.datetime_is_iso(good_datetime)[0])

        good_date = '2017-W38'
        self.assertTrue(util.datetime_is_iso(good_date)[0])

        good_date = '2017-W38-2'
        self.assertTrue(util.datetime_is_iso(good_date)[0])

        good_date = '2017-262'
        self.assertTrue(util.datetime_is_iso(good_date)[0])

        # we need to fail on non-ISO 8601 compliant dates
        bad_datetime = '21 Dec 2015 10:02 PM'
        self.assertFalse(util.datetime_is_iso(bad_datetime)[0])

        # Month first is not ISO-8601 compliant
        bad_datetime = '09192017T230617Z'
        self.assertFalse(util.datetime_is_iso(bad_datetime)[0])

        bad_date = '09192017'
        self.assertFalse(util.datetime_is_iso(bad_datetime)[0])