[ARVADOS] updated: fee8873d0c5eeec1bd838161357679de1a3fe0cb

Git user git at public.curoverse.com
Tue Dec 6 17:55:01 EST 2016


Summary of changes:
 sdk/cli/test/test_arv-keep-get.rb            |  8 +++++
 sdk/python/tests/test_arv_copy.py            | 45 +++++++++++++++++++++++++++
 sdk/python/tests/test_arv_keepdocker.py      | 46 ++++++++++++++++++++++++++++
 sdk/python/tests/test_arv_ls.py              | 32 ++++++++++++++++++-
 sdk/python/tests/test_arv_normalize.py       | 27 ++++++++++++++++
 sdk/python/tests/test_arv_put.py             | 26 ++++++++++++++++
 sdk/python/tests/test_arv_run.py             | 45 +++++++++++++++++++++++++++
 sdk/python/tests/test_arv_ws.py              | 30 ++++++++++++++++++
 services/fuse/tests/test_command_args.py     | 16 ++++++++++
 services/nodemanager/tests/test_arguments.py | 42 +++++++++++++++++++++++++
 10 files changed, 316 insertions(+), 1 deletion(-)
 create mode 100644 sdk/python/tests/test_arv_copy.py
 create mode 100644 sdk/python/tests/test_arv_keepdocker.py
 create mode 100644 sdk/python/tests/test_arv_normalize.py
 create mode 100644 sdk/python/tests/test_arv_run.py
 create mode 100644 services/nodemanager/tests/test_arguments.py

       via  fee8873d0c5eeec1bd838161357679de1a3fe0cb (commit)
      from  128766dfc5826eafb5768d49461019dee980baa4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit fee8873d0c5eeec1bd838161357679de1a3fe0cb
Author: Lucas Di Pentima <lucas at curoverse.com>
Date:   Tue Dec 6 19:54:04 2016 -0300

    10587: Added tests to Python commands to check for the --version argument.

diff --git a/sdk/cli/test/test_arv-keep-get.rb b/sdk/cli/test/test_arv-keep-get.rb
index d0224ae..04f4543 100644
--- a/sdk/cli/test/test_arv-keep-get.rb
+++ b/sdk/cli/test/test_arv-keep-get.rb
@@ -20,6 +20,14 @@ class TestArvKeepGet < Minitest::Test
     assert_match /^usage:/, err
   end
 
+  def test_get_version
+    out, err = capture_subprocess_io do
+      assert_arv_get '--version'
+    end
+    assert_empty(out, "STDOUT not expected: '#{out}'")
+    assert_match(/[0-9]+\.[0-9]+\.[0-9]+/, err, "Version information incorrect: '#{err}'")
+  end
+
   def test_help
     out, err = capture_subprocess_io do
       assert_arv_get '-h'
