Esempio n. 1
0
    def test_ec2_start_phase_four_miss_minute(self):
        event = datetime.fromisoformat('2020-06-26T07:01:00+00:00')
        event_hour, event_minute = ec2_state_mgmt.get_invoke_time(event)
        phase = ec2_state_mgmt.get_hour_phase(event_minute)
        is_weekend = ec2_state_mgmt.check_if_weekend(event)

        instance = MockInstance('i-1', 'stopped', [{
            'Key': 'Name',
            'Value': 'test'
        }, {
            'Key': 'ec2_start',
            'Value': '07:45'
        }])

        self.assertIs(
            ec2_state_mgmt._filter_start_instances(instance, event_hour, phase,
                                                   is_weekend), False)
Esempio n. 2
0
    def test_weekend_allowed_start(self):
        event = datetime.fromisoformat('2020-06-27T07:13:00+00:00')
        event_hour, event_minute = ec2_state_mgmt.get_invoke_time(event)
        phase = ec2_state_mgmt.get_hour_phase(event_minute)
        is_weekend = ec2_state_mgmt.check_if_weekend(event)

        instance = MockInstance('i-1', 'stopped', [{
            'Key': 'Name',
            'Value': 'test'
        }, {
            'Key': 'ec2_start',
            'Value': '07:00'
        }, {
            'Key': 'ec2_start_on_weekends',
            'Value': 'true'
        }])

        self.assertIs(
            ec2_state_mgmt._filter_start_instances(instance, event_hour, phase,
                                                   is_weekend), True)
Esempio n. 3
0
 def test_weekday(self):
     event = datetime.fromisoformat('2020-06-26T18:30:39+00:00')
     is_weekend = ec2_state_mgmt.check_if_weekend(event)
     self.assertEqual(is_weekend, False)