-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Null tests.142 #290
base: main
Are you sure you want to change the base?
Null tests.142 #290
Conversation
@@ -0,0 +1,45 @@ | |||
#tests for the create-checkout step of fre-make, for null_model.yaml | |||
import os | |||
from fre import fre |
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.
Can remove this, not needed
from fre.pp import configure_script_yaml as csy | ||
from click.testing import CliRunner |
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.
Can remove these too, not needed. We won't be using runner.invoke
for these tool tests here
from fre.pp import configure_script_yaml as csy | ||
from click.testing import CliRunner | ||
import subprocess | ||
from fre.make import createCheckout |
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.
This needs to be updated: createCheckout
--> create_checkout_script
test_dir = Path("fre/make/tests/null_example") | ||
yamlfile = Path(f"{test_dir}/null_model.yaml") | ||
|
||
#set platform and target | ||
platform = "ncrc5.intel" | ||
target = "debug" |
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.
To keep consistency with other tests, make these variable names capitalized.
test_dir = Path("fre/make/tests/null_example") | ||
yamlfile = Path(f"{test_dir}/null_model.yaml") |
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.
I'd recommend keeping all the tests together in fre/make/tests for now. We can move it there and make this
TEST_DIR = Path("fre/make/tests")
YAMLFILE = Path(f"{TEST_DIR}/null_example/null_model.yaml")
|
||
# Set home for ~/cylc-src location in script | ||
#os.environ["HOME"]=str(Path(f"{out_dir}")) | ||
HOME_DIR = os.environ["HOME"] |
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.
So through doing this, we've found it definitely effects other tests that use HOME
.
- Let's move re-setting
HOME
to inside each test that needs it AND make sure to save the defaultHOME
location first. We can look at how Ryan maneuvered it:
define home:def_home = str(os.environ["HOME"])
set home:os.environ["HOME"]=OUT#str(Path(OUT))
reset home:os.environ["HOME"] = def_home
#set output directory | ||
#out_dir = Path(f"fre/make/tests/null_example/fre_make_out") | ||
#Path(out_dir).mkdir(parents=True,exist_ok=True) |
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.
In my opinion, I feel like it would be nice it each test had output that was easy to find. Here, for the checkout, maybe we can set OUT to be:
OUT = f"{TEST_DIR}/checkout_out"
Where test_dir would be what I commented above. Also add in the out location to the .gitignore
file
#os.environ["HOME"]=str(Path(f"{out_dir}")) | ||
HOME_DIR = os.environ["HOME"] | ||
#run checkout command | ||
runner = CliRunner() |
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.
remove
""" | ||
Make sure checkout file exists | ||
""" | ||
result = runner.invoke(fre.fre, args=["make","create-checkout","-y",yamlfile,"-p",platform,"-t",target]) |
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.
Using runner.invoke is good for testing the cli for fre. For actually script functionality testing here, we're going to call the actual functions in the script.
Using from fre.make import create_checkout_script
from the top:
- we'll set/reset home as I mentioned above
- we'll set what would be click options passed by the user for the fre make create-checkout command
- we'll invoke the main checkout function
- check for the existence of the checkout script as a good starting test
You have line 33 that just needs to be edited a little. Try this:
create_checkout_script.checkout_create(variables set right before)
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.
Is this different than the test_basic_null_yaml.py
file in fre/make/tests/null_example
?
2078d23
to
3f04df9
Compare
update local branch for change in fre make command names
7b22d9c
to
c7c62d7
Compare
Describe your changes
Added tests in fre/make/null_example for checkout
Issue ticket number and link (if applicable)
creating this so Dana can help with debugging of issues with paths
Checklist before requesting a review
@singhd789