Skip to content
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

Dump file name issue #32

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/release/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ Release Notes

.. release:: Upcoming

.. change:: changed

Updated name of the dump file generated by :option:`wiz --record` to
make it attachable to a Github issue and Jira ticket. The file extension
is now :file:`.gz` instead of :file:`.dump`, and invalid characters
have been removed.

.. seealso::

* `Github - File attachments on issues and pull requests
<https://docs.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests>`_
* `JIRA - Attaching files and screenshots to issues
<https://confluence.atlassian.com/servicedeskserver/attaching-files-and-screenshots-to-issues-939937192.html>`_

.. change:: fixed

Fixed :meth:`wiz.graph.Graph.find` to prevent returning nodes with
Expand Down
4 changes: 3 additions & 1 deletion source/wiz/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,9 @@ def _export_history_if_requested(click_context):
history = wiz.history.get(serialized=True)
path = os.path.join(
os.path.abspath(click_context.obj["recording_path"]),
"wiz-{}.dump".format(datetime.datetime.now().isoformat())
"wiz-{}.gz".format(
datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S-%f")
)
)
wiz.filesystem.export(path, history, compressed=True)
logger.info("History recorded and exported in '{}'".format(path))
33 changes: 21 additions & 12 deletions test/unit/test_command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def reset_configuration(mocker):

@pytest.fixture()
def mock_datetime_now(mocker):
"""Return mocked 'wiz.fetch_definition_mapping' function."""
_date = mocker.Mock(**{"isoformat.return_value": "NOW"})
"""Return mocked 'datetime.datetime.now' function."""
value = datetime.datetime(2020, 8, 24, 17, 49, 1, 985944)
return mocker.patch.object(
datetime, "datetime", **{"now.return_value": _date}
datetime, "datetime", **{"now.return_value": value}
)


Expand Down Expand Up @@ -573,7 +573,8 @@ def test_list_packages_recorded(
)
mocked_history_get.assert_called_once_with(serialized=True)
mocked_filesystem_export.assert_called_once_with(
tempfile.gettempdir() + "/wiz-NOW.dump", "__HISTORY__",
tempfile.gettempdir() + "/wiz-2020-08-24-17-49-01-985944.gz",
"__HISTORY__",
compressed=True
)

Expand Down Expand Up @@ -740,7 +741,8 @@ def test_list_commands_recorded(
)
mocked_history_get.assert_called_once_with(serialized=True)
mocked_filesystem_export.assert_called_once_with(
tempfile.gettempdir() + "/wiz-NOW.dump", "__HISTORY__",
tempfile.gettempdir() + "/wiz-2020-08-24-17-49-01-985944.gz",
"__HISTORY__",
compressed=True
)

Expand Down Expand Up @@ -903,7 +905,8 @@ def test_search_recorded(
)
mocked_history_get.assert_called_once_with(serialized=True)
mocked_filesystem_export.assert_called_once_with(
tempfile.gettempdir() + "/wiz-NOW.dump", "__HISTORY__",
tempfile.gettempdir() + "/wiz-2020-08-24-17-49-01-985944.gz",
"__HISTORY__",
compressed=True
)

Expand Down Expand Up @@ -1282,7 +1285,8 @@ def test_view_recorded(
)
mocked_history_get.assert_called_once_with(serialized=True)
mocked_filesystem_export.assert_called_once_with(
tempfile.gettempdir() + "/wiz-NOW.dump", "__HISTORY__",
tempfile.gettempdir() + "/wiz-2020-08-24-17-49-01-985944.gz",
"__HISTORY__",
compressed=True
)

Expand Down Expand Up @@ -1487,7 +1491,8 @@ def test_use_recorded(
)
mocked_history_get.assert_called_once_with(serialized=True)
mocked_filesystem_export.assert_called_once_with(
tempfile.gettempdir() + "/wiz-NOW.dump", "__HISTORY__",
tempfile.gettempdir() + "/wiz-2020-08-24-17-49-01-985944.gz",
"__HISTORY__",
compressed=True
)

Expand Down Expand Up @@ -1834,7 +1839,8 @@ def test_run_recorded(
)
mocked_history_get.assert_called_once_with(serialized=True)
mocked_filesystem_export.assert_called_once_with(
tempfile.gettempdir() + "/wiz-NOW.dump", "__HISTORY__",
tempfile.gettempdir() + "/wiz-2020-08-24-17-49-01-985944.gz",
"__HISTORY__",
compressed=True
)

Expand Down Expand Up @@ -2151,7 +2157,8 @@ def test_freeze_recorded(
)
mocked_history_get.assert_called_once_with(serialized=True)
mocked_filesystem_export.assert_called_once_with(
tempfile.gettempdir() + "/wiz-NOW.dump", "__HISTORY__",
tempfile.gettempdir() + "/wiz-2020-08-24-17-49-01-985944.gz",
"__HISTORY__",
compressed=True
)

Expand Down Expand Up @@ -2521,7 +2528,8 @@ def test_install_recorded(
)
mocked_history_get.assert_called_once_with(serialized=True)
mocked_filesystem_export.assert_called_once_with(
tempfile.gettempdir() + "/wiz-NOW.dump", "__HISTORY__",
tempfile.gettempdir() + "/wiz-2020-08-24-17-49-01-985944.gz",
"__HISTORY__",
compressed=True
)

Expand Down Expand Up @@ -2793,7 +2801,8 @@ def test_edit_recorded(
)
mocked_history_get.assert_called_once_with(serialized=True)
mocked_filesystem_export.assert_called_once_with(
tempfile.gettempdir() + "/wiz-NOW.dump", "__HISTORY__",
tempfile.gettempdir() + "/wiz-2020-08-24-17-49-01-985944.gz",
"__HISTORY__",
compressed=True
)

Expand Down