Skip to content
This repository was archived by the owner on Oct 1, 2022. It is now read-only.

Commit ec4bdd0

Browse files
committed
Add unit test for ServiceX.get_requesting_user
1 parent c877a8b commit ec4bdd0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/resources/test_servicex_resource.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,26 @@
2727
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
import pkg_resources
2929

30+
from servicex.resources.servicex_resource import ServiceXResource
31+
from tests.resource_test_base import ResourceTestBase
3032

31-
class TestServiceXResource:
33+
34+
class TestServiceXResource(ResourceTestBase):
3235
def test_get_app_version_no_servicex_app(self, mocker):
3336
mock_get_distribution = mocker.patch(
3437
"servicex.resources.servicex_resource.pkg_resources.get_distribution",
3538
side_effect=pkg_resources.DistributionNotFound(None, None))
3639

37-
from servicex.resources.servicex_resource import ServiceXResource
3840
version = ServiceXResource._get_app_version()
3941

4042
mock_get_distribution.assert_called_with("servicex_app")
4143
assert version == 'develop'
44+
45+
def test_get_requesting_user_no_auth(self, client):
46+
with client.application.app_context():
47+
assert ServiceXResource.get_requesting_user() is None
48+
49+
def test_get_requesting_user_with_auth(self, mock_requesting_user):
50+
client = self._test_client(extra_config={'ENABLE_AUTH': True})
51+
with client.application.app_context():
52+
assert ServiceXResource.get_requesting_user() == mock_requesting_user

0 commit comments

Comments
 (0)