Skip to content

Commit

Permalink
add tests of stat
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Aug 10, 2017
1 parent 509383f commit 9c9c31f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
# Packages
*.egg
*.egg-info
dist
build
dist/
build/
eggs
parts
bin
bin/
var
sdist
MANIFEST
develop-eggs
.installed.cfg
lib
lib64
lib/
lib64/
__pycache__

# Sphinx
Expand Down Expand Up @@ -52,4 +52,4 @@ nosetests.xml
.DS_Store

# don't ignore test/bin
!test/bin
!hpsspy/test/bin/*
16 changes: 15 additions & 1 deletion hpsspy/test/bin/hsi
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,18 @@ while getopts O:s: argname; do
esac
done
shift $((OPTIND-1))
echo "$@" > ${ofile}
if [ "$1" = "ls" -a "$2" = "-ld" ]; then
if [ "$3" = "cosmo" ]; then
echo 'lrwxrwxrwx 1 bweaver bweaver 21 Aug 22 2014 cosmo@ -> /nersc/projects/cosmo' > ${ofile}
elif [ "$3" = "/nersc/projects/cosmo" ]; then
echo 'drwxrws--- 6 nugent cosmo 512 Dec 16 2016 cosmo' > ${ofile}
elif [ "$3" = "test" ]; then
echo 'drwxr-sr-x 3 bweaver bweaver 512 Oct 4 2010 test' > ${ofile}
elif [ "$3" = "desi/cosmos_nvo.tar" ]; then
echo '-rw-rw---- 1 bweaver desi 29956061184 May 15 2014 cosmos_nvo.tar' > ${ofile}
else
echo "$@" > ${ofile}
fi
else
echo "$@" > ${ofile}
fi
22 changes: 19 additions & 3 deletions hpsspy/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,36 @@ class TestOs(MockHpss):
"""Test the functions in the os subpackage.
"""

def test_stat(self):
"""Test the stat() function.
"""
s = stat("desi/cosmos_nvo.tar")
self.assertEqual(s.st_size, 29956061184)
self.assertEqual(s.st_mtime, 1400137200)
self.assertEqual(s.st_mode, 33200)

def test_lstat(self):
"""Test the lstat() function.
"""
s = lstat("cosmo")
self.assertTrue(s.islink)
s = lstat("test")
self.assertFalse(s.islink)

def test_isdir(self):
"""Test the isdir() function.
"""
pass
self.assertTrue(isdir('test'))

def test_isfile(self):
"""Test the isfile() function.
"""
pass
self.assertTrue(isfile('desi/cosmos_nvo.tar'))

def test_islink(self):
"""Test the islink() function.
"""
pass
self.assertTrue(islink('cosmo'))


def test_suite():
Expand Down

0 comments on commit 9c9c31f

Please sign in to comment.