1
+ import pytest
2
+ from azure .ai .ml import Input
3
+ from azure .ai .ml .entities import (
4
+ Component ,
5
+ CommandComponent ,
6
+ PipelineComponent ,
7
+ ValidationResult ,
8
+ )
9
+ from azure .ai .ml .dsl ._mldesigner import (
10
+ _AdditionalIncludes ,
11
+ InternalComponent ,
12
+ )
13
+ from azure .ai .ml .entities ._builders .base_node import BaseNode
14
+ from azure .ai .ml .entities ._inputs_outputs import GroupInput
15
+ from azure .ai .ml .entities ._job .pipeline ._io import PipelineInput , NodeOutput , NodeInput
16
+
17
+
18
+ @pytest .mark .unittest
19
+ @pytest .mark .pipeline_test
20
+ class TestMldesignerImports :
21
+ """
22
+ The assertions are NOT SUPPOSED TO BE CHANGED once they are added.
23
+
24
+ The attributes are needed for a certain version of mldesigner package, modifying or deleting any of them will cause
25
+ compatibility issues. If there are new dependencies for mldesigner package, add new assertions in this file.
26
+ """
27
+ def test_necessay_attributes (self ):
28
+ assert hasattr (Component , "_customized_validate" )
29
+ assert hasattr (Component , "_source_path" )
30
+ assert hasattr (CommandComponent , "_to_dict" )
31
+ assert hasattr (CommandComponent , "_source_path" )
32
+ assert hasattr (PipelineComponent , "_to_dict" )
33
+ assert hasattr (PipelineComponent , "_source_path" )
34
+ assert hasattr (PipelineComponent , "jobs" )
35
+ assert hasattr (InternalComponent , "_to_dict" )
36
+ assert hasattr (InternalComponent , "_source_path" )
37
+ assert hasattr (InternalComponent , "_additional_includes" )
38
+ assert hasattr (_AdditionalIncludes , "with_includes" )
39
+ assert hasattr (_AdditionalIncludes , "_code_path" )
40
+ assert hasattr (_AdditionalIncludes , "_includes" )
41
+ assert hasattr (ValidationResult , "passed" )
42
+ assert hasattr (ValidationResult , "error_messages" )
43
+
44
+ def test_necessary_attributes_for_input (self ):
45
+ input_obj = Input ()
46
+ assert hasattr (input_obj , "type" )
47
+ assert hasattr (input_obj , "_is_enum" )
48
+ assert hasattr (input_obj , "default" )
49
+ assert hasattr (input_obj , "min" )
50
+ assert hasattr (input_obj , "max" )
51
+ assert hasattr (input_obj , "optional" )
52
+ assert hasattr (input_obj , "_is_literal" )
53
+ assert hasattr (input_obj , "_get_python_builtin_type_str" )
54
+ assert hasattr (input_obj , "_get_param_with_standard_annotation" )
55
+
56
+ node_input_obj = NodeInput (name = "sdk" , meta = input_obj )
57
+ assert hasattr (node_input_obj , "_meta" )
58
+ assert hasattr (node_input_obj , "_data" )
59
+
60
+ def test_class_names (self ):
61
+ """These class are undirectly used in mldesigner by their class names"""
62
+ assert BaseNode .__name__ == "BaseNode"
63
+ assert GroupInput .__name__ == "GroupInput"
64
+ assert PipelineInput .__name__ == "PipelineInput"
65
+ assert NodeInput .__name__ == "NodeInput"
66
+ assert NodeOutput .__name__ == "NodeOutput"
0 commit comments