diff --git a/sdk/python/tests/test_arv_copy.py b/sdk/python/tests/test_arv_copy.py
new file mode 100644
index 0000000..4be212c
--- /dev/null
+++ b/sdk/python/tests/test_arv_copy.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import multiprocessing
+import os
+import sys
+import tempfile
+import unittest
+
+import arvados.commands.arv_copy as arv_copy
+
+class ArvCopyTestCase(unittest.TestCase):
+    def run_copy(self, args):
+        sys.argv = ['arv-copy'] + args
+        return arv_copy.main()
+
+    def run_copy_process(self, args):
+        _, stdout_path = tempfile.mkstemp()
+        _, stderr_path = tempfile.mkstemp()
+        def wrap():
+            def wrapper():
+                sys.argv = ['arv-copy'] + args
+                sys.stdout = open(stdout_path, 'w')
+                sys.stderr = open(stderr_path, 'w')
+                arv_copy.main()
+            return wrapper
+        p = multiprocessing.Process(target=wrap())
+        p.start()
+        p.join()
+        out = open(stdout_path, 'r').read()
+        err = open(stderr_path, 'r').read()
+        os.unlink(stdout_path)
+        os.unlink(stderr_path)
+        return p.exitcode, out, err
+
+    def test_unsupported_arg(self):
+        with self.assertRaises(SystemExit):
+            self.run_copy(['-x=unknown'])
+
+    def test_version_argument(self):
+        exitcode, out, err = self.run_copy_process(['--version'])
+        self.assertEqual(0, exitcode)
+        self.assertEqual('', out)
+        self.assertNotEqual('', err)
+        self.assertRegexpMatches(err, "[0-9]+\.[0-9]+\.[0-9]+")
diff --git a/sdk/python/tests/test_arv_keepdocker.py b/sdk/python/tests/test_arv_keepdocker.py
new file mode 100644
index 0000000..27081af
--- /dev/null
+++ b/sdk/python/tests/test_arv_keepdocker.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import multiprocessing
+import os
+import sys
+import tempfile
+import unittest
+
+import arvados.commands.keepdocker as arv_keepdocker
+
+
+class ArvKeepdockerTestCase(unittest.TestCase):
+    def run_arv_keepdocker(self, args):
+        sys.argv = ['arv-keepdocker'] + args
+        return arv_keepdocker.main()
+
+    def run_arv_keepdocker_process(self, args):
+        _, stdout_path = tempfile.mkstemp()
+        _, stderr_path = tempfile.mkstemp()
+        def wrap():
+            def wrapper():
+                sys.argv = ['arv-keepdocker'] + args
+                sys.stdout = open(stdout_path, 'w')
+                sys.stderr = open(stderr_path, 'w')
+                arv_keepdocker.main()
+            return wrapper
+        p = multiprocessing.Process(target=wrap())
+        p.start()
+        p.join()
+        out = open(stdout_path, 'r').read()
+        err = open(stderr_path, 'r').read()
+        os.unlink(stdout_path)
+        os.unlink(stderr_path)
+        return p.exitcode, out, err
+
+    def test_unsupported_arg(self):
+        with self.assertRaises(SystemExit):
+            self.run_arv_keepdocker(['-x=unknown'])
+
+    def test_version_argument(self):
+        exitcode, out, err = self.run_arv_keepdocker_process(['--version'])
+        self.assertEqual(0, exitcode)
+        self.assertEqual('', out)
+        self.assertNotEqual('', err)
+        self.assertRegexpMatches(err, "[0-9]+\.[0-9]+\.[0-9]+")
diff --git a/sdk/python/tests/test_arv_ls.py b/sdk/python/tests/test_arv_ls.py
index 664b57f..ed03c12 100644
--- a/sdk/python/tests/test_arv_ls.py
+++ b/sdk/python/tests/test_arv_ls.py
@@ -2,9 +2,12 @@
 # -*- coding: utf-8 -*-
 
 import io
+import os
 import random
-
+import sys
 import mock
+import tempfile
+import multiprocessing
 
 import arvados.errors as arv_error
 import arvados.commands.ls as arv_ls
@@ -38,6 +41,25 @@ class ArvLsTestCase(run_test_server.TestCaseWithServers):
         self.stderr = io.BytesIO()
         return arv_ls.main(args, self.stdout, self.stderr, api_client)
 
+    def run_ls_process(self, args=[], api_client=None):
+        _, stdout_path = tempfile.mkstemp()
+        _, stderr_path = tempfile.mkstemp()
+        def wrap():
+            def wrapper(*args, **kwargs):
+                sys.stdout = open(stdout_path, 'w')
+                sys.stderr = open(stderr_path, 'w')
+                arv_ls.main(*args, **kwargs)
+            return wrapper
+        p = multiprocessing.Process(target=wrap(),
+                                    args=(args, sys.stdout, sys.stderr, api_client))
+        p.start()
+        p.join()
+        out = open(stdout_path, 'r').read()
+        err = open(stderr_path, 'r').read()
+        os.unlink(stdout_path)
+        os.unlink(stderr_path)
+        return p.exitcode, out, err
+
     def test_plain_listing(self):
         collection, api_client = self.mock_api_for_manifest(
             ['. {} 0:3:one.txt 3:4:two.txt'.format(self.random_blocks(5, 2)),
@@ -78,3 +100,11 @@ class ArvLsTestCase(run_test_server.TestCaseWithServers):
             arv_error.NotFoundError)
         self.assertNotEqual(0, self.run_ls([self.FAKE_UUID], api_client))
         self.assertNotEqual('', self.stderr.getvalue())
+
+    def test_version_argument(self):
+        _, api_client = self.mock_api_for_manifest([''])
+        exitcode, out, err = self.run_ls_process(['--version'])
+        self.assertEqual(0, exitcode)
+        self.assertEqual('', out)
+        self.assertNotEqual('', err)
+        self.assertRegexpMatches(err, "[0-9]+\.[0-9]+\.[0-9]+")
diff --git a/sdk/python/tests/test_arv_normalize.py b/sdk/python/tests/test_arv_normalize.py
new file mode 100644
index 0000000..8bce7e3
--- /dev/null
+++ b/sdk/python/tests/test_arv_normalize.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import subprocess
+import sys
+import tempfile
+import unittest
+
+
+class ArvNormalizeTestCase(unittest.TestCase):
+    def run_arv_normalize(self, args=[]):
+        p = subprocess.Popen([sys.executable, 'bin/arv-normalize'] + args,
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.PIPE)
+        (stdout, stderr) = p.communicate()
+        return p.returncode, stdout, stderr
+
+    def test_unsupported_arg(self):
+        returncode, out, err = self.run_arv_normalize(['-x=unknown'])
+        self.assertNotEqual(0, returncode)
+
+    def test_version_argument(self):
+        returncode, out, err = self.run_arv_normalize(['--version'])
+        self.assertEqual(0, returncode)
+        self.assertEqual('', out)
+        self.assertNotEqual('', err)
+        self.assertRegexpMatches(err, "[0-9]+\.[0-9]+\.[0-9]+")
diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py
index 7a0120c..76317b6 100644
--- a/sdk/python/tests/test_arv_put.py
+++ b/sdk/python/tests/test_arv_put.py
@@ -16,6 +16,7 @@ import yaml
 import threading
 import hashlib
 import random
+import multiprocessing
 
 from cStringIO import StringIO
 
@@ -396,6 +397,24 @@ class ArvadosPutTest(run_test_server.TestCaseWithServers, ArvadosBaseTestCase):
                                         '098f6bcd4621d373cade4e832627b4f6')),
             "did not find file stream in Keep store")
 
