-
Notifications
You must be signed in to change notification settings - Fork 12
Create time-stamp and load it into args #60
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dbd9945
Initial commit to load datetime automatically with datetime function.
stevenhua0320 ffd8d75
Merge branch 'diffpy:main' into datetime
stevenhua0320 275e1ff
Commit set creation_time as attribute into args
stevenhua0320 6a38df7
Commit adding creation_time argument with default current time value …
stevenhua0320 04962e6
Commit test_load_datetime by checking actual args creation_time attri…
stevenhua0320 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 hidden or 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 hidden or 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,7 +1,9 @@ | ||
import os | ||
import re | ||
from pathlib import Path | ||
|
||
import freezegun | ||
from freezegun import freeze_time | ||
from datetime import datetime | ||
import pytest | ||
|
||
from diffpy.labpdfproc.labpdfprocapp import get_args | ||
|
@@ -11,6 +13,7 @@ | |
set_input_lists, | ||
set_output_directory, | ||
set_wavelength, | ||
load_datetime | ||
) | ||
|
||
# Use cases can be found here: https://github.com/diffpy/diffpy.labpdfproc/issues/48 | ||
|
@@ -162,7 +165,7 @@ def test_set_wavelength(inputs, expected): | |
params3 = [ | ||
( | ||
["--anode-type", "invalid"], | ||
[f"Anode type not recognized. Please rerun specifying an anode_type from {*known_sources, }."], | ||
[f"Anode type not recognized. Please rerun specifying an anode_type from {*known_sources,}."], | ||
), | ||
( | ||
["--wavelength", "0"], | ||
|
@@ -241,3 +244,15 @@ def test_load_user_metadata_bad(inputs, msg): | |
actual_args = get_args(cli_inputs) | ||
with pytest.raises(ValueError, match=msg[0]): | ||
actual_args = load_user_metadata(actual_args) | ||
|
||
|
||
params7 = [(["--creation_time", "2014-02-01 12:34:56"], | ||
[datetime.strptime("2014-02-01 12:34:56", "%Y-%m-%d %H:%M:%S")])] | ||
|
||
|
||
@freezegun.freeze_time("2024-02-01 12:34:56") | ||
@pytest.mark.parametrize("inputs, expected", params7) | ||
def test_load_datetime(inputs, expected): | ||
actual_args = ["2.5", "data.xy"] + inputs | ||
actual_args = load_datetime(actual_args) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we won't be loading a datetime so this function is not needed. |
||
assert actual_args.creation_time == expected |
This file contains hidden or 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
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.
we don't want
--creation-time
as an input. Please delete.