Skip to content

Commit

Permalink
Added gitignore and travis yml
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanK committed Mar 17, 2015
1 parent f81d1bf commit c086fd5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
.vagrant
*.pyc
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: python
python:
- "2.6"
- "2.7"
script: python test/test.py
17 changes: 9 additions & 8 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
class TestSequenceFunctions(unittest.TestCase):

def setUp(self):
self.progname = '../src/rcron.py'
self.cwd = os.path.dirname(os.path.abspath(__file__))
self.progname = self.cwd+'/../src/rcron.py'
self.progversion = '0.2.0'
self.statepath = '/tmp/rcron.state'
self.usage = "Usage:\nrcron.py [--help] [--version] [--generate] [--conf file] command [args]"
Expand Down Expand Up @@ -38,31 +39,31 @@ def test_generate(self):
def test_run_passive(self):
self._generate_with_conf('passive')

output = self._run_with(['--conf', './passive.conf', 'echo', 'foo'])
output = self._run_with(['--conf', self.cwd+'/passive.conf', 'echo', 'foo'])
self.assertEqual('', output.strip())

def test_run_active(self):
self._generate_with_conf('active')

output = self._run_with(['--conf', './active.conf', 'echo', 'foo'])
output = self._run_with(['--conf', self.cwd+'/active.conf', 'echo', 'foo'])
self.assertEqual('foo', output.strip())

def test_run_noargs(self):
self._generate_with_conf('passive')

output = self._except_with(['--conf', './passive.conf'])
output = self._except_with(['--conf', self.cwd+'/passive.conf'])
self.assertEqual("not enough arguments\n\n"+self.usage, output)

def test_bad_config(self):
output = self._except_with(['--conf', './bad.conf', 'echo', 'foo'])
output = self._except_with(['--conf', self.cwd+'/bad.conf', 'echo', 'foo'])
self.assertTrue(output.find("warning: couldn't open config: File contains parsing errors: "))

def test_missing_config(self):
output = self._except_with(['--conf', './missing.conf', 'echo', 'foo'])
self.assertTrue(output.find("warning: failed to open config file './missing.conf' : No such file or directory"))
output = self._except_with(['--conf', self.cwd+'/missing.conf', 'echo', 'foo'])
self.assertTrue(output.find("warning: failed to open config file '%s/missing.conf' : No such file or directory" % self.cwd))

def _generate_with_conf(self, confname):
self._run_with(['--conf', './%s.conf' % confname, '--generate'])
self._run_with(['--conf', self.cwd+'/%s.conf' % confname, '--generate'])

def _run_with(self, args):
p = subprocess.Popen(['python', self.progname] + args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
Expand Down

0 comments on commit c086fd5

Please sign in to comment.