Ladsgroup has uploaded a new change for review.
https://gerrit.wikimedia.org/r/239515
Change subject: Add test_coordinate.py
......................................................................
Add test_coordinate.py
Change-Id: Ie75feb5b439af4e0e5370829783481ef2ad9ac7d
---
A tests/test_coordinate.py
1 file changed, 43 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/wikibase
refs/changes/15/239515/1
diff --git a/tests/test_coordinate.py b/tests/test_coordinate.py
new file mode 100644
index 0000000..70aef8a
--- /dev/null
+++ b/tests/test_coordinate.py
@@ -0,0 +1,43 @@
+import unittest
+
+from pywikibase import Coordinate
+
+
+class TestCoordinate(unittest.TestCase):
+
+ """Test Coordinate."""
+
+ def setUp(self):
+ self.params = {u'latitude': 38.897669444444,
+ u'altitude': None,
+ u'globe': u'http://www.wikidata.org/entity/Q2',
+ u'longitude': -77.03655,
+ u'precision': 2.7777777777778e-06}
+
+ self.coordinate = Coordinate(
+ 38.897669444444, -77.03655, precision=2.7777777777778e-06,
+ entity='http://www.wikidata.org/entity/Q2')
+
+ def test_init(self):
+ """Test __init__."""
+ self.assertEqual(self.coordinate.lat, 38.897669444444)
+ self.assertEqual(self.coordinate.lon, -77.03655)
+
+ def test_wikibase(self):
+ """Test Wikibase-related methods."""
+ self.assertEqual(self.params, self.coordinate.toWikibase())
+ self.assertEqual(self.coordinate, Coordinate.fromWikibase(self.params))
+
+ def test_precision(self):
+ """Test precision attribute."""
+ self.assertEqual(self.coordinate.precision, 2.7777777777778e-06)
+ coord = Coordinate(38.897669444444, -77.03655, dim=100)
+ self.assertEqual(coord.precision, 0.0011542482624706185)
+
+ def test_entity(self):
+ """Test entity property."""
+ self.assertEqual(
+ self.coordinate.entity, 'http://www.wikidata.org/entity/Q2')
+
+if __name__ == '__main__':
+ unittest.main()
--
To view, visit https://gerrit.wikimedia.org/r/239515
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie75feb5b439af4e0e5370829783481ef2ad9ac7d
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/wikibase
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits