def test_ec2_start_phase_four_miss_minute(self): event = datetime.fromisoformat('2020-06-26T16:01:00+00:00') event_hour, event_minute = ec2_state_mgmt.get_invoke_time(event) phase = ec2_state_mgmt.get_hour_phase(event_minute) instance = MockInstance('i-1', 'running', [{ 'Key': 'Name', 'Value': 'test' }, { 'Key': 'ec2_stop', 'Value': '16:45' }]) self.assertIs( ec2_state_mgmt._filter_stop_instances(instance, event_hour, phase), False)
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)
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)
def test(self): event = datetime.fromisoformat('2020-06-26T18:30:39+00:00') event_hour, event_minute = ec2_state_mgmt.get_invoke_time(event) self.assertEqual(event_hour, '18') self.assertEqual(event_minute, '30')