+    def run_main_process(self, args):
+        _, stdout_path = tempfile.mkstemp()
+        _, stderr_path = tempfile.mkstemp()
+        def wrap():
+            def wrapper(*args, **kwargs):
+                sys.stdout = open(stdout_path, 'w')
+                sys.stderr = open(stderr_path, 'w')
+                arv_put.main(*args, **kwargs)
+            return wrapper
+        p = multiprocessing.Process(target=wrap(), args=(args, sys.stdout, sys.stderr))
+        p.start()
+        p.join()
+        out = open(stdout_path, 'r').read()
+        err = open(stderr_path, 'r').read()
+        os.unlink(stdout_path)
+        os.unlink(stderr_path)
+        return p.exitcode, out, err
+
     def setUp(self):
         super(ArvadosPutTest, self).setUp()
         run_test_server.authorize_with('active')
@@ -408,6 +427,13 @@ class ArvadosPutTest(run_test_server.TestCaseWithServers, ArvadosBaseTestCase):
                 delattr(self, outbuf)
         super(ArvadosPutTest, self).tearDown()
 
+    def test_version_argument(self):
+        exitcode, out, err = self.run_main_process(['--version'])
+        self.assertEqual(0, exitcode)
+        self.assertEqual('', out)
+        self.assertNotEqual('', err)
+        self.assertRegexpMatches(err, "[0-9]+\.[0-9]+\.[0-9]+")
+
     def test_simple_file_put(self):
         self.call_main_on_test_file()
 
diff --git a/sdk/python/tests/test_arv_run.py b/sdk/python/tests/test_arv_run.py
new file mode 100644
index 0000000..7afe52b
--- /dev/null
+++ b/sdk/python/tests/test_arv_run.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import multiprocessing
+import os
+import sys
+import tempfile
+import unittest
+
+import arvados.commands.run as arv_run
+
+class ArvRunTestCase(unittest.TestCase):
+    def run_arv_run(self, args):
+        sys.argv = ['arv-run'] + args
+        return arv_run.main()
+
+    def run_arv_run_process(self, args):
+        _, stdout_path = tempfile.mkstemp()
+        _, stderr_path = tempfile.mkstemp()
+        def wrap():
+            def wrapper():
+                sys.argv = ['arv-run'] + args
+                sys.stdout = open(stdout_path, 'w')
+                sys.stderr = open(stderr_path, 'w')
+                arv_run.main()
+            return wrapper
+        p = multiprocessing.Process(target=wrap())
+        p.start()
+        p.join()
+        out = open(stdout_path, 'r').read()
+        err = open(stderr_path, 'r').read()
+        os.unlink(stdout_path)
+        os.unlink(stderr_path)
+        return p.exitcode, out, err
+
+    def test_unsupported_arg(self):
+        with self.assertRaises(SystemExit):
+            self.run_arv_run(['-x=unknown'])
+
+    def test_version_argument(self):
+        exitcode, out, err = self.run_arv_run_process(['--version'])
+        self.assertEqual(0, exitcode)
+        self.assertEqual('', out)
+        self.assertNotEqual('', err)
+        self.assertRegexpMatches(err, "[0-9]+\.[0-9]+\.[0-9]+")
diff --git a/sdk/python/tests/test_arv_ws.py b/sdk/python/tests/test_arv_ws.py
index 5a01827..17706c1 100644
--- a/sdk/python/tests/test_arv_ws.py
+++ b/sdk/python/tests/test_arv_ws.py
@@ -1,6 +1,11 @@
 #!/usr/bin/env python
 
+import multiprocessing
+import os
+import sys
+import tempfile
 import unittest
+
 import arvados.errors as arv_error
 import arvados.commands.ws as arv_ws
 
