def test_build_behaviour(self): project_sim = self.simlab.simulate_type_with_behaviour() project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) self.assertFalse(result.validation_result.has_warnings()) pkg = result.pkg with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_descriptor_file( os.path.join(TYPE_DESCRIPTOR_DIR, TYPE_DESCRIPTOR_YML_FILE), WITH_BEHAVIOUR_DESCRIPTOR_YAML) pkg_tester.assert_has_directory(ASSEMBLY_BEHAVIOUR_DIR) pkg_tester.assert_has_directory( os.path.join(ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR)) pkg_tester.assert_has_file( os.path.join(ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR, 'simple.json'), WITH_BEHAVIOUR_SIMPLE_CONFIGURATION_JSON) pkg_tester.assert_has_directory( os.path.join(ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_TESTS_DIR)) pkg_tester.assert_has_file( os.path.join(ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_TESTS_DIR, 'test.json'), WITH_BEHAVIOUR_TEST_JSON) pkg_tester.assert_has_meta({ 'schema': '2.0', 'name': 'with_behaviour', 'version': '1.0', 'type': 'Type' })
def test_build_with_template(self): project_sim = self.simlab.simulate_assembly_with_template() project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) self.assertIsInstance(result, BuildResult) self.assertFalse(result.validation_result.has_warnings()) pkg = result.pkg self.assertIsNotNone(pkg) self.assertIsInstance(pkg, pkgs.Pkg) package_base_name = os.path.basename(pkg.path) self.assertEqual(package_base_name, 'with_template-1.0.tgz') with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_descriptor_file( os.path.join(ASSEMBLY_DESCRIPTOR_DIR, ASSEMBLY_DESCRIPTOR_YML_FILE), WITH_TEMPLATE_ASSEMBLY_DESCRIPTOR_YAML) pkg_tester.assert_has_descriptor_file( os.path.join(ASSEMBLY_DESCRIPTOR_DIR, ASSEMBLY_DESCRIPTOR_TEMPLATE_YML_FILE), WITH_TEMPLATE_ASSEMBLY_TEMPLATE_DESCRIPTOR_YAML) pkg_tester.assert_has_meta({ 'schema': '2.0', 'name': 'with_template', 'version': '1.0', 'type': 'Assembly' })
def test_unresolvable_references(self): project_sim = self.simlab.simulate_assembly_with_unresolvable_references( ) project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) pkg = result.pkg self.assertIsNotNone(pkg) self.assertIsInstance(pkg, pkgs.Pkg) package_base_name = os.path.basename(pkg.path) self.assertEqual(package_base_name, 'with_unresolvable_references-1.0.tgz') with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_descriptor_file( os.path.join(ASSEMBLY_DESCRIPTOR_DIR, ASSEMBLY_DESCRIPTOR_YML_FILE), UNRESOLVABLE_DESCRIPTOR) pkg_tester.assert_has_file( os.path.join(ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR, 'bad_path.json'), UNRESOLVABLE_CONFIGURATION_BAD_PATH) pkg_tester.assert_has_file( os.path.join(ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR, 'not_found.json'), UNRESOLVABLE_CONFIGURATION_NOT_FOUND)
def test_build(self): project_sim = self.simlab.simulate_assembly_contains_assembly_basic() project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) self.assertIsInstance(result, BuildResult) self.assertFalse(result.validation_result.has_warnings()) pkg = result.pkg self.assertIsNotNone(pkg) self.assertIsInstance(pkg, pkgs.Pkg) package_base_name = os.path.basename(pkg.path) self.assertEqual(package_base_name, 'contains_basic-1.0.tgz') with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_descriptor_file( os.path.join(PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_ASSEMBLY_BASIC, ASSEMBLY_DESCRIPTOR_DIR, ASSEMBLY_DESCRIPTOR_YML_FILE), SUB_BASIC_ASSEMBLY_DESCRIPTOR_YAML) pkg_tester.assert_has_meta({ 'schema': '2.0', 'name': 'contains_basic', 'version': '1.0', 'type': 'Assembly', 'contains': [{ 'name': 'sub_basic', 'type': 'Assembly', 'directory': 'sub_basic' }] })
def test_build_empty_infrastructure(self): project_sim = self.simlab.simulate_brent_2dot1_with_empty_infrastructure( ) project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) self.assertIsInstance(result, BuildResult) self.assertFalse(result.validation_result.has_warnings()) pkg = result.pkg self.assertIsNotNone(pkg) self.assertIsInstance(pkg, pkgs.Pkg) package_base_name = os.path.basename(pkg.path) self.assertEqual(package_base_name, 'with-empty-infrastructure-1.0.tgz') with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_file_path('with-empty-infrastructure.zip') with self.assert_zip( pkg_tester.get_file_path( 'with-empty-infrastructure.zip')) as zip_tester: zip_tester.assert_has_directory(BRENT_DEFINITIONS_DIR) inf_path = os.path.join(BRENT_DEFINITIONS_DIR, BRENT_INFRASTRUCTURE_DIR) zip_tester.assert_has_directory(inf_path) zip_tester.assert_has_no_file( os.path.join(inf_path, '.gitkeep'))
def test_validate_assembly_subproject_with_invalid_json_test(self): project_sim = self.simlab.simulate_assembly_contains_invalid_assembly_invalid_json_test() project = Project(project_sim.path) build_options = BuildOptions() with self.assertRaises(BuildValidationError) as context: project.build(build_options) test_path = os.path.join(project_sim.path, PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_INVALID_ASSEMBLY_INVALID_JSON_TEST, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_TESTS_DIR, 'notvalid.json') self.assert_validation_errors(context.exception.validation_result, 'Test [{0}]: does not contain valid JSON: Expecting value: line 1 column 1 (char 0)'.format(test_path))
def test_validate_assembly_subproject_with_non_json_test(self): project_sim = self.simlab.simulate_assembly_contains_invalid_assembly_non_json_test() project = Project(project_sim.path) build_options = BuildOptions() with self.assertRaises(BuildValidationError) as context: project.build(build_options) test_path = os.path.join(project_sim.path, PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_INVALID_ASSEMBLY_NON_JSON_TEST, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_TESTS_DIR, 'notjson.xml') self.assert_validation_errors(context.exception.validation_result, 'Test [{0}]: is not a json file (with a .json extension)'.format(test_path))
def test_validate_assembly_subproject_without_descriptor_file(self): project_sim = self.simlab.simulate_assembly_contains_invalid_assembly_no_descriptor() project = Project(project_sim.path) build_options = BuildOptions() with self.assertRaises(BuildValidationError) as context: project.build(build_options) descriptor_path = os.path.join(project_sim.path, PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_INVALID_ASSEMBLY_NO_DESCRIPTOR, ASSEMBLY_DESCRIPTOR_DIR, ASSEMBLY_DESCRIPTOR_YML_FILE) self.assert_validation_errors(context.exception.validation_result, 'No descriptor found at: {0}'.format(descriptor_path))
def test_build_validate_assembly_with_invalid_json_runtime(self): project_sim = self.simlab.simulate_invalid_assembly_invalid_json_runtime() project = Project(project_sim.path) build_options = BuildOptions() with self.assertRaises(BuildValidationError) as context: project.build(build_options) runtime_path = os.path.join(project_sim.path, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_RUNTIME_DIR, 'notvalid.json') self.assert_validation_errors(context.exception.validation_result, 'Runtime [{0}]: does not contain valid JSON: Expecting value: line 1 column 1 (char 0)'.format(runtime_path))
def test_build_validate_assembly_with_non_json_runtime(self): project_sim = self.simlab.simulate_invalid_assembly_non_json_runtime() project = Project(project_sim.path) build_options = BuildOptions() with self.assertRaises(BuildValidationError) as context: project.build(build_options) runtime_path = os.path.join(project_sim.path, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_RUNTIME_DIR, 'notjson.xml') self.assert_validation_errors(context.exception.validation_result, 'Runtime [{0}]: is not a json file (with a .json extension)'.format(runtime_path))
def test_build(self): project_sim = self.simlab.simulate_brent_basic() project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) self.assertIsInstance(result, BuildResult) self.assertFalse(result.validation_result.has_warnings()) pkg = result.pkg self.assertIsNotNone(pkg) self.assertIsInstance(pkg, pkgs.Pkg) package_base_name = os.path.basename(pkg.path) self.assertEqual(package_base_name, 'basic-1.0.tgz') with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_file_path('basic.zip') pkg_tester.assert_has_file(BRENT_DESCRIPTOR_YML_FILE, BASIC_DESCRIPTOR_YAML) pkg_tester.assert_has_meta({ 'schema': '2.0', 'name': 'basic', 'version': '1.0', 'type': 'Resource', 'resource-manager': 'brent' }) with self.assert_zip( pkg_tester.get_file_path('basic.zip')) as zip_tester: zip_tester.assert_has_directory(BRENT_DEFINITIONS_DIR) lm_path = os.path.join(BRENT_DEFINITIONS_DIR, BRENT_DESCRIPTOR_DIR) zip_tester.assert_has_file( os.path.join(lm_path, BRENT_DESCRIPTOR_YML_FILE), BASIC_DESCRIPTOR_YAML) zip_tester.assert_has_directory(BRENT_LIFECYCLE_DIR) openstack_dir = os.path.join(BRENT_LIFECYCLE_DIR, BRENT_OPENSTACK_DIR) zip_tester.assert_has_directory(openstack_dir) openstack_tosca_path = os.path.join( openstack_dir, BRENT_OPENSTACK_TOSCA_YAML_FILE) zip_tester.assert_has_file(openstack_tosca_path, BASIC_INFRASTRUCTURE_TOSCA) ansible_dir = os.path.join(BRENT_LIFECYCLE_DIR, BRENT_LIFECYCLE_ANSIBLE_DIR) zip_tester.assert_has_directory(ansible_dir) ansible_scripts_dir = os.path.join( ansible_dir, BRENT_LIFECYCLE_ANSIBLE_SCRIPTS_DIR) zip_tester.assert_has_directory(ansible_scripts_dir) zip_tester.assert_has_file( os.path.join(ansible_scripts_dir, 'Install.yaml'), BASIC_INSTALL_PLAYBOOK) ansible_config_dir = os.path.join( ansible_dir, BRENT_LIFECYCLE_ANSIBLE_CONFIG_DIR) zip_tester.assert_has_directory(ansible_config_dir) zip_tester.assert_has_file( os.path.join(ansible_config_dir, 'inventory'), BASIC_INVENTORY) zip_tester.assert_has_file( os.path.join(ansible_config_dir, 'host_vars', 'example-host.yml'), BASIC_EXAMPLE_HOST_YAML)
def test_validate_assembly_subproject_descriptor_name(self): project_sim = self.simlab.simulate_assembly_contains_invalid_assembly_mismatch_descriptor_name() project = Project(project_sim.path) build_options = BuildOptions() with self.assertRaises(BuildValidationError) as context: project.build(build_options) descriptor_path = os.path.join(project_sim.path, PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_INVALID_ASSEMBLY_MISMATCH_DESCRIPTOR_NAME, ASSEMBLY_DESCRIPTOR_DIR, 'assembly.yml') expected_errors = [] expected_errors.append('Descriptor [{0}]: name \'resource::notvalid::9.7\' includes type \'resource\' but this should be \'assembly\' based on project configuration'.format(descriptor_path)) expected_errors.append( 'Descriptor [{0}]: name \'resource::notvalid::9.7\' includes \'notvalid\' but this should be \'sub_invalid_mismatch_descriptor_name-contains_invalid_mismatch_descriptor_name\' based on project configuration'.format(descriptor_path)) expected_errors.append('Descriptor [{0}]: name \'resource::notvalid::9.7\' includes version \'9.7\' but this should be \'1.0\' based on project configuration'.format(descriptor_path)) self.assert_validation_errors(context.exception.validation_result, *expected_errors)
def test_behaviour_references(self): project_sim = self.simlab.simulate_assembly_with_behaviour_references() project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) pkg = result.pkg self.assertIsNotNone(pkg) self.assertIsInstance(pkg, pkgs.Pkg) package_base_name = os.path.basename(pkg.path) self.assertEqual(package_base_name, 'with_behaviour_references-1.0.tgz') with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_file( os.path.join(ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR, 'root.json'), WITH_BEH_REFERENCE_ROOT_CONFIGURATION_ROOT) pkg_tester.assert_has_file( os.path.join(ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR, 'subA.json'), WITH_BEH_REFERENCE_ROOT_CONFIGURATION_SUBA) pkg_tester.assert_has_file( os.path.join(ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR, 'subAA.json'), WITH_BEH_REFERENCE_ROOT_CONFIGURATION_SUBAA) pkg_tester.assert_has_file( os.path.join(ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_RUNTIME_DIR, 'runtime.json'), WITH_BEH_REFERENCE_ROOT_RUNTIME) pkg_tester.assert_has_file( os.path.join(ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_TESTS_DIR, 'test.json'), WITH_BEH_REFERENCE_ROOT_TEST) subA_path = os.path.join(PROJECT_CONTAINS_DIR, 'subA') pkg_tester.assert_has_file( os.path.join(subA_path, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR, 'root.json'), WITH_BEH_REFERENCE_SUBA_CONFIGURATION_ROOT) pkg_tester.assert_has_file( os.path.join(subA_path, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR, 'subAB.json'), WITH_BEH_REFERENCE_SUBA_CONFIGURATION_SUBAB) pkg_tester.assert_has_file( os.path.join(subA_path, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR, 'subB.json'), WITH_BEH_REFERENCE_SUBA_CONFIGURATION_SUBB) subAB_path = os.path.join(subA_path, PROJECT_CONTAINS_DIR, 'subAB') pkg_tester.assert_has_file( os.path.join(subAB_path, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR, 'subB.json'), WITH_BEH_REFERENCE_SUAB_CONFIGURATION_SUBB)
def test_vnfcs(self): project_sim = self.simlab.simulate_assembly_old_style() project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) self.assertTrue( os.path.exists(os.path.join(project_sim.path, PROJECT_VNFCS_DIR))) self.assertTrue( os.path.exists( os.path.join(project_sim.path, PROJECT_VNFCS_DIR, 'vnfcA'))) self.assertTrue( os.path.exists( os.path.join(project_sim.path, PROJECT_VNFCS_DIR, 'vnfcB'))) pkg = result.pkg self.assertIsNotNone(pkg) self.assertIsInstance(pkg, pkgs.Pkg) package_base_name = os.path.basename(pkg.path) self.assertEqual(package_base_name, 'old_style-1.0.tgz') with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_descriptor_file( os.path.join(PROJECT_CONTAINS_DIR, 'vnfcA', 'vnfcA-old_style.yml'), VNFC_A_DESCRIPTOR_YAML) pkg_tester.assert_has_descriptor_file( os.path.join(PROJECT_CONTAINS_DIR, 'vnfcB', 'vnfcB-old_style.yml'), VNFC_B_DESCRIPTOR_YAML) pkg_tester.assert_has_meta({ 'schema': '2.0', 'name': 'old_style', 'version': '1.0', 'type': 'Assembly', 'contains': [{ 'name': 'vnfcA', 'type': 'Resource', 'directory': 'vnfcA', 'resource-manager': 'ansible-rm' }, { 'name': 'vnfcB', 'type': 'Resource', 'directory': 'vnfcB', 'resource-manager': 'ansible-rm' }] })
def test_build(self): project_sim = self.simlab.simulate_type_basic() project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) self.assertIsInstance(result, BuildResult) self.assertFalse(result.validation_result.has_warnings()) pkg = result.pkg self.assertIsNotNone(pkg) self.assertIsInstance(pkg, pkgs.Pkg) package_base_name = os.path.basename(pkg.path) self.assertEqual(package_base_name, 'basic-1.0.tgz') with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_descriptor_file( os.path.join(TYPE_DESCRIPTOR_DIR, TYPE_DESCRIPTOR_YML_FILE), BASIC_TYPE_DESCRIPTOR_YAML) pkg_tester.assert_has_meta({ 'schema': '2.0', 'name': 'basic', 'version': '1.0', 'type': 'Type' })
def test_build_csar(self): project_sim = self.simlab.simulate_brent_tosca() project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) self.assertIsInstance(result, BuildResult) self.assertFalse(result.validation_result.has_warnings()) pkg = result.pkg self.assertIsNotNone(pkg) self.assertIsInstance(pkg, pkgs.Pkg) package_base_name = os.path.basename(pkg.path) self.assertEqual(package_base_name, 'with_tosca-1.0.csar') self.assertTrue(zipfile.is_zipfile(pkg.path)) with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_file_path('with_tosca.zip') pkg_tester.assert_has_file_path(BRENT_DESCRIPTOR_YML_FILE) pkg_tester.assert_has_meta({ 'schema': '2.0', 'name': 'with_tosca', 'version': '1.0', 'type': 'Resource', 'resource-manager': 'lm' })
def test_descriptor_references(self): project_sim = self.simlab.simulate_assembly_with_descriptor_references( ) project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) pkg = result.pkg self.assertIsNotNone(pkg) self.assertIsInstance(pkg, pkgs.Pkg) package_base_name = os.path.basename(pkg.path) self.assertEqual(package_base_name, 'with_descriptor_references-1.0.tgz') with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_descriptor_file( os.path.join(ASSEMBLY_DESCRIPTOR_DIR, ASSEMBLY_DESCRIPTOR_YML_FILE), WITH_REFERENCE_ROOT_DESCRIPTOR_YAML) subA_path = os.path.join(PROJECT_CONTAINS_DIR, 'subA') pkg_tester.assert_has_descriptor_file( os.path.join(subA_path, ASSEMBLY_DESCRIPTOR_DIR, ASSEMBLY_DESCRIPTOR_YML_FILE), WITH_REFERENCE_SUBA_DESCRIPTOR_YAML) pkg_tester.assert_has_descriptor_file( os.path.join(subA_path, PROJECT_CONTAINS_DIR, 'subAA', ASSEMBLY_DESCRIPTOR_DIR, ASSEMBLY_DESCRIPTOR_YML_FILE), WITH_REFERENCE_SUBAA_DESCRIPTOR_YAML) pkg_tester.assert_has_descriptor_file( os.path.join(subA_path, PROJECT_CONTAINS_DIR, 'subAB', ASSEMBLY_DESCRIPTOR_DIR, ASSEMBLY_DESCRIPTOR_YML_FILE), WITH_REFERENCE_SUBAB_DESCRIPTOR_YAML) pkg_tester.assert_has_descriptor_file( os.path.join(PROJECT_CONTAINS_DIR, 'subB', 'subB-with_descriptor_references.yml'), WITH_REFERENCE_SUBB_DESCRIPTOR_YAML)
def test_has_journal_consumer(self): self.assertTrue(hasattr(Options(), 'journal_consumer')) self.assertTrue(hasattr(ValidateOptions(), 'journal_consumer')) self.assertTrue(hasattr(BuildOptions(), 'journal_consumer')) self.assertTrue(hasattr(PullOptions(), 'journal_consumer'))
def test_build(self): project_sim = self.simlab.simulate_assembly_contains_brent_2dot1_basic( ) project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) self.assertIsInstance(result, BuildResult) self.assertFalse(result.validation_result.has_warnings()) pkg = result.pkg self.assertIsNotNone(pkg) self.assertIsInstance(pkg, pkgs.Pkg) package_base_name = os.path.basename(pkg.path) self.assertEqual(package_base_name, 'contains_basic-1.0.tgz') sub_brent_basic_path = os.path.join( PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_BRENT_BASIC) with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_file_path( os.path.join(sub_brent_basic_path, 'sub_basic-contains_basic.zip')) pkg_tester.assert_has_file( os.path.join(sub_brent_basic_path, BRENT_DESCRIPTOR_YML_FILE), SUB_BASIC_DESCRIPTOR_YAML) pkg_tester.assert_has_meta({ 'schema': '2.0', 'name': 'contains_basic', 'version': '1.0', 'type': 'Assembly', 'contains': [{ 'name': 'sub_basic', 'type': 'Resource', 'resource-manager': 'brent2.1', 'directory': 'sub_basic' }] }) with self.assert_zip( pkg_tester.get_file_path( os.path.join( sub_brent_basic_path, 'sub_basic-contains_basic.zip'))) as zip_tester: zip_tester.assert_has_directory(BRENT_DEFINITIONS_DIR) inf_path = os.path.join(BRENT_DEFINITIONS_DIR, BRENT_INFRASTRUCTURE_DIR) zip_tester.assert_has_directory(inf_path) zip_tester.assert_has_file( os.path.join(inf_path, 'example.yaml'), BASIC_INFRASTRUCTURE_TOSCA) lm_path = os.path.join(BRENT_DEFINITIONS_DIR, BRENT_DESCRIPTOR_DIR) zip_tester.assert_has_file( os.path.join(lm_path, BRENT_DESCRIPTOR_YML_FILE), SUB_BASIC_DESCRIPTOR_YAML) zip_tester.assert_has_directory(BRENT_LIFECYCLE_DIR) ansible_dir = os.path.join(BRENT_LIFECYCLE_DIR, BRENT_LIFECYCLE_ANSIBLE_DIR) zip_tester.assert_has_directory(ansible_dir) ansible_scripts_dir = os.path.join( ansible_dir, BRENT_LIFECYCLE_ANSIBLE_SCRIPTS_DIR) zip_tester.assert_has_directory(ansible_scripts_dir) zip_tester.assert_has_file( os.path.join(ansible_scripts_dir, 'Install.yaml'), BASIC_INSTALL_PLAYBOOK) ansible_config_dir = os.path.join( ansible_dir, BRENT_LIFECYCLE_ANSIBLE_CONFIG_DIR) zip_tester.assert_has_directory(ansible_config_dir) zip_tester.assert_has_file( os.path.join(ansible_config_dir, 'inventory'), BASIC_INVENTORY) zip_tester.assert_has_file( os.path.join(ansible_config_dir, 'host_vars', 'example-host.yml'), BASIC_EXAMPLE_HOST_YAML)
def test_build_behaviour(self): project_sim = self.simlab.simulate_assembly_contains_assembly_with_behaviour( ) project = Project(project_sim.path) build_options = BuildOptions() result = project.build(build_options) self.assertFalse(result.validation_result.has_warnings()) pkg = result.pkg with self.assert_package(pkg) as pkg_tester: pkg_tester.assert_has_descriptor_file( os.path.join( PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_ASSEMBLY_WITH_BEHAVIOUR, ASSEMBLY_DESCRIPTOR_DIR, ASSEMBLY_DESCRIPTOR_YML_FILE), SUB_WITH_BEHAVIOUR_DESCRIPTOR_YAML) pkg_tester.assert_has_directory( os.path.join( PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_ASSEMBLY_WITH_BEHAVIOUR, ASSEMBLY_BEHAVIOUR_DIR)) pkg_tester.assert_has_directory( os.path.join( PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_ASSEMBLY_WITH_BEHAVIOUR, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR)) pkg_tester.assert_has_file( os.path.join( PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_ASSEMBLY_WITH_BEHAVIOUR, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_CONFIGURATIONS_DIR, 'simple.json'), SUB_WITH_BEHAVIOUR_SIMPLE_CONFIGURATION_JSON) pkg_tester.assert_has_directory( os.path.join( PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_ASSEMBLY_WITH_BEHAVIOUR, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_RUNTIME_DIR)) pkg_tester.assert_has_file( os.path.join( PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_ASSEMBLY_WITH_BEHAVIOUR, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_RUNTIME_DIR, 'runtime.json'), SUB_WITH_BEHAVIOUR_RUNTIME_JSON) pkg_tester.assert_has_directory( os.path.join( PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_ASSEMBLY_WITH_BEHAVIOUR, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_TESTS_DIR)) pkg_tester.assert_has_file( os.path.join( PROJECT_CONTAINS_DIR, project_lab.SUBPROJECT_NAME_ASSEMBLY_WITH_BEHAVIOUR, ASSEMBLY_BEHAVIOUR_DIR, ASSEMBLY_TESTS_DIR, 'test.json'), SUB_WITH_BEHAVIOUR_TEST_JSON) pkg_tester.assert_has_meta({ 'schema': '2.0', 'name': 'contains_with_behaviour', 'version': '1.0', 'type': 'Assembly', 'contains': [{ 'name': 'sub_with_behaviour', 'type': 'Assembly', 'directory': 'sub_with_behaviour' }] })