1
1
import uuid
2
+ from typing import Any , Union
2
3
3
- import utils
4
+ from case_mapping import mix_utils
4
5
5
6
6
- def check_app_name (app_name , app_names , app_objects , uuid ):
7
- # c_check = utils.CheckDuplicate()
8
- observable_app = utils .check_value (
7
+ def check_app_name (
8
+ app_name : str , app_names : list [str ], app_objects : list [dict [str , Any ]], uuid : str
9
+ ) -> dict [str , Any ]:
10
+ # c_check = mix_utils.CheckDuplicate()
11
+ observable_app = mix_utils .check_value (
9
12
app_name ,
10
13
uuid ,
11
14
value = app_name ,
@@ -16,9 +19,15 @@ def check_app_name(app_name, app_names, app_objects, uuid):
16
19
return observable_app
17
20
18
21
19
- def check_geo_coordinates (latitude , longitude , geo_coordinates , geo_objects , uuid ):
20
- # c_check = utils.CheckDuplicate()
21
- observable_app = utils .check_value (
22
+ def check_geo_coordinates (
23
+ latitude : float ,
24
+ longitude : float ,
25
+ geo_coordinates : list [str ],
26
+ geo_objects : list [dict [str , Any ]],
27
+ uuid : str ,
28
+ ) -> dict [str , Any ]:
29
+ # c_check = mix_utils.CheckDuplicate()
30
+ observable_app = mix_utils .check_value (
22
31
latitude ,
23
32
longitude ,
24
33
uuid ,
@@ -30,7 +39,7 @@ def check_geo_coordinates(latitude, longitude, geo_coordinates, geo_objects, uui
30
39
return observable_app
31
40
32
41
33
- def generateTraceAppName (app_name , uuid ) :
42
+ def generateTraceAppName (app_name : str , uuid : str ) -> dict [ str , Any ] :
34
43
observable = {
35
44
"@type" : "uco-observable:ApplicationFacet" ,
36
45
"@id" : uuid ,
@@ -39,19 +48,21 @@ def generateTraceAppName(app_name, uuid):
39
48
return observable
40
49
41
50
42
- def generateTraceLocationCoordinate (latitude , longitude , uuid ):
51
+ def generateTraceLocationCoordinate (
52
+ latitude : Union [float , str ], longitude : Union [float , str ], uuid : str
53
+ ) -> dict [str , Any ]:
43
54
observable = {
44
55
"@type" : "uco-location:LatLongCoordinatesFacet" ,
45
56
"@id" : uuid ,
46
- "uco-location:latitude" : {"@type" : "xsd:decimal" , "@value" : latitude },
47
- "uco-location:longitude" : {"@type" : "xsd:decimal" , "@value" : longitude },
57
+ "uco-location:latitude" : {"@type" : "xsd:decimal" , "@value" : str ( latitude ) },
58
+ "uco-location:longitude" : {"@type" : "xsd:decimal" , "@value" : str ( longitude ) },
48
59
}
49
60
return observable
50
61
51
62
52
- def test_app_name ():
53
- app_names = list ()
54
- app_objects = list ()
63
+ def test_app_name () -> None :
64
+ app_names : list [ str ] = list ()
65
+ app_objects : list [ dict [ str , Any ]] = list ()
55
66
app_1 = "Safari"
56
67
uuid_1 = "kb:" + str (uuid .uuid4 ())
57
68
check_app_name (app_1 , app_names , app_objects , uuid_1 )
@@ -82,9 +93,9 @@ def test_app_name():
82
93
]
83
94
84
95
85
- def test_geo_coordinates ():
86
- geo_coordinates = list ()
87
- geo_objects = list ()
96
+ def test_geo_coordinates () -> None :
97
+ geo_coordinates : list [ str ] = list ()
98
+ geo_objects : list [ dict [ str , Any ]] = list ()
88
99
(lat_1 , long_1 , uuid_1 ) = (56.47267913 , - 71.17069244 , "kb:" + str (uuid .uuid4 ()))
89
100
check_geo_coordinates (lat_1 , long_1 , geo_coordinates , geo_objects , uuid_1 )
90
101
# print(f"\n 1) FT geo_coordinates={geo_coordinates}")
@@ -104,8 +115,8 @@ def test_geo_coordinates():
104
115
assert geo_object == {
105
116
"@type" : "uco-location:LatLongCoordinatesFacet" ,
106
117
"@id" : uuid_1 ,
107
- "uco-location:latitude" : {"@type" : "xsd:decimal" , "@value" : lat_1 },
108
- "uco-location:longitude" : {"@type" : "xsd:decimal" , "@value" : long_1 },
118
+ "uco-location:latitude" : {"@type" : "xsd:decimal" , "@value" : str ( lat_1 ) },
119
+ "uco-location:longitude" : {"@type" : "xsd:decimal" , "@value" : str ( long_1 ) },
109
120
}
110
121
# print(f"\n 3) FT geo_coordinates={geo_coordinates}")
111
122
assert geo_coordinates == [
@@ -122,13 +133,13 @@ def test_geo_coordinates():
122
133
{
123
134
"@type" : "uco-location:LatLongCoordinatesFacet" ,
124
135
"@id" : uuid_1 ,
125
- "uco-location:latitude" : {"@type" : "xsd:decimal" , "@value" : lat_1 },
126
- "uco-location:longitude" : {"@type" : "xsd:decimal" , "@value" : long_1 },
136
+ "uco-location:latitude" : {"@type" : "xsd:decimal" , "@value" : str ( lat_1 ) },
137
+ "uco-location:longitude" : {"@type" : "xsd:decimal" , "@value" : str ( long_1 ) },
127
138
},
128
139
{
129
140
"@type" : "uco-location:LatLongCoordinatesFacet" ,
130
141
"@id" : uuid_2 ,
131
- "uco-location:latitude" : {"@type" : "xsd:decimal" , "@value" : lat_2 },
132
- "uco-location:longitude" : {"@type" : "xsd:decimal" , "@value" : long_2 },
142
+ "uco-location:latitude" : {"@type" : "xsd:decimal" , "@value" : str ( lat_2 ) },
143
+ "uco-location:longitude" : {"@type" : "xsd:decimal" , "@value" : str ( long_2 ) },
133
144
},
134
145
]
0 commit comments