Skip to content

Commit a40b2be

Browse files
committed
updating views test, but will need update (to not require sudo) to work
1 parent 4a825a3 commit a40b2be

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Singularity Python
22

3+
[![Build Status](https://travis-ci.org/singularityware/singularity-python.svg?branch=master)](https://travis-ci.org/singularityware/singularity-python)
4+
35
This is a python command line tool for working with [Singularity](singularityware.github.io) containers, specifically providing functions to visualize, package, and containers. Currently, most functions use Singularity on the commnd line, and require sudo, and this is expected to change when the software is updated to obtain image folders and files without an export that uses `Singularity export`.
46

57
The Singularity-Python code is licensed under the MIT open source license, which is a highly permissive license that places few limits upon reuse. This ensures that the code will be usable by the greatest number of researchers, in both academia and industry.

singularity/testing/test_views.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,24 @@
55
66
"""
77

8-
from numpy.testing import assert_array_equal, assert_almost_equal, assert_equal
9-
from singularity.utils import get_installdir, read_file, write_file
10-
from singularity.views import tree, make_package_tree
8+
from numpy.testing import (
9+
assert_array_equal,
10+
assert_almost_equal,
11+
assert_equal
12+
)
13+
14+
from singularity.utils import (
15+
get_installdir,
16+
read_file,
17+
write_file
18+
)
19+
20+
from singularity.views import (
21+
container_tree,
22+
calculate_similarity,
23+
container_similarity
24+
)
25+
1126
from singularity.package import load_package
1227
import unittest
1328
import tempfile
@@ -22,9 +37,6 @@ def setUp(self):
2237
self.tmpdir = tempfile.mkdtemp()
2338
self.image1 = "%s/testing/data/busybox-2016-02-16.img" %(self.pwd)
2439
self.image2 = "%s/testing/data/cirros-2016-01-04.img" %(self.pwd)
25-
self.pkg1 = "%s/testing/data/busybox-2016-02-16.img.zip" %(self.pwd)
26-
self.pkg2 = "%s/testing/data/cirros-2016-01-04.img.zip" %(self.pwd)
27-
2840

2941
def tearDown(self):
3042
shutil.rmtree(self.tmpdir)
@@ -39,11 +51,11 @@ def test_tree(self):
3951

4052
# This template has actual paths to static files instead of Flask
4153
html_template = " ".join(read_file("%s/templates/container_tree_circleci.html" %(self.pwd)))
42-
viz = tree(self.pkg1)
54+
viz = container_tree(self.image1)
4355
# Make replacements in the template
4456
html_template = html_template.replace("{{ graph | safe }}",json.dumps(viz["graph"]))
4557
html_template = html_template.replace("{{ files | safe }}",json.dumps(viz["files"]))
46-
container_name = os.path.basename(self.pkg1).split(".")[0]
58+
container_name = os.path.basename(self.image1).split(".")[0]
4759
html_template = html_template.replace("{{ container_name }}",container_name)
4860
write_file("tree.html",html_template)
4961
views["Similarity Tree"] = 'tree.html'
@@ -55,17 +67,6 @@ def test_tree(self):
5567
html_template = " ".join(read_file("%s/templates/index_circleci.html" %(self.pwd)))
5668
html_template = html_template.replace("{{ links }}",links)
5769
write_file("index.html",html_template)
58-
59-
# Test the package tree
60-
pkg1_includes = load_package(self.pkg1)
61-
package_tree = make_package_tree(folders=pkg1_includes["folders.txt"],
62-
files=pkg1_includes["folders.txt"])
63-
self.assertTrue(package_tree['depth']==3)
64-
self.assertTrue(isinstance(package_tree['lookup'],dict))
6570

66-
# Remove temporary package
67-
image1_extraction = pkg1_includes[os.path.basename(self.image1)]
68-
shutil.rmtree(os.path.dirname(image1_extraction))
69-
7071
if __name__ == '__main__':
7172
unittest.main()

0 commit comments

Comments
 (0)