diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-06-22 17:50:18 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-06-22 17:50:18 -0400 |
commit | 4003a71535e765fc2e6e727c3702453cc37ca520 (patch) | |
tree | 246de1243e8b0b706cd5a6222fab26409fc9d369 /tests/test.py | |
parent | f089b80df814e94a43db60d77d9f1a2e79428238 (diff) | |
download | cbc-4003a71535e765fc2e6e727c3702453cc37ca520.tar.gz |
Initial commit; nose tests
Diffstat (limited to 'tests/test.py')
-rw-r--r-- | tests/test.py | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/test.py b/tests/test.py new file mode 100644 index 0000000..9041024 --- /dev/null +++ b/tests/test.py @@ -0,0 +1,68 @@ +import nose +import nose.tools +import os +import cbc +from cbc.environment import IncompleteEnv +from cbc.meta import SpecError +import sys + + +class TestCBC(object): + def setUp(self): + lookup = os.path.join(os.path.dirname(__file__), 'data') + output = os.path.join(lookup, 'output') + os.makedirs(output, exist_ok=True) + os.environ['CBC_HOME'] = output + self.env = cbc.environment.Environment() + self.ini = os.path.join(lookup, 'test.ini') + + + def tearDown(self): + pass + + @nose.tools.raises(OSError) + def test_spec_does_not_exist(self): + '''Issue non-existent INI and see what happens. + ''' + spec = cbc.meta.Spec('deadbeefcafe.ini', self.env) + + @nose.tools.raises(IncompleteEnv) + def test_spec_incomplete_environment(self): + '''Screw up the environment on purpose + ''' + del os.environ['CBC_HOME'] + env = cbc.environment.Environment() + + @nose.tools.raises(SpecError) + def test_spec_environment_instance(self): + '''Issue the incorrect class instance as the environment + ''' + env = '' + spec = cbc.meta.Spec(self.ini, env) + + def test_spec_standalone_build_data(self): + spec = cbc.meta.Spec(self.ini, self.env) + nose.tools.assert_in('build_ext', spec.spec_metadata) + + def test_spec_standalone_cgi_server_data(self): + spec = cbc.meta.Spec(self.ini, self.env) + nose.tools.assert_in('cgi', spec.spec_metadata) + + def test_spec_no_ini_and_yaml_crosstalk(self): + spec = cbc.meta.Spec(self.ini, self.env) + nose.tools.assert_not_in('build_ext', spec.conda_metadata) + nose.tools.assert_not_in('cgi', spec.conda_metadata) + + def test_spec_outputs_valid_conda_metadata(self): + spec = cbc.meta.Spec(self.ini, self.env) + spec.conda_write_meta() + import conda_build.metadata + meta = conda_build.metadata.MetaData(self.env.cbchome) + nose.tools.assert_is_instance(meta, conda_build.metadata.MetaData) + nose.tools.assert_equal(meta.dist(), 'test-1.0.0-1') + + + +if __name__ == '__main__': + sys.argv.append('--verbosity=3') + nose.main(argv=sys.argv)
\ No newline at end of file |