After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 791307 - Add tests for timezone validity
Add tests for timezone validity
Status: RESOLVED FIXED
Product: libgweather
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: future
Assigned To: libgweather-maint
libgweather-maint
Depends on:
Blocks:
 
 
Reported: 2017-12-06 13:54 UTC by Bastien Nocera
Modified: 2017-12-07 00:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GWeatherLocation: Add API to get timezone as string (2.28 KB, patch)
2017-12-06 13:55 UTC, Bastien Nocera
committed Details | Review
GWeatherTimezone: Add guard to gweather_timezone_get_by_tzid() (928 bytes, patch)
2017-12-06 13:55 UTC, Bastien Nocera
committed Details | Review
tests: Add comment to named-timezones test (892 bytes, patch)
2017-12-06 13:55 UTC, Bastien Nocera
committed Details | Review
tests: Add tests for timezone validity (3.21 KB, patch)
2017-12-06 13:55 UTC, Bastien Nocera
committed Details | Review
locations: Correct AoE timezone (1.05 KB, patch)
2017-12-06 13:55 UTC, Bastien Nocera
committed Details | Review
locations: Add tz-hint for Wake Island airfield (911 bytes, patch)
2017-12-06 13:55 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2017-12-06 13:54:50 UTC
And correct the bugs it shows
Comment 1 Bastien Nocera 2017-12-06 13:55:07 UTC
Created attachment 365109 [details] [review]
GWeatherLocation: Add API to get timezone as string

Make it possible to get the timezone of a location as a string. This
will be used to verify the timezone's validity, as _get_timezone() would
return NULL, whether the location had no timezone, or if it had an
invalid timezone.
Comment 2 Bastien Nocera 2017-12-06 13:55:12 UTC
Created attachment 365110 [details] [review]
GWeatherTimezone: Add guard to gweather_timezone_get_by_tzid()

This led to a crash in my badly written test code, a g_warning() is
more useful to show incorrect API usage.
Comment 3 Bastien Nocera 2017-12-06 13:55:18 UTC
Created attachment 365111 [details] [review]
tests: Add comment to named-timezones test

Not that interesting, but useful nonetheless.
Comment 4 Bastien Nocera 2017-12-06 13:55:27 UTC
Created attachment 365112 [details] [review]
tests: Add tests for timezone validity

For every location at the country level, or smaller, check whether we
have at least one timezone defined. If only one timezone is defined for
the location, verify its validity.

This generated 3 errors:
(MSG: Location 'Anywhere on Earth (AoE)' has invalid timezone 'Etc/UTC-12')
(MSG: Location 'Wake Island, Wake Island Army Airfield Airport' does not have an associated timezone)
(MSG: Location 'Wake Island, Wake Island Army Airfield Airport' does not have an associated timezone)
Comment 5 Bastien Nocera 2017-12-06 13:55:32 UTC
Created attachment 365113 [details] [review]
locations: Correct AoE timezone

Etc/UTC-12 does not exist in tzdata, it's called Etc/GMT-12.
This fixes an error in gnome-clocks:
org.gnome.Clocks-WARNING **: world.vala:271: Timezone not defined for (null). This is a bug in libgweather database
Comment 6 Bastien Nocera 2017-12-06 13:55:38 UTC
Created attachment 365114 [details] [review]
locations: Add tz-hint for Wake Island airfield

Fixes test errors:
(MSG: Location 'Wake Island, Wake Island Army Airfield Airport' does not have an associated timezone)
(MSG: Location 'Wake Island, Wake Island Army Airfield Airport' does not have an associated timezone)
Comment 7 Bastien Nocera 2017-12-06 14:23:58 UTC
I committed those fixes already. Let me know what you think of the test case and the API addition it requires.

Attachment 365110 [details] pushed as 10f1bf6 - GWeatherTimezone: Add guard to gweather_timezone_get_by_tzid()
Attachment 365111 [details] pushed as 6969e49 - tests: Add comment to named-timezones test
Attachment 365113 [details] pushed as 9980fcf - locations: Correct AoE timezone
Attachment 365114 [details] pushed as 5847472 - locations: Add tz-hint for Wake Island airfield
Comment 8 Bastien Nocera 2017-12-07 00:29:41 UTC
Attachment 365109 [details] pushed as f84ea76 - GWeatherLocation: Add API to get timezone as string
Attachment 365112 [details] pushed as 2dab8a8 - tests: Add tests for timezone validity