Ejemplo n.º 1
0
def test_badge_ok_master():
    """Test badge for an OK build using legacy 'master' branch"""
    with utils.mock_systems(systems.app, [sys2]):
        c = systems.app.test_client()
        rv = c.get('/0/badge.svg?branch=master')
        assert b'stable release-2.11.0-brightgreen.svg' in rv.data
        assert rv.status_code == 302
Ejemplo n.º 2
0
def test_badge_old_master():
    """Test redirect for old badge URL using legacy 'master' branch"""
    with utils.mock_systems(systems.app, [sys2]):
        c = systems.app.test_client()
        rv = c.get('/?sysstat=0&branch=master')
        assert b'"/0/badge.svg?branch=main"' in rv.data
        assert rv.status_code == 301
Ejemplo n.º 3
0
def test_badge_failed():
    """Test badge for a failed build"""
    with utils.mock_systems(systems.app, [sys1]):
        c = systems.app.test_client()
        rv = c.get('/0/badge.svg?branch=develop')
        assert b'nightly build-never-red.svg' in rv.data
        assert rv.status_code == 302
Ejemplo n.º 4
0
def test_build_failed():
    """Test the build information page with a system that failed"""
    with utils.mock_systems(systems.app, [sys1, sys2]):
        c = systems.app.test_client()
        rv = c.get('/1/build/3')
        assert (b'was tested but <span class="build_fail">does not work'
                in rv.data)
Ejemplo n.º 5
0
def test_system_class():
    """Test the System class"""
    with utils.mock_systems(systems.app, [sys1, sys2, sys3, sys4]):
        with systems.app.app_context():
            s, s2, s3, s4 = systems.get_all_systems()
        for i in range(2):  # 2nd run should hit cache in most cases
            assert s.name == 'sys1'
            assert s.repo == 'repo1'
            assert s.title == 'sys1 title'
            assert s.pmid == '1234'
            assert s.description == 'sys1 desc'
            assert s.homepage == 'sys1 home'
            assert s.tags == ["foo", "bar"]
            assert s.pubmed_title == 'Smith J. Nature 99, 2014'
            assert s.accessions == ['PDBDEV_00000001', 'foo']
            assert s.pdbdev_accessions == ['PDBDEV_00000001']
            assert s.module_prereqs == ['imp', 'modeller', 'python3/scikit']
            assert s.conda_prereqs == ['imp', 'modeller', 'scikit-learn']
            assert s.readme == u'foobar'
            assert s2.readme == ''
            assert s2.pmid is None
            assert s2.pubmed_title is None
            assert s3.pubmed_title == 'Smith J, Jones A et al. Nature 99, 2014'
            assert s3.homepage == 'https://integrativemodeling.org/systems/22'
            # fly_genome system must use Python 2
            assert s3.name == "fly_genome"
            assert s3.module_prereqs == ['imp', 'modeller', 'python2/scikit']
            # protobuf must use Python 2
            assert s4.module_prereqs == ['imp', 'modeller', 'python2/protobuf']
Ejemplo n.º 6
0
def test_all_builds():
    """Test the all-builds page"""
    with utils.mock_systems(systems.app, [sys1, sys2]):
        c = systems.app.test_client()
        rv = c.get('/all-builds')
        assert (b'<a class="buildbox build_fail" title="Build failed"'
                in rv.data)
        assert b'<a class="buildbox build_ok" title="Build OK"' in rv.data
Ejemplo n.º 7
0
def test_unknown_build():
    """Test the build information page with an unknown system/build"""
    with utils.mock_systems(systems.app, [sys1, sys2]):
        c = systems.app.test_client()
        rv = c.get('/1/build/100')
        assert rv.status_code == 404
        rv = c.get('/100/build/1')
        assert rv.status_code == 404
Ejemplo n.º 8
0
def test_badge_bad():
    """Test badges for bad system or branch"""
    with utils.mock_systems(systems.app, [sys1]):
        c = systems.app.test_client()
        rv = c.get('/9/badge.svg?branch=develop')
        assert rv.status_code == 404

        rv = c.get('/0/badge.svg?branch=foo')
        assert rv.status_code == 400
Ejemplo n.º 9
0
def test_summary_only_tags():
    """Test the summary page with only one tag shown"""
    with utils.mock_systems(systems.app, [sys1, sys2]):
        c = systems.app.test_client()
        rv = c.get('/?tag=bar')
        assert b'<a class="sysmore" href="sys1 home">[more...]</a>' in rv.data
        assert (b'<a class="sysmore" href="sys2 home">[more...]</a>'
                not in rv.data)
        assert b'<a class="tag" href="?tag=foo">foo</a>' in rv.data
        assert b'<a class="tag" href="?tag=bar">bar</a>' in rv.data
        assert b'<a class="tag" href="?tag=baz">baz</a>' in rv.data
Ejemplo n.º 10
0
def test_500():
    """Test custom error handler for an internal error"""
    with utils.mock_systems(systems.app, [sys1]):
        c = systems.app.test_client()
        # Force an error
        systems.app.config['SYSTEM_TOP'] = '/not/exist'
        # Don't throw an exception but instead return a 500 HTTP response
        systems.app.testing = False
        rv = c.get('/')
        assert b'An unexpected error has occurred' in rv.data
        assert rv.status_code == 500
Ejemplo n.º 11
0
 def test_list(self):
     """Test the /api/list route"""
     with utils.mock_systems(systems.app, [sys1]):
         c = systems.app.test_client()
         rv = c.get('/api/list')
         # Should be a JSON string listing all systems
         assert b'"homepage": "sys1 home"' in rv.data
         assert (b'"conda_prereqs": ["imp", "modeller", "scikit-learn"]'
                 in rv.data)
         j = json.loads(rv.data)
         assert len(j) == 1
         assert j[0]['pmid'] == '1234'
Ejemplo n.º 12
0
def test_summary_all_tags():
    """Test the summary page with all tags shown"""
    with utils.mock_systems(systems.app, [sys1, sys2]):
        c = systems.app.test_client()
        rv = c.get('/')
        assert b'<a class="sysmore" href="sys1 home">[more...]</a>' in rv.data
        assert b'<a class="sysmore" href="sys2 home">[more...]</a>' in rv.data
        assert b'<a class="tag" href="?tag=foo">foo</a>' in rv.data
        assert b'<a class="tag" href="?tag=bar">bar</a>' in rv.data
        assert b'<a class="tag" href="?tag=baz">baz</a>' in rv.data
        assert (b'<img src="//integrativemodeling.org/systems/info/'
                b'sys2/thumb.png"' in rv.data)
Ejemplo n.º 13
0
def test_unknown_system():
    """Test the system information page given an unknown system ID"""
    with utils.mock_systems(systems.app, [sys1]):
        c = systems.app.test_client()
        rv = c.get('/100')
        assert rv.status_code == 404
Ejemplo n.º 14
0
def test_system():
    """Test the system information page"""
    with utils.mock_systems(systems.app, [sys1, sys2]):
        c = systems.app.test_client()
        _ = c.get('/1')
Ejemplo n.º 15
0
def test_build_ok():
    """Test the build information page with a system that passed"""
    with utils.mock_systems(systems.app, [sys1, sys2]):
        c = systems.app.test_client()
        rv = c.get('/1/build/1')
        assert b'has been verified to work with:' in rv.data