def test_check_uptime1(self): now_string = datetime.now(tz=timezone.utc).strftime("%Y-%m-%dT%H:%M:%S") now_string += ".0000000000Z" json_results = { 'State': {'StartedAt': now_string}, } with patch('check_docker.get_url', return_value=json_results): check_docker.check_uptime(container_name='container', warn=10, crit=5) self.assertEqual(check_docker.rc, check_docker.CRITICAL_RC)
def test_check_uptime3(self): ten = timedelta(seconds=10) then = datetime.now(tz=timezone.utc) - ten now_string = then.strftime("%Y-%m-%dT%H:%M:%S") now_string += ".0000000000Z" json_results = { 'State': {'StartedAt': now_string}, } with patch('check_docker.get_url', return_value=json_results): check_docker.check_uptime(container_name='container', warn=2, crit=1) self.assertEqual(check_docker.rc, check_docker.OK_RC)