From 77ae6614222820622f33b99ad01f2414b4c7d040 Mon Sep 17 00:00:00 2001 From: Victor Bartel Date: Fri, 9 Jul 2021 12:07:37 +0200 Subject: [PATCH] Fix and improve unit tests and add a launcher --- .../tests/shotgrid/lib/test_credentials.py | 34 +++++++++++++++++++ .../modules/shotgrid/lib/credentials_test.py | 11 ------ tools/run_unit_tests.sh | 3 ++ 3 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 openpype/modules/shotgrid/tests/shotgrid/lib/test_credentials.py delete mode 100644 openpype/tests/modules/shotgrid/lib/credentials_test.py create mode 100644 tools/run_unit_tests.sh diff --git a/openpype/modules/shotgrid/tests/shotgrid/lib/test_credentials.py b/openpype/modules/shotgrid/tests/shotgrid/lib/test_credentials.py new file mode 100644 index 00000000000..1f78cf77c92 --- /dev/null +++ b/openpype/modules/shotgrid/tests/shotgrid/lib/test_credentials.py @@ -0,0 +1,34 @@ +import pytest +from assertpy import assert_that + +import openpype.modules.shotgrid.lib.credentials as sut + + +def test_missing_shotgrid_url(): + with pytest.raises(Exception) as ex: + # arrange + url = "" + # act + sut.get_shotgrid_hostname(url) + # assert + assert_that(ex).is_equal_to("Shotgrid url cannot be a null") + + +def test_full_shotgrid_url(): + # arrange + url = "https://shotgrid.com/myinstance" + # act + actual = sut.get_shotgrid_hostname(url) + # assert + assert_that(actual).is_not_empty() + assert_that(actual).is_equal_to("shotgrid.com") + + +def test_incomplete_shotgrid_url(): + # arrange + url = "shotgrid.com/myinstance" + # act + actual = sut.get_shotgrid_hostname(url) + # assert + assert_that(actual).is_not_empty() + assert_that(actual).is_equal_to("shotgrid.com") diff --git a/openpype/tests/modules/shotgrid/lib/credentials_test.py b/openpype/tests/modules/shotgrid/lib/credentials_test.py deleted file mode 100644 index 0d6104721e5..00000000000 --- a/openpype/tests/modules/shotgrid/lib/credentials_test.py +++ /dev/null @@ -1,11 +0,0 @@ -import pytest -import openpype.modules.shotgrid.lib.credentials as sut - - -@pytest.mark.xfail(raises=Exception) -def test_missing_shotgrid_url(): - # arrange - url = "" - # act - sut.get_shotgrid_hostname(url) - # assert diff --git a/tools/run_unit_tests.sh b/tools/run_unit_tests.sh new file mode 100644 index 00000000000..ef19c90e44b --- /dev/null +++ b/tools/run_unit_tests.sh @@ -0,0 +1,3 @@ +export OPENPYPE_DATABASE_NAME=test; +export PYTHONPATH="./;./repos/avalon-core;$PYTHONPATH"; +pytest openpype/modules/shotgrid --capture=sys --print -W ignore::DeprecationWarning