# CONFIDENTIAL. (C) 2017 OpenEye Scientific Software Inc.
# All rights reserved.
#
# ALL SOFTWARE BELOW IS PROPRIETARY AND CONFIDENTIAL TO OPENEYE
# SCIENTIFIC SOFTWARE INC., AND IS SUBJECT TO THE FULL PROTECTION OF
# COPYRIGHT AND TRADESECRET LAW.
# Copying or modifying this software is strictly prohibited and illegal.
# Using this software without a valid license from OpenEye is strictly
# prohibited and illegal. De-obfuscating, de-minimizing, or any other
# attempt to reverse engineer or discover the workings of this software,
# is strictly prohibited. Even if software is exposed or visible, it is
# still proprietary and confidential and the above prohibitions apply.
# This software is NOT "Sample Code". For purposes of customization or
# interoperation with other software you must use Sample Code
# specifically labeled as such.
# Please contact OpenEye at eyesopen.com/legal if you have any questions
# about this warning.
"""
 Test suite for FastROCS TK examples
"""

import pytest
from . import OETestCase, check_license, check_fastrocs

# Order of skipif is not clearly defined so the check_license() may
# fail first and give a misleading reason because it tries the import also


@pytest.mark.skipif(check_fastrocs() == 35,
                    reason='Insufficient NVIDIA Driver! Please update.')
@pytest.mark.skipif(check_fastrocs() == 1,
                    reason='No device found!')
@pytest.mark.skipif(check_fastrocs() == 3,
                    reason='CUDA driver and runtime could not be initialized!')
@pytest.mark.skipif(check_fastrocs() == 38,
                    reason='No CUDA-capable devices were detected!')
@pytest.mark.skipif(check_fastrocs() == 100,
                    reason='No CUDA-capable devices were detected!')
@pytest.mark.skipif(check_fastrocs() == 800,
                    reason='Attempted operation is not permitted!')
@pytest.mark.skipif(check_fastrocs() == -1,
                    reason='FastROCS library is not importable!')
@pytest.mark.skipif(check_fastrocs() == 999,
                    reason='FastROCS is not available! Unknown error.')
@pytest.mark.skipif(check_fastrocs() == 0 and not check_license('fastrocs'),
                    reason='FastROCS license not found')

class TestFastROCS(OETestCase):
    def test_best_shape_overlay(self):
        script = self.run_example(
            '{0}/fastrocs/BestShapeOverlay.py'.format(self.EXAMPLES_DIR),
            '{0}/drugs.sdf'.format(self.DATA_DIR),
            '{0}/4std_lig.oeb.gz'.format(self.DATA_DIR),
            expect_stderr=True)
        if "No supported GPU available!" in script.stderr:
            pytest.skip('No supported GPU available!')
        self.assertFalse(script.returncode)
