Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# .coveragerc to control test coverage report
[report]

exclude_lines =
pragma: no cover

raise AssertionError
raise NotImplementedError

def __repr__
if self\.debug

if 0:
if __name__ == .__main__.:
29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
language: python
sudo: false

cache:
directories:
- $HOME/virtualenv

env:
global:
- CACHE_DIR="$HOME/virtualenv"
- PYTHONIOENCODING=UTF8

python:
- 2.7
- 3.4

before_install:
- travis/before_install.sh

install:
- travis/install-pip.sh
- travis/install-tools.sh

script:
- travis/tests-unit.sh
- travis/tests-long.sh

after_success:
- coveralls
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

**Composite of Multiple Signals**: tests for selection in meiotically recombinant populations

[![Travis CI Status](https://api.travis-ci.org/broadinstitute/cms.svg)](https://travis-ci.org/broadinstitute/cms)
[![Coverage Status](https://coveralls.io/repos/broadinstitute/cms/badge.svg)](https://coveralls.io/r/broadinstitute/cms)
[![Documentation Status](https://readthedocs.org/projects/broad-cms/badge/?version=latest)](https://readthedocs.org/projects/broad-cms/?badge=latest)

More detailed documentation can be found at http://broad-cms.readthedocs.org/
Expand Down
1 change: 1 addition & 0 deletions cms/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7bc1b96-dirty
6 changes: 6 additions & 0 deletions cms/cms_exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class CMSException(Exception):
'''base class for CMS exceptions. except for built-ins, all should be descendants of this exception so that an except block for this exception will catch all others'''
pass

class CMSInputError(CMSException):
pass
12 changes: 12 additions & 0 deletions cms/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/python

class CMS(object):
def __init__(self):
pass

def main(self):
return 0

if __name__ == "__main__":
cms = CMS()
cms.main()
8 changes: 8 additions & 0 deletions cms/selection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/python

class Selection(object):
def __init__(self):
pass

def main(self):
return 0
35 changes: 35 additions & 0 deletions cms/test/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'''utilities for tests'''

__author__ = "irwin@broadinstitute.org"

import filecmp, os, unittest

import util.file

def assert_equal_contents(testCase, filename1, filename2) :
'Assert contents of two files are equal for a unittest.TestCase'
testCase.assertTrue(filecmp.cmp(filename1, filename2, shallow=False))

class TestCaseWithTmp(unittest.TestCase) :
'Base class for tests that use tempDir'
def setUp(self) :
util.file.set_tmpDir(type(self).__name__)

def tearDown(self) :
util.file.destroy_tmpDir()

def assertEqualContents(self, f1, f2) :
assert_equal_contents(self, f1, f2)


"""
When "nose" executes python scripts for automated testing, it excludes ones with
the executable bit set (in case they aren't import safe). To prevent any of the
tests in this folder from being silently excluded, assure this bit is not set.
"""
def assert_none_executable() :
testDir = os.path.dirname(__file__)
assert all(not os.access(os.path.join(testDir, filename), os.X_OK)
for filename in os.listdir(testDir)
if filename.endswith('.py'))
assert_none_executable()
File renamed without changes.
18 changes: 18 additions & 0 deletions cms/test/integration/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/python

import unittest
import main

class TestCMS(unittest.TestCase):
# to be executed prior to running tests
def setUp(self):
self.cms = main.CMS()
pass

# to be executed after running tests, regardless of pass/fail
# only called if setUp succeeds
def tearDown(self):
pass

def test_main_return_code(self):
self.assertEqual( self.cms.main(), 0 )
Empty file added cms/test/unit/__init__.py
Empty file.
18 changes: 18 additions & 0 deletions cms/test/unit/test_selection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/python

import unittest
from selection import Selection

class TestSelection(unittest.TestCase):
# to be executed prior to running tests
def setUp(self):
self.cms_selection = Selection()
pass

# to be executed after running tests, regardless of pass/fail
# only called if setUp succeeds
def tearDown(self):
pass

def test_selection_return_code(self):
self.assertEqual( self.cms_selection.main(), 0 )
33 changes: 33 additions & 0 deletions cms/test/unit/test_tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Unit tests for tools/__init__.py

__author__ = "dpark@broadinstitute.org"

import tools
from tools import *
import unittest, tempfile, shutil, os, logging
import util.cmd, util.file
from test import TestCaseWithTmp

log = logging.getLogger(__name__)

class TestToolsInstallation(TestCaseWithTmp):
def setUp(self):
super(TestToolsInstallation, self).setUp()
util.cmd.setup_logger('INFO')
def testAllToolInstallers(self):
def iter_leaf_subclasses(aClass) :
"Iterate over subclasses at all levels that don't themselves have a subclass"
isLeaf = True
for subclass in aClass.__subclasses__() :
isLeaf = False
for leafClass in iter_leaf_subclasses(subclass) :
yield leafClass
#if isLeaf :
# yield aClass
'''Load every tool's default chain of install methods and try them.'''
for tool_class in iter_leaf_subclasses(tools.Tool):
t = tool_class()
t.install()
self.assertTrue(t.is_installed(), "installation of tool %s failed" % tool_class.__name__)
log.info(".. installation of %s succeeded with installer %s" % (tool_class.__name__, t.installed_method.__class__.__name__))

Loading