Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SI-2262 Translate isRedacted to DIMO.IsLocationRedacted #22

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkg/schema/spec/definitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,12 @@
originalType: string
isArray: false
requiredPrivileges:
- VEHICLE_NON_LOCATION_DATA
- VEHICLE_NON_LOCATION_DATA
- vspecName: Vehicle.DIMO.IsLocationRedacted
goType: ""
conversions:
- originalName: isRedacted
originalType: bool
isArray: false
requiredPrivileges:
- VEHICLE_ALL_TIME_LOCATION
9 changes: 5 additions & 4 deletions pkg/schema/spec/vss_rel_4.2-DIMO.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1276,9 +1276,10 @@
"Vehicle.DIMO.Aftermarket.NSAT","sensor","float","","","","","Number of sync satellites for GPS","","","","2efda4b9dc125f659bb2f4a53b997067"
"Vehicle.DIMO.Aftermarket.WPAState","sensor","string","","","","","Indicate the current wpa state for the devices wifi","","","","99d4eeabc6f353b5b868066c716e8d03"
"Vehicle.DIMO.Aftermarket.SSID","sensor","string","","","","","Service Set Ientifier for the wifi.","","","","e781cfcf911b5ea49ec4f95495f8a593"
"Vehicle.DIMO.Subject","sensor","string","","","","","subjet of this vehicle data","","","","fadb61b0f4e855a795252e9abfb4c28e"
"Vehicle.DIMO.Timestamp","sensor","string","","iso8601","","","timestamp of when this data was colllected","","","","bef0836ce4815bae98ae7c23928d630c"
"Vehicle.DIMO.Subject","sensor","string","","","","","subject of this vehicle data","","","","fadb61b0f4e855a795252e9abfb4c28e"
"Vehicle.DIMO.Timestamp","sensor","string","","iso8601","","","timestamp of when this data was collected","","","","bef0836ce4815bae98ae7c23928d630c"
"Vehicle.DIMO.Source","sensor","string","","","","","where the data was sourced from","","","","f7b9d7f7f2d85c09a4f1c6cd3b640a57"
"Vehicle.DIMO.Type","sensor","string","","","","","type of data collected","","","","e8e4c8506052543eabe136cb1198a030"
"Vehicle.DIMO.DefinitionID","sensor","string","","","","","ID for the vehicles definition","","","","3031d4c0bd3f578286f6f0e077377c18"
"Vehicle.DIMO.VehicleID","sensor","string","","","","","unque DIMO ID for the vehicle","","","","241c912ada4054628813c9a7b9b73914"
"Vehicle.DIMO.DefinitionID","sensor","string","","","","","ID for the vehicle's definition","","","","3031d4c0bd3f578286f6f0e077377c18"
"Vehicle.DIMO.VehicleID","sensor","string","","","","","unique DIMO ID for the vehicle","","","","241c912ada4054628813c9a7b9b73914"
"Vehicle.DIMO.IsLocationRedacted","sensor","boolean","","","","","Indicates if the latitude and longitude signals at the current timestamp have been redacted using a privacy zone.","","","","cc9c8b51f05153a39436030bd1f3c134"
4 changes: 3 additions & 1 deletion pkg/vss/convert/payloadv1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ var (
"make": "Toyota",
"model": "Camry",
"year": 2020,
"vin": "1234567890"
"vin": "1234567890",
"isRedacted": true
},
}`
ts = time.Date(2022, 1, 1, 12, 34, 56, 0, time.UTC)
Expand All @@ -90,6 +91,7 @@ var (
{TokenID: 123, Timestamp: ts, Name: "currentLocationLatitude", ValueNumber: 37.7749, Source: "dimo/integration/123"},
{TokenID: 123, Timestamp: ts, Name: "currentLocationLongitude", ValueNumber: -122.4194, Source: "dimo/integration/123"},
{TokenID: 123, Timestamp: ts, Name: "currentLocationTimestamp", ValueNumber: float64(ts.UTC().Unix()), Source: "dimo/integration/123"},
{TokenID: 123, Timestamp: ts, Name: "dimoIsLocationRedacted", ValueNumber: 1, Source: "dimo/integration/123"},
{TokenID: 123, Timestamp: ts, Name: "powertrainCombustionEngineECT", ValueNumber: 90, Source: "dimo/integration/123"},
{TokenID: 123, Timestamp: ts, Name: "powertrainCombustionEngineEngineOilLevel", ValueString: "CRITICALLY_LOW", Source: "dimo/integration/123"},
{TokenID: 123, Timestamp: ts, Name: "powertrainCombustionEngineSpeed", ValueNumber: 3000, Source: "dimo/integration/123"},
Expand Down
8 changes: 8 additions & 0 deletions pkg/vss/vehicle-convert-funcs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions pkg/vss/vehicle-convert-funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,44 @@ func TestToPowertrainTractionBatteryCurrentPower1(t *testing.T) {
})
}
}

func TestToDIMOIsLocationRedacted0(t *testing.T) {
t.Parallel()
tests := []struct {
name string
input bool
expected float64
expectedError bool
}{
{
name: "True to 1",
input: true,
expected: 1,
expectedError: false,
},
{
name: "False to 0",
input: false,
expected: 0,
expectedError: false,
},
}

for i := range tests {
test := tests[i]
name := test.name
if name == "" {
name = fmt.Sprintf("Input: %v", test.input)
}
t.Run(name, func(t *testing.T) {
t.Parallel()
result, err := vss.ToDIMOIsLocationRedacted0(test.input)
if test.expectedError {
require.Error(t, err, "Expected an error but got none")
} else {
require.NoError(t, err, "Unexpected error")
require.Equal(t, test.expected, result, "Unexpected result")
}
})
}
}
2 changes: 2 additions & 0 deletions pkg/vss/vehicle-structs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions pkg/vss/vehicle-v1-convert.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions pkg/vss/vehicle-v2-convert.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading