def test_unknown_remote(self): """Check that a proper exception is raised""" path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'tests_resources', 'not_valid', '4-lift.yaml') self.assertTrue(os.path.isfile(path), '%s does not exist!' % path) with self.assertRaisesRegexp(InvalidDescriptionFile, 'Unknown remote'): load_config_file(path, {}, {}, {})
def test_unknown_remote(self): """Check that a proper exception is raised""" path = os.path.join( os.path.dirname(os.path.realpath(__file__)), "tests_resources", "not_valid", "4-lift.yaml", ) self.assertTrue(os.path.isfile(path), "%s does not exist!" % path) with self.assertRaisesRegexp(InvalidDescriptionFile, "Unknown remote"): load_config_file(path, {}, {}, {})
def test_load(self): """Check a load, without external inheritance""" path = os.path.join( os.path.dirname(os.path.realpath(__file__)), "tests_resources", "valid", "lift.yaml", ) self.assertTrue(os.path.isfile(path), "%s does not exist!" % path) expected_remotes = { "my_remote": OrderedDict([("host", "example.com"), ("username", "root"), ("password", "foobar")]) } expected_environment = {"MY_ENV_VAR1": "foo", "MY_ENV_VAR2": "bar"} expected_tests = [ LocalTest( "ping", "sleep 1", directory=os.path.dirname(path), expected_return_code=0, timeout=10, environment=expected_environment.copy(), ), RemoteTest( "remote_env_with_resource", "sh test/test.sh", expected_remotes["my_remote"], resources=["test/"], directory=os.path.dirname(path), expected_return_code=0, timeout=2, environment={ "MY_ENV_VAR1": "foo", "MY_ENV_VAR2": "edit_bar", "MY_VAR": "content", }, ), ] tests, remotes, environment = load_config_file(path, {}, {}, {}) self.assertEqual( remotes, expected_remotes, "Remotes: inherited %s instead of %s" % (str(remotes), str(expected_remotes)), ) self.assertEqual( environment, expected_environment, "Environment: inherited %s instead of %s" % (str(environment), str(expected_environment)), ) self.assertEqual(tests, expected_tests, "Expected and parsed tests are not the same")
def test_load_with_inheritance(self): """Check a load, with external inheritance""" path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'tests_resources', 'valid', 'lift.yaml') self.assertTrue(os.path.isfile(path), '%s does not exist!' % path) expected_remotes = {'my_remote': OrderedDict([('host', 'example.com'), ('username', 'root'), ('password', 'foobar')]), 'my_remote2': OrderedDict([('host', 'example.org'), ('username', 'root'), ('password', 'barfoo')])} expected_environment = {'MY_ENV_VAR1': 'foo', 'MY_ENV_VAR2': 'bar', 'MY_ENV_VAR3': 'foobar'} expected_tests = [LocalTest('ping', 'sleep 1', directory=os.path.dirname(path), expected_return_code=0, timeout=10, environment=expected_environment.copy()), RemoteTest('remote_env_with_resource', 'sh test/test.sh', expected_remotes['my_remote'], resources=['test/'], directory=os.path.dirname(path), expected_return_code=0, timeout=2, environment={'MY_ENV_VAR1': 'foo', 'MY_ENV_VAR2': 'edit_bar', 'MY_ENV_VAR3': 'foobar', 'MY_VAR': 'content'})] tests, remotes, environment = load_config_file(path, {'my_remote2': OrderedDict([('host', 'example.org'), ('username', 'root'), ('password', 'barfoo')])}, {'MY_ENV_VAR3': 'foobar'}, {}) self.assertEqual(remotes, expected_remotes, 'Remotes: inherited %s instead of %s' % (str(remotes), str(expected_remotes))) self.assertEqual(environment, expected_environment, 'Environment: inherited %s instead of %s' % (str(environment), str(expected_environment))) self.assertEqual(tests, expected_tests, 'Expected and parsed tests are not the same')