def test_get_environment_dict_non_existent_file(self): expected = {'prefix': '/home/admin/anaconda3/envs/test-env', 'dependencies': ['mixpanel=1.11.0', 'sigmasix=1.91.0', 'sqlite', {'pip': ['six==1.11.0', 'sqlite==2.0.0']}], 'channels': ['defaults'], 'name': 'test-env'} environment = get_environment_dict(env_fname='environment-test.yml') with self.assertRaises(FileNotFoundError): get_environment_dict(env_fname='non-existent-file.yml')
def test_write_env_name(data, name): with fake_envfile(): dump_environment_to_yaml_file('test.yml', data) write_env_name(name, 'test.yml') assert get_environment_dict('test.yml')['name'] == name
def test_get_environment_dict(self): expected_result = {'prefix': '/home/admin/anaconda3/envs/test-env', 'dependencies': ['mixpanel=1.11.0', 'sigmasix=1.91.0', 'sqlite', {'pip': ['six==1.11.0', 'sqlite==2.0.0']}], 'channels': ['defaults'], 'name': 'test-env'} environment = get_environment_dict(env_fname='environment-test.yml') self.assertDictEqual(environment, expected_result)
def test_write_env_name_no_name(self): data = {'channels': ['defaults'], 'dependencies': ['mixpanel=1.11.0'], 'prefix': '/home/admin/anaconda3/envs/test-env'} dump_environment_to_yaml_file('test.yml', data) write_env_name('test-env', 'test.yml') expected_result = 'test-env' self.assertEqual(get_environment_dict('test.yml')['name'], expected_result)
def test_sanitize_envfile(self): packages = ['six==1.11.0', 'sigmasix=1.91.0'] sanitize_envfile('test.yml', packages) expected_result = {'channels': ['defaults'], 'dependencies': ['mixpanel=1.11.0', 'sqlite', {'pip': ['sqlite==2.0.0']}], 'name': 'test-env', 'prefix': '/home/admin/anaconda3/envs/test-env'} self.assertEqual(get_environment_dict('test.yml'), expected_result)
def test_get_environment_dict_raises_exception_invalid_file(): with fake_envfile(): with open('invalid-yaml-file.yml', 'w') as f: f.write( dedent(""" ok: sub1: sub1 ][ hello: world: world some: other """)) assert get_environment_dict('invalid-yaml-file.yml') == {}
def test_get_environment_dict(): with fake_envfile(): expected_result = { 'prefix': '/home/admin/anaconda3/envs/test-env', 'dependencies': [ 'mixpanel=1.11.0', 'sigmasix=1.91.0', 'sqlite', { 'pip': ['six==1.11.0', 'sqlite==2.0.0'] } ], 'channels': ['defaults'], 'name': 'test-env' } environment = get_environment_dict(env_fname='environment.yml') assert environment == expected_result
def test_dump_environment_to_yaml_file_normal(): with fake_envfile(): data = { 'channels': ['defaults'], 'dependencies': [ 'mixpanel=1.11.0', 'sigmasix=1.91.0', 'sqlite', { 'pip': ['six==1.11.0', 'sqlite==2.0.0'] } ], 'name': 'test-env', 'prefix': '/home/admin/anaconda3/envs/test-env' } dump_environment_to_yaml_file('test.yml', data) assert get_environment_dict('test.yml') == data
def test_get_environment_dict_raises_exception_invalid_file(self): expected_result = {} self.assertDictEqual(get_environment_dict('invalid-yaml-file.yml'), expected_result)
def test_dump_environment_to_yaml_file_normal(self): self.assertEqual(get_environment_dict('test.yml'), self.data)