# Path: solvebio/contrib/dash/tests/utils.py
# def invincible(func):
#     def wrap():
#         try:
#             return func()
#         except:
#             pass
#     return wrap
# 
# def wait_for(condition_function, get_message=lambda: '', *args, **kwargs):
#     """
#     Waits for condition_function to return True or raises WaitForTimeout.
#     :param (function) condition_function: Should return True on success.
#     :param args: Optional args to pass to condition_function.
#     :param kwargs: Optional kwargs to pass to condition_function.
#         if `timeout` is in kwargs, it will be used to override TIMEOUT
#     :raises: WaitForTimeout If condition_function doesn't return True in time.
#     Usage:
#         def get_element(selector):
#             # some code to get some element or return a `False`-y value.
#         selector = '.js-plotly-plot'
#         try:
#             wait_for(get_element, selector)
#         except WaitForTimeout:
#             self.fail('element never appeared...')
#         plot = get_element(selector)  # we know it exists.
#     """
#     def wrapped_condition_function():
#         """We wrap this to alter the call base on the closure."""
#         if args and kwargs:
#             return condition_function(*args, **kwargs)
#         if args:
#             return condition_function(*args)
#         if kwargs:
#             return condition_function(**kwargs)
#         return condition_function()
# 
#     if 'timeout' in kwargs:
#         timeout = kwargs['timeout']
#         del kwargs['timeout']
#     else:
#         timeout = TIMEOUT
# 
#     start_time = time.time()
#     while time.time() < start_time + timeout:
#         if wrapped_condition_function():
#             return True
#         time.sleep(0.5)
# 
#     raise WaitForTimeout(get_message())


from selenium import webdriver
from .utils import invincible, wait_for
import multiprocessing
import requests
import time
import unittest
import percy
import sys
import os

        if ('PERCY_PROJECT' in os.environ and
                os.environ['PERCY_PROJECT'] == 'solvebio/contrib/dash'):
            loader = percy.ResourceLoader(
                webdriver=cls.driver
            )
            cls.percy_runner = percy.Runner(loader=loader)

            cls.percy_runner.initialize_build()

    @classmethod
    def tearDownClass(cls):
        super(IntegrationTests, cls).tearDownClass()
        cls.driver.quit()
        if ('PERCY_PROJECT' in os.environ and
                os.environ['PERCY_PROJECT'] == 'solvebio/contrib/dash'):
            cls.percy_runner.finalize_build()

    def setUp(self):
        super(IntegrationTests, self).setUp()
        self.driver = webdriver.Chrome()

        def wait_for_element_by_id(id):
            wait_for(lambda: None is not invincible(
                lambda: self.driver.find_element_by_id(id)
            ))
            return self.driver.find_element_by_id(id)
        self.wait_for_element_by_id = wait_for_element_by_id

        def wait_for_element_by_css_selector(css_selector):

# Path: solvebio/contrib/dash/tests/utils.py
# def invincible(func):
#     def wrap():
#         try:
#             return func()
#         except:
#             pass
#     return wrap
# 
# def wait_for(condition_function, get_message=lambda: '', *args, **kwargs):
#     """
#     Waits for condition_function to return True or raises WaitForTimeout.
#     :param (function) condition_function: Should return True on success.
#     :param args: Optional args to pass to condition_function.
#     :param kwargs: Optional kwargs to pass to condition_function.
#         if `timeout` is in kwargs, it will be used to override TIMEOUT
#     :raises: WaitForTimeout If condition_function doesn't return True in time.
#     Usage:
#         def get_element(selector):
#             # some code to get some element or return a `False`-y value.
#         selector = '.js-plotly-plot'
#         try:
#             wait_for(get_element, selector)
#         except WaitForTimeout:
#             self.fail('element never appeared...')
#         plot = get_element(selector)  # we know it exists.
#     """
#     def wrapped_condition_function():
#         """We wrap this to alter the call base on the closure."""
#         if args and kwargs:
#             return condition_function(*args, **kwargs)
#         if args:
#             return condition_function(*args)
#         if kwargs:
#             return condition_function(**kwargs)
#         return condition_function()
# 
#     if 'timeout' in kwargs:
#         timeout = kwargs['timeout']
#         del kwargs['timeout']
#     else:
#         timeout = TIMEOUT
# 
#     start_time = time.time()
#     while time.time() < start_time + timeout:
#         if wrapped_condition_function():
#             return True
#         time.sleep(0.5)
# 
#     raise WaitForTimeout(get_message())


# Path: solvebio/contrib/dash/tests/IntegrationTests.py
from selenium import webdriver
from .utils import invincible, wait_for
import multiprocessing
import requests
import time
import unittest
import percy
import sys
import os


        if ('PERCY_PROJECT' in os.environ and
                os.environ['PERCY_PROJECT'] == 'solvebio/contrib/dash'):
            loader = percy.ResourceLoader(
                webdriver=cls.driver
            )
            cls.percy_runner = percy.Runner(loader=loader)

            cls.percy_runner.initialize_build()

    @classmethod
    def tearDownClass(cls):
        super(IntegrationTests, cls).tearDownClass()
        cls.driver.quit()
        if ('PERCY_PROJECT' in os.environ and
                os.environ['PERCY_PROJECT'] == 'solvebio/contrib/dash'):
            cls.percy_runner.finalize_build()

    def setUp(self):
        super(IntegrationTests, self).setUp()
        self.driver = webdriver.Chrome()

        def wait_for_element_by_id(id):
            wait_for(lambda: None is not invincible(
                lambda: self.driver.find_element_by_id(id)
            ))
            return self.driver.find_element_by_id(id)
        self.wait_for_element_by_id = wait_for_element_by_id

        def wait_for_element_by_css_selector(css_selector):

            wait_for(lambda: None is not invincible(