Skip to content

Commit

Permalink
[irods/irods_client_icommands#14] Added tests for irmdir
Browse files Browse the repository at this point in the history
Conflicts:
	scripts/run_tests.py
  • Loading branch information
rskarbez committed May 10, 2017
1 parent 7263e6e commit b551ea6
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
80 changes: 80 additions & 0 deletions scripts/irods/test/test_irmdir.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from __future__ import print_function
import sys
if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest

import os

from . import session
from . import settings
from . import resource_suite
from .. import lib

class Test_Irmdir(resource_suite.ResourceBase, unittest.TestCase):

def setUp(self):
super(Test_Irmdir, self).setUp()

def tearDown(self):
super(Test_Irmdir, self).tearDown()

def test_irmdir_of_nonexistent_collection(self):
self.admin.assert_icommand(['irmdir', 'garbage_dir'], 'STDOUT_SINGLELINE', 'Collection does not exist')

def test_irmdir_of_dataobj(self):
filename = 'test_irmdir_of_dataobj'
lib.make_file(filename, 1024, 'arbitrary')
rods_filename = self.admin.session_collection + '/' + filename
self.admin.assert_icommand(['iput', filename, rods_filename])
self.admin.assert_icommand(['irmdir', rods_filename], 'STDOUT_SINGLELINE', 'Collection does not exist')
os.unlink(filename)

def test_irmdir_of_collection_containing_dataobj(self):
filename = 'test_dataobj'
collname = 'test_collection'
lib.make_file(filename, 1024, 'arbitrary')
rods_collname = self.admin.session_collection + '/' + collname
rods_filename = rods_collname + '/' + filename
self.admin.assert_icommand(['imkdir', rods_collname])
self.admin.assert_icommand(['iput', filename, rods_filename])
self.admin.assert_icommand(['irmdir', rods_collname], 'STDOUT_SINGLELINE', 'Collection is not empty')
os.unlink(filename)

def test_irmdir_of_collection_containing_collection(self):
collname_1 = 'test_collection_1'
collname_2 = 'test_collection_2'
rods_collname_1 = self.admin.session_collection + '/' + collname_1
rods_collname_2 = rods_collname_1 + '/' + collname_2
self.admin.assert_icommand(['imkdir', rods_collname_1])
self.admin.assert_icommand(['imkdir', rods_collname_2])
self.admin.assert_icommand(['irmdir', rods_collname_1], 'STDOUT_SINGLELINE', 'Collection is not empty')

def test_irmdir_of_empty_collection(self):
collname = 'test_collection'
rods_collname = self.admin.session_collection + '/' + collname
self.admin.assert_icommand(['imkdir', rods_collname])
self.admin.assert_icommand(['irmdir', rods_collname])
# If irmdir failed, attempting to make a directory with the same name will also fail
self.admin.assert_icommand(['imkdir', rods_collname])

def test_irmdir_dash_p(self):
collname_1 = 'test_collection_1'
collname_2 = 'test_collection_2'
collname_3 = 'subdir'
collname_4 = 'subsubdir'
collname_5 = 'subsubsubdir'
rods_collname_1 = self.admin.session_collection + '/' + collname_1
rods_collname_2 = self.admin.session_collection + '/' + collname_2
rods_collname_3 = rods_collname_2 + '/' + collname_3
rods_collname_4 = rods_collname_3 + '/' + collname_4
rods_collname_5 = rods_collname_4 + '/' + collname_5
self.admin.assert_icommand(['imkdir', rods_collname_1])
self.admin.assert_icommand(['imkdir', rods_collname_2])
self.admin.assert_icommand(['imkdir', rods_collname_3])
self.admin.assert_icommand(['imkdir', rods_collname_4])
self.admin.assert_icommand(['imkdir', rods_collname_5])
self.admin.assert_icommand(['irmdir', '-p', rods_collname_5], 'STDOUT_SINGLELINE', [ '[' + self.admin.session_collection + ']', 'Collection is not empty'])
# If irmdir failed, attempting to make a directory with the same name will also fail
self.admin.assert_icommand(['imkdir', rods_collname_2])
3 changes: 2 additions & 1 deletion scripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ def startTest(self, test):
test_identifiers.extend(['test_xmsg', 'test_iadmin', 'test_resource_types', 'test_catalog', 'test_rulebase',
'test_resource_tree', 'test_load_balanced_suite', 'test_icommands_file_operations', 'test_imeta_set',
'test_all_rules', 'test_iscan', 'test_ichmod', 'test_iput_options', 'test_ireg', 'test_irsync',
'test_iticket', 'test_irodsctl', 'test_resource_configuration', 'test_control_plane', 'test_native_rule_engine_plugin', 'test_quotas', 'test_ils'])
'test_iticket', 'test_irodsctl', 'test_resource_configuration', 'test_control_plane',
'test_native_rule_engine_plugin', 'test_quotas', 'test_ils', 'test_irmdir'])

results = run_tests_from_names(test_identifiers, options.buffer_test_output, options.xml_output)
print(results)
Expand Down

0 comments on commit b551ea6

Please sign in to comment.