This repository has been archived by the owner on Jul 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
[#47] Unittests Part1 #48
Open
pauljv92
wants to merge
4
commits into
paypal:master
Choose a base branch
from
pauljv92:testcases_part1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
"Name", "Sex", "Age", "Height (in)", "Weight (lbs)" | ||
"Alex", "M", 41, 74, 170 | ||
"Bert", "M", 42, 68, 166 | ||
"Carl", "M", 32, 70, 155 | ||
"Dave", "M", 39, 72, 167 | ||
"Elly", "F", 30, 66, 124 | ||
"Fran", "F", 33, 66, 115 | ||
"Gwen", "F", 26, 64, 121 | ||
"Hank", "M", 30, 71, 158 | ||
"Ivan", "M", 53, 72, 175 | ||
"Jake", "M", 32, 69, 143 | ||
"Kate", "F", 47, 69, 139 | ||
"Luke", "M", 34, 72, 163 | ||
"Myra", "F", 23, 62, 98 | ||
"Neil", "M", 36, 75, 160 | ||
"Omar", "M", 38, 70, 145 | ||
"Page", "F", 31, 67, 135 | ||
"Quin", "M", 29, 71, 176 | ||
"Ruth", "F", 28, 65, 131 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from ppextensions.ppsql.connection.hiveconnection import HiveConnection | ||
from thriftpy.transport import TTransportException | ||
import unittest | ||
|
||
class TestPPSqlHiveConnection(unittest.TestCase): | ||
|
||
def test_invalid_hive_connection(self): | ||
with self.assertRaises(TTransportException): | ||
hc = HiveConnection("fake", "fake", 1234, "GSSAPI", "fake") | ||
self.assertTrue(hc != None) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from ppextensions.pputils.utils.configuration import * | ||
import unittest | ||
|
||
class TestPPUtilsConfiguration(unittest.TestCase): | ||
|
||
def setUp(self): | ||
pass | ||
|
||
def test_load_config(self): | ||
conf = load_conf(PATH) | ||
self.assertTrue(isinstance(conf, dict)) | ||
|
||
def test_conf_info(self): | ||
config_info = conf_info("test-engine") | ||
self.assertTrue(isinstance(config_info, dict)) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from ppextensions.ppsql.connection.csvconnection import CSVConnection | ||
import unittest | ||
|
||
class TestPPSqlCSVConnection(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.csvconn = CSVConnection() | ||
|
||
def test_csv_query(self): | ||
self.assertTrue(self.csvconn.execute("select * from test_files/test.csv") != None) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from ppextensions.pputils.utils.filesystemreader import FileSystemReaderWriter | ||
import unittest | ||
|
||
class TestPPUtilsFileSystemReaderWriter(unittest.TestCase): | ||
|
||
def setUp(self): | ||
# In current implementation we will have two RM Objects | ||
# One with invalid RM Url & One with Valid one | ||
self.fsreadwriter = FileSystemReaderWriter("~") | ||
|
||
def test_ensure_path_exists(self): | ||
self.assertTrue(self.fsreadwriter.ensure_path_exists() == None) | ||
|
||
def test_ensure_file_exists(self): | ||
self.assertTrue(self.fsreadwriter.ensure_file_exists() == None) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from ppextensions.pputils.utils.log import Log | ||
import unittest | ||
|
||
class TestPPUtilsLog(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.logger = Log("test_logger") | ||
|
||
def test_log_debug(self): | ||
self.assertTrue(self.logger.debug("test_debug") == None) | ||
|
||
def test_log_error(self): | ||
self.assertTrue(self.logger.error("test_error") == None) | ||
|
||
def test_log_info(self): | ||
self.assertTrue(self.logger.info("test_info") == None) | ||
|
||
def test_log_exception(self): | ||
self.assertTrue(self.logger.exception("test_exception") == None) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from ppextensions.pputils.utils.parameterargs import * | ||
from IPython.core.magic_arguments import argument, magic_arguments, parse_argstring | ||
import unittest | ||
|
||
class TestPPUtilsParamArgs(unittest.TestCase): | ||
|
||
@magic_arguments() | ||
@argument("-test", "--test", type=str, help="test1") | ||
@argument("-test2", "--test2", type=str, help="test2") | ||
def setUp(self): | ||
args = "--test test --test2 testa:::testb:::testc" | ||
self.param_args = ParameterArgs(parse_argstring(self.setUp, args)) | ||
|
||
def test_get_args(self): | ||
self.assertTrue(self.param_args.get("test") == "test") | ||
self.assertTrue(self.param_args.get("test2") == "testa:::testb:::testc") | ||
|
||
def test_has_args(self): | ||
self.assertTrue(self.param_args.hasattr("test")) | ||
self.assertTrue(self.param_args.hasattr("test2")) | ||
|
||
def test_get_list(self): | ||
return_vals = self.param_args.get_list("test2") | ||
self.assertTrue(isinstance(return_vals, list)) | ||
self.assertTrue(len(return_vals) == 3) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from ppextensions.pputils.utils.resultset import ResultSet, unduplicate_field_names | ||
import unittest | ||
import pandas as pd | ||
|
||
class TestPPUtilsResultSet(unittest.TestCase): | ||
|
||
def setUp(self): | ||
data = {'col1': [1,2,3,4], 'col2': [3,4,5,6], 'col3': [4,5,6,7], 'col4': [5,6,7,8]} | ||
cols = ['col1', 'col2', 'col3', 'col4'] | ||
self.resultset = ResultSet(cols, data) | ||
|
||
def test_resultset_df(self): | ||
df = self.resultset.DataFrame() | ||
self.assertTrue(isinstance(df, pd.DataFrame)) | ||
|
||
def test_dict(self): | ||
dictionary = self.resultset.dict() | ||
self.assertTrue(isinstance(dictionary, dict)) | ||
|
||
def test_csv(self): | ||
self.assertTrue(self.resultset.csv()) | ||
|
||
def test_unduplicate_field_names(self): | ||
cols = ['col1', 'col2', 'col3', 'col4', 'col1'] | ||
updated_cols = unduplicate_field_names(cols) | ||
self.assertTrue(isinstance(updated_cols, list)) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from ppextensions.pputils.utils import utils | ||
import pandas as pd | ||
import unittest | ||
|
||
class TestPPUtilsUtils(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.test_df = utils.csv_to_df({}, {"csv":"test_files/test.csv"}) | ||
|
||
def test_renew_kerberos_ticket_negative(self): | ||
self.assertFalse(utils.renew_kerberos_ticket("fake","fake")) | ||
|
||
def test_renew_kerberos_ticket_positive(self): | ||
self.assertTrue(utils.renew_kerberos_ticket("pp_batch_opts_admin","~/PPExtensions/tests/test_files/.pp_batch_opts_admin.keytab")) | ||
|
||
def test_parse_run_str(self): | ||
self.assertTrue(utils.parse_run_str("%%info")) | ||
self.assertTrue(utils.parse_run_str("test_call_value=123")) | ||
|
||
def test_csv_to_df_and_back(self): | ||
df = utils.csv_to_df({}, {"csv":"test_files/test.csv"}) | ||
self.assertTrue(isinstance(df, pd.DataFrame)) | ||
args = {"dataframe":"df"} | ||
csv_file = utils.df_to_csv({"df":df}, args) | ||
self.assertTrue(csv_file != None) | ||
|
||
def test_substitute_params(self): | ||
substitute_cell = utils.substitute_params("test_cell_value = {}", {"test":"test"}) | ||
self.assertTrue(substitute_cell != None) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from ppextensions.pputils.utils.yarnapi import ResourceManager | ||
import unittest | ||
import requests | ||
|
||
class TestPPUtilsYarnAPI(unittest.TestCase): | ||
|
||
def setUp(self): | ||
# In current implementation we will have two RM Objects | ||
# One with invalid RM Url & One with Valid one | ||
self.invalid_rm = ResourceManager("http://invalidrm.paypalinc.com") | ||
|
||
def test_invalid_rm_cluster_app(self): | ||
with self.assertRaises(requests.exceptions.ConnectionError): | ||
self.invalid_rm.cluster_application("fake_app") | ||
|
||
def test_invalid_rm_cluster_metrics(self): | ||
with self.assertRaises(requests.exceptions.ConnectionError): | ||
self.invalid_rm.cluster_metrics() | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from pputils.utils import utils | ||
import unittest | ||
|
||
class TestPPUtilsUtils(unittest.TestCase): | ||
|
||
def test_renew_kerberos_ticket(self): | ||
self.assertFalse(utils.renew_kerberos_ticket("fake","fake")) | ||
|
||
def test_load_user_config(self): | ||
user_config = utils.load_user_config() | ||
self.assertTrue(user_config != None) | ||
self.assertTrue(isinstance(user_config, dict)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT - can we avoid these changes