def test_layer_build_should_fail_when_no_build_method_is_provided(self, mock_copy_tree, mock_path): given_layer = Mock() given_layer.build_method = None layer_build_definition = LayerBuildDefinition("layer1", "codeuri", "build_method", []) layer_build_definition.layer = given_layer build_graph = Mock(spec=BuildGraph) build_graph.get_layer_build_definitions.return_value = [layer_build_definition] build_graph.get_function_build_definitions.return_value = [] default_build_strategy = DefaultBuildStrategy(build_graph, "build_dir", Mock(), Mock()) self.assertRaises(MissingBuildMethodException, default_build_strategy.build)
def test_layer_build_definition_to_toml_table(self): build_definition = LayerBuildDefinition("name", "codeuri", "method", "runtime") build_definition.layer = generate_function() toml_table = _layer_build_definition_to_toml_table(build_definition) self.assertEqual(toml_table[LAYER_NAME_FIELD], build_definition.name) self.assertEqual(toml_table[CODE_URI_FIELD], build_definition.codeuri) self.assertEqual(toml_table[BUILD_METHOD_FIELD], build_definition.build_method) self.assertEqual(toml_table[COMPATIBLE_RUNTIMES_FIELD], build_definition.compatible_runtimes) self.assertEqual(toml_table[LAYER_FIELD], build_definition.layer.name) self.assertEqual(toml_table[SOURCE_MD5_FIELD], build_definition.source_md5)