def __init__(self, *args, **kwargs): super(LongTermBackupRetentionPolicyAction, self).__init__( BackupRetentionPolicyHelper.LONG_TERM_SQL_OPERATIONS, *args, **kwargs) self.backup_type = BackupRetentionPolicyHelper.LongTermBackupType[ self.data.get('backup-type')] retention_period = self.data['retention-period'] retention_period_units = RetentionPeriod.Units[ self.data['retention-period-units']] self.iso8601_duration = RetentionPeriod.iso8601_duration( retention_period, retention_period_units)
def test_iso8601_duration_days(self): duration = RetentionPeriod.iso8601_duration(23, RetentionPeriod.Units.days) self.assertEqual(duration, "P23D")
def test_iso8601_duration_months(self): duration = RetentionPeriod.iso8601_duration( 7, RetentionPeriod.Units.months) self.assertEqual(duration, "P7M")
def test_iso8601_duration_years(self): duration = RetentionPeriod.iso8601_duration( 3, RetentionPeriod.Units.years) self.assertEqual(duration, "P3Y")
def test_iso8601_duration_weeks(self): duration = RetentionPeriod.iso8601_duration( 12, RetentionPeriod.Units.weeks) self.assertEqual(duration, "P12W")