You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2020/08/18 17:10:56 UTC
[ranger] branch master updated: RANGER-2927: fix python unit test
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push:
new 1066351 RANGER-2927: fix python unit test
1066351 is described below
commit 1066351cb9813b3e8542467c0ec543835c47aaa9
Author: Madhan Neethiraj <ma...@apache.org>
AuthorDate: Tue Aug 18 08:57:12 2020 -0700
RANGER-2927: fix python unit test
---
intg/.gitignore | 1 -
intg/pom.xml | 70 ++++--------------------------
intg/scripts/build.sh | 23 ----------
intg/src/test/python/test_ranger_client.py | 14 +++---
4 files changed, 15 insertions(+), 93 deletions(-)
diff --git a/intg/.gitignore b/intg/.gitignore
index 897593c..b83d222 100644
--- a/intg/.gitignore
+++ b/intg/.gitignore
@@ -1,2 +1 @@
/target/
-/venv/
\ No newline at end of file
diff --git a/intg/pom.xml b/intg/pom.xml
index 83b87d8..d61900e 100644
--- a/intg/pom.xml
+++ b/intg/pom.xml
@@ -54,79 +54,25 @@
</plugin>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-clean-plugin</artifactId>
- <version>2.6.1</version>
- <configuration>
- <filesets>
- <fileset>
- <directory>venv</directory>
- </fileset>
- </filesets>
- </configuration>
- </plugin>
-
- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${maven.exec.plugin.version}</version>
<executions>
<execution>
- <configuration>
- <skip>${skipTests}</skip>
- <executable>python3</executable>
- <arguments>
- <argument>-m</argument>
- <argument>venv</argument>
- <argument>venv</argument>
- </arguments>
- </configuration>
- <id>create-venv</id>
- <phase>validate</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- </execution>
- <execution>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
- <executable>bash</executable>
- <commandlineArgs>scripts/build.sh</commandlineArgs>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-resources-plugin</artifactId>
- <version>2.7</version>
- <executions>
- <execution>
- <id>copy-resources</id>
- <phase>initialize</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>venv/pylib</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/python</directory>
- <includes>
- <include>**/*.py</include>
- </includes>
- </resource>
- <resource>
- <directory>src/test/python</directory>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- </resources>
+ <environmentVariables>
+ <PYTHONPATH>${project.basedir}/src/main/python</PYTHONPATH>
+ </environmentVariables>
+ <executable>python3</executable>
+ <arguments>
+ <argument>-B</argument>
+ <argument>src/test/python/test_ranger_client.py</argument>
+ </arguments>
</configuration>
</execution>
</executions>
diff --git a/intg/scripts/build.sh b/intg/scripts/build.sh
deleted file mode 100644
index a875da1..0000000
--- a/intg/scripts/build.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-cd venv || exit
-source bin/activate
-INSTALL="python3 ./../scripts/setup.py install"
-$INSTALL >> build.log
-TEST="python3 build/lib/pylib/test_ranger_client.py"
-$TEST
diff --git a/intg/src/test/python/test_ranger_client.py b/intg/src/test/python/test_ranger_client.py
index 5efda23..6f7d172 100644
--- a/intg/src/test/python/test_ranger_client.py
+++ b/intg/src/test/python/test_ranger_client.py
@@ -18,8 +18,8 @@
import unittest
from unittest.mock import patch
-from ranger.model.ranger_service import RangerService
-from ranger.client.ranger_client import API, HttpMethod, HTTPStatus, RangerClient
+from apache_ranger.model.ranger_service import RangerService
+from apache_ranger.client.ranger_client import API, HttpMethod, HTTPStatus, RangerClient
class MockResponse:
@@ -41,7 +41,7 @@ class TestRangerClient(unittest.TestCase):
USERNAME = "user"
PASSWORD = "password"
- @patch('ranger.client.ranger_client.Session')
+ @patch('apache_ranger.client.ranger_client.Session')
def test_get_service_unavailable(self, mock_session):
mock_session.return_value.get.return_value = MockResponse(HTTPStatus.SERVICE_UNAVAILABLE)
result = RangerClient(TestRangerClient.URL, TestRangerClient.USERNAME, TestRangerClient.PASSWORD).find_services({})
@@ -49,7 +49,7 @@ class TestRangerClient(unittest.TestCase):
self.assertTrue(result is None)
- @patch('ranger.client.ranger_client.Session')
+ @patch('apache_ranger.client.ranger_client.Session')
def test_get_success(self, mock_session):
response = RangerService()
mock_session.return_value.get.return_value = MockResponse(HTTPStatus.OK, response=response, content='Success')
@@ -58,8 +58,8 @@ class TestRangerClient(unittest.TestCase):
self.assertTrue(response.__repr__() in result)
- @patch('ranger.client.ranger_client.Session')
- @patch('ranger.client.ranger_client.Response')
+ @patch('apache_ranger.client.ranger_client.Session')
+ @patch('apache_ranger.client.ranger_client.Response')
def test_get_unexpected_status_code(self, mock_response, mock_session):
content = 'Internal Server Error'
mock_response.text = content
@@ -73,7 +73,7 @@ class TestRangerClient(unittest.TestCase):
self.assertTrue(content in repr(e))
- @patch('ranger.client.ranger_client.RangerClient.FIND_SERVICES')
+ @patch('apache_ranger.client.ranger_client.RangerClient.FIND_SERVICES')
def test_unexpected_http_method(self, mock_api):
mock_api.method.return_value = "PATCH"