-
Notifications
You must be signed in to change notification settings - Fork 10
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
6 changed files
with
78 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.5.18 | ||
0.5.19 |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2015-2020, Exa Analytics Development Team | ||
# Distributed under the terms of the Apache License 2.0 | ||
import tarfile | ||
from os import remove, rmdir, path, makedirs | ||
from tempfile import mkdtemp | ||
from exa.util.io import read_tarball | ||
|
||
|
||
def test_tarball(): | ||
tmpdir = mkdtemp() | ||
archive_dir = path.join(tmpdir, "tmp") | ||
makedirs(archive_dir) | ||
with open(path.join(archive_dir, "file.txt"), "w") as f: | ||
f.write("hello {value}") | ||
archive = path.join(tmpdir, "tmp.tar.gz") | ||
with tarfile.open(archive, "w:gz") as tar: | ||
tar.add(archive_dir) | ||
eds = read_tarball(archive, shortkey=True) | ||
assert len(eds) == 1 | ||
ed = eds["file.txt"] | ||
assert ed.variables == ["{value}"] | ||
assert str(ed) == "hello {value}" | ||
remove(path.join(archive_dir, "file.txt")) | ||
remove(archive) | ||
rmdir(path.join(tmpdir, "tmp")) | ||
rmdir(tmpdir) |
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,44 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (c) 2015-2020, Exa Analytics Development Team | ||
# Distributed under the terms of the Apache License 2.0 | ||
from os import path | ||
from tempfile import mkdtemp | ||
from exa.util.utility import datetime_header, mkp, convert_bytes, get_internal_modules | ||
|
||
|
||
def test_get_internal_modules(): | ||
lst = get_internal_modules() | ||
assert len(lst) > 0 | ||
assert lst[0].__name__.startswith("exa") | ||
|
||
|
||
def test_convert_bytes(): | ||
a, b = convert_bytes(2049) | ||
assert a >= 2.0 | ||
assert b == "KiB" | ||
a, b = convert_bytes(10000000) | ||
assert a >= 9.5367 | ||
assert b == "MiB" | ||
a, b = convert_bytes(10000000000) | ||
assert a >= 9.3132 | ||
assert b == "GiB" | ||
a, b = convert_bytes(10000000000000) | ||
assert a >= 9.0949 | ||
assert b == "TiB" | ||
a, b = convert_bytes(1000000000000000000) | ||
assert a >= 888.1784 | ||
assert b == "PiB" | ||
a, b = convert_bytes(1000000000000000000000) | ||
assert a >= 867.3617 | ||
assert b == "EiB" | ||
|
||
|
||
def test_mkp(): | ||
dir_ = mkdtemp() | ||
pth = path.join(dir_, "tmp") | ||
mkp(pth) | ||
assert path.exists(pth) | ||
|
||
|
||
def test_datetime_header(): | ||
assert isinstance(datetime_header(), str) |
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