Esempio n. 1
0
 def test_will_instance_run(self):
     # no project tag
     instance_tags = eval("""{u'Name': u'veripark-poc-mgmt', u'poc': u'yes'}""")
     self.assertEqual(None, stayontop.will_instance_run(instance_tags))
     # not in restricted projects
     instance_tags = eval("""{u'project': u'SAP', u'role': u'platformservices', u'Name': u'sapdsips.acme.com'}""")
     self.assertEqual(None, stayontop.will_instance_run(instance_tags))
     # in restricted projects but not in keep_running
     instance_tags = eval("""{u'project': u'CRM', u'Name': u'web.acme.com'}""")
     next_state = 'running' if stayontop.is_working_hours() else 'stopped'
     self.assertEqual(next_state, stayontop.will_instance_run(instance_tags))
     # in restricted projects and in keep_running
     instance_tags = eval("""{u'project': u'CRM', u'Name': u'hana01.acme.com'}""")
     self.assertEqual('running', stayontop.will_instance_run(instance_tags))
     # in restricted projects and in keep_stopped
     instance_tags = eval("""{u'project': u'CRM', u'Name': u'hanadyn.acme.com'}""")
     self.assertEqual('stopped', stayontop.will_instance_run(instance_tags))
     # in restricted projects and both in keep_stopped and keep_running
     instance_tags = eval("""{u'project': u'CRM', u'Name': u'sybase.acme.com'}""")
     self.assertEqual('stopped', stayontop.will_instance_run(instance_tags))
     # project is both in restricted and weekend on
     instance_tags = eval("""{u'project': u'PUSHAPP', u'Name': u'push01.acme.com'}""")
     self.assertEqual('running' if stayontop.is_working_hours() else 'stopped', stayontop.will_instance_run(instance_tags))
     # project is both in restricted and weekend on, instance in keep_stopped
     instance_tags = eval("""{u'project': u'PUSHAPP', u'Name': u'apush.acme.com'}""")
     self.assertEqual('stopped', stayontop.will_instance_run(instance_tags))
Esempio n. 2
0
 def test_is_working_hours(self):
     working_hours = 7 <= self.hour < 19
     weekend = self.day in (5, 6)
     # test is_holiday flag
     stayontop.config.set('is_holiday', False)
     self.assertEqual(stayontop.is_working_hours(ignore_weekend=True), working_hours)
     stayontop.config.set('is_holiday', True)
     self.assertEqual(stayontop.is_working_hours(ignore_weekend=True), False)
     stayontop.config.set('is_holiday', False)
     self.assertEqual(stayontop.is_working_hours(), not weekend and working_hours)