forked from CLCMacTeam/besapi
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
55 additions
and
15 deletions.
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
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
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 |
---|---|---|
@@ -1,19 +1,55 @@ | ||
""" | ||
Test besapi | ||
""" | ||
import argparse | ||
import os | ||
import subprocess | ||
import sys | ||
|
||
# set working directory to folder this file is in: | ||
os.chdir(os.path.dirname(os.path.abspath(__file__))) | ||
# check for --test_pip arg | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--test_pip", help="to test package installed with pip", action="store_true" | ||
) | ||
args = parser.parse_args() | ||
|
||
# set working directory to src folder in parent folder | ||
os.chdir("../src") | ||
if not args.test_pip: | ||
# add module folder to import paths for testing local src | ||
sys.path.append( | ||
os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "src") | ||
) | ||
# reverse the order so we make sure to get the local src module | ||
sys.path.reverse() | ||
|
||
import besapi | ||
import bescli | ||
|
||
|
||
print(f"besapi version: {besapi.__version__}") | ||
|
||
if os.name == "nt": | ||
subprocess.run( | ||
'CMD /C python -m besapi ls clear ls conf "query number of bes computers" exit', | ||
check=True, | ||
) | ||
bigfix_cli = bescli.bescli.BESCLInterface() | ||
|
||
# just make sure these don't throw errors: | ||
bigfix_cli.do_ls() | ||
bigfix_cli.do_clear() | ||
bigfix_cli.do_ls() | ||
bigfix_cli.do_logout() | ||
bigfix_cli.do_error_count() | ||
bigfix_cli.do_version() | ||
bigfix_cli.do_conf() | ||
|
||
# this should really only run if the config file is present: | ||
if bigfix_cli.bes_conn: | ||
print(bigfix_cli.bes_conn.session_relevance_string("number of bes computers")) | ||
|
||
# set working directory to folder this file is in: | ||
os.chdir(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
# set working directory to src folder in parent folder | ||
os.chdir("../src") | ||
|
||
if os.name == "nt": | ||
subprocess.run( | ||
'CMD /C python -m besapi ls clear ls conf "query number of bes computers" version error_count exit', | ||
check=True, | ||
) |