@@ -8,6 +13,31 @@ class ArvWsTestCase(unittest.TestCase):
     def run_ws(self, args):
         return arv_ws.main(args)
 
+    def run_ws_process(self, args=[], api_client=None):
+        _, stdout_path = tempfile.mkstemp()
+        _, stderr_path = tempfile.mkstemp()
+        def wrap():
+            def wrapper(*args, **kwargs):
+                sys.stdout = open(stdout_path, 'w')
+                sys.stderr = open(stderr_path, 'w')
+                arv_ws.main(*args, **kwargs)
+            return wrapper
+        p = multiprocessing.Process(target=wrap(), args=(args,))
+        p.start()
+        p.join()
+        out = open(stdout_path, 'r').read()
+        err = open(stderr_path, 'r').read()
+        os.unlink(stdout_path)
+        os.unlink(stderr_path)
+        return p.exitcode, out, err
+
     def test_unsupported_arg(self):
         with self.assertRaises(SystemExit):
             self.run_ws(['-x=unknown'])
+
+    def test_version_argument(self):
+        exitcode, out, err = self.run_ws_process(['--version'])
+        self.assertEqual(0, exitcode)
+        self.assertEqual('', out)
+        self.assertNotEqual('', err)
+        self.assertRegexpMatches(err, "[0-9]+\.[0-9]+\.[0-9]+")
diff --git a/services/fuse/tests/test_command_args.py b/services/fuse/tests/test_command_args.py
index e8488d7..57b4a37 100644
--- a/services/fuse/tests/test_command_args.py
+++ b/services/fuse/tests/test_command_args.py
@@ -3,6 +3,7 @@ import arvados_fuse
 import arvados_fuse.command
 import contextlib
 import functools
+import io
 import json
 import llfuse
 import logging
@@ -48,6 +49,14 @@ class MountArgsTest(unittest.TestCase):
             ent = ent[p]
         return ent
 
+    @contextlib.contextmanager
+    def stderrMatches(self, stderr):
+        orig, sys.stderr = sys.stderr, stderr
+        try:
+            yield
+        finally:
+            sys.stderr = orig
+
     def check_ent_type(self, cls, *path):
         ent = self.lookup(self.mnt, *path)
         self.assertEqual(ent.__class__, cls)
@@ -170,6 +179,13 @@ class MountArgsTest(unittest.TestCase):
                          run_test_server.fixture('users')['active']['uuid'])
         self.assertEqual(True, self.mnt.listen_for_events)
 
+    def test_version_argument(self):
+        orig, sys.stderr = sys.stderr, io.BytesIO()
+        with self.assertRaises(SystemExit):
+            args = arvados_fuse.command.ArgumentParser().parse_args(['--version'])
+        self.assertRegexpMatches(sys.stderr.getvalue(), "[0-9]+\.[0-9]+\.[0-9]+")
+        sys.stderr = orig
+
     @noexit
     @mock.patch('arvados.events.subscribe')
     def test_disable_event_listening(self, mock_subscribe):
diff --git a/services/nodemanager/tests/test_arguments.py b/services/nodemanager/tests/test_arguments.py
new file mode 100644
index 0000000..e4749ce
--- /dev/null
+++ b/services/nodemanager/tests/test_arguments.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+
+import multiprocessing
+import os
+import sys
+import tempfile
+import unittest
+
+import arvnodeman.launcher as nodeman
+
+class ArvNodemArgumentsTestCase(unittest.TestCase):
+    def run_nodeman(self, args):
+        return nodeman.main(args)
+
+    def run_nodeman_process(self, args=[]):
+        _, stdout_path = tempfile.mkstemp()
+        _, stderr_path = tempfile.mkstemp()
+        def wrap():
+            def wrapper(*args, **kwargs):
+                sys.stdout = open(stdout_path, 'w')
+                sys.stderr = open(stderr_path, 'w')
+                nodeman.main(*args, **kwargs)
+            return wrapper
+        p = multiprocessing.Process(target=wrap(), args=(args,))
+        p.start()
+        p.join()
+        out = open(stdout_path, 'r').read()
+        err = open(stderr_path, 'r').read()
+        os.unlink(stdout_path)
+        os.unlink(stderr_path)
+        return p.exitcode, out, err
+
+    def test_unsupported_arg(self):
+        with self.assertRaises(SystemExit):
+            self.run_nodeman(['-x=unknown'])
+
+    def test_version_argument(self):
+        exitcode, out, err = self.run_nodeman_process(['--version'])
+        self.assertEqual(0, exitcode)
+        self.assertEqual('', out)
+        self.assertNotEqual('', err)
+        self.assertRegexpMatches(err, "[0-9]+\.[0-9]+\.[0-9]+")

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list