-
Notifications
You must be signed in to change notification settings - Fork 11
/
run_tests.py
executable file
·801 lines (736 loc) · 26.8 KB
/
run_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
#!/usr/bin/env python
import io
import json
import unittest
from contextlib import redirect_stdout
from copy import deepcopy
from unittest.mock import patch
from arcgis2geojson import arcgis2geojson, main
"""
arcgis2geojson is a derivative work of ESRI's arcgis-to-geojson-utils:
https://github.com/Esri/arcgis-to-geojson-utils/
Original code is Copyright 2015 by Esri and was licensed under
the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
Ported to Python in 2016 by Chris Shaw.
arcgis2geojson is made available under the MIT License.
"""
class ArcGisToGeoJsonTests(unittest.TestCase):
def test_convert_arcgis_point_to_geojson_point(self):
input = {"x": -66.796875, "y": 20.0390625, "spatialReference": {"wkid": 4326}}
output = arcgis2geojson(input)
self.assertEqual(output["coordinates"], [-66.796875, 20.0390625])
self.assertEqual(output["type"], "Point")
def test_convert_string_json_to_string_json(self):
input = json.dumps(
{"x": -66.796875, "y": 20.0390625, "spatialReference": {"wkid": 4326}}
)
output = arcgis2geojson(input)
self.assertIsInstance(output, str)
output = json.loads(output)
self.assertEqual(output["coordinates"], [-66.796875, 20.0390625])
self.assertEqual(output["type"], "Point")
def test_convert_arcgis_point_with_z_value_to_geojson_point(self):
input = {
"x": -66.796875,
"y": 20.0390625,
"z": 1,
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(output["coordinates"], [-66.796875, 20.0390625, 1])
self.assertEqual(output["type"], "Point")
def test_convert_arcgis_null_island_to_geojson_point(self):
input = {"x": 0, "y": 0, "spatialReference": {"wkid": 4326}}
output = arcgis2geojson(input)
self.assertEqual(output["coordinates"], [0, 0])
self.assertEqual(output["type"], "Point")
def test_invalid_geometry(self):
input = {"geometry": {"x": "NaN", "y": "NaN"}, "attributes": {"foo": "bar"}}
output = arcgis2geojson(input)
self.assertIsNone(output["geometry"])
def test_convert_arcgis_polyline_to_geojson_linestring(self):
input = {
"paths": [
[
[6.6796875, 47.8125],
[-65.390625, 52.3828125],
[-52.3828125, 42.5390625],
]
],
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(
output["coordinates"],
[[6.6796875, 47.8125], [-65.390625, 52.3828125], [-52.3828125, 42.5390625]],
)
self.assertEqual(output["type"], "LineString")
def test_convert_arcgis_polyline_with_z_values_to_geojson_linestring(self):
input = {
"paths": [
[
[6.6796875, 47.8125, 1],
[-65.390625, 52.3828125, 1],
[-52.3828125, 42.5390625, 1],
]
],
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(
output["coordinates"],
[
[6.6796875, 47.8125, 1],
[-65.390625, 52.3828125, 1],
[-52.3828125, 42.5390625, 1],
],
)
self.assertEqual(output["type"], "LineString")
def test_convert_arcgis_polygon_to_geojson_polygon(self):
input = {
"rings": [
[
[41.8359375, 71.015625],
[56.953125, 33.75],
[21.796875, 36.5625],
[41.8359375, 71.015625],
]
],
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(
output["coordinates"],
[
[
[41.8359375, 71.015625],
[21.796875, 36.5625],
[56.953125, 33.75],
[41.8359375, 71.015625],
]
],
)
self.assertEqual(output["type"], "Polygon")
def test_convert_arcgis_polygon_with_z_values_to_geojson_polygon(self):
input = {
"rings": [
[
[41.8359375, 71.015625, 1],
[56.953125, 33.75, 1],
[21.796875, 36.5625, 1],
[41.8359375, 71.015625, 1],
]
],
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(
output["coordinates"],
[
[
[41.8359375, 71.015625, 1],
[21.796875, 36.5625, 1],
[56.953125, 33.75, 1],
[41.8359375, 71.015625, 1],
]
],
)
self.assertEqual(output["type"], "Polygon")
def test_close_rings_in_convert_arcgis_polygon_to_geojson_polygon(self):
input = {
"rings": [
[[41.8359375, 71.015625], [56.953125, 33.75], [21.796875, 36.5625]]
],
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(
output["coordinates"],
[
[
[41.8359375, 71.015625],
[21.796875, 36.5625],
[56.953125, 33.75],
[41.8359375, 71.015625],
]
],
)
self.assertEqual(output["type"], "Polygon")
def test_parse_arcgis_multipoint_to_geojson_multipoint(self):
input = {
"points": [
[[41.8359375, 71.015625], [56.953125, 33.75], [21.796875, 36.5625]]
],
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(
output["coordinates"],
[
[
[41.8359375, 71.015625],
[56.953125, 33.75],
[21.796875, 36.5625],
]
],
)
self.assertEqual(output["type"], "MultiPoint")
def test_parse_arcgis_polyline_to_geojson_multilinestring(self):
input = {
"paths": [
[[41.8359375, 71.015625], [56.953125, 33.75]],
[[21.796875, 36.5625], [41.8359375, 71.015625]],
],
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(
output["coordinates"],
[
[[41.8359375, 71.015625], [56.953125, 33.75]],
[[21.796875, 36.5625], [41.8359375, 71.015625]],
],
)
self.assertEqual(output["type"], "MultiLineString")
def test_parse_arcgis_polygon_to_geojson_multipolygon(self):
input = {
"rings": [
[
[-122.63, 45.52],
[-122.57, 45.53],
[-122.52, 45.50],
[-122.49, 45.48],
[-122.64, 45.49],
[-122.63, 45.52],
[-122.63, 45.52],
],
[[-83, 35], [-74, 35], [-74, 41], [-83, 41], [-83, 35]],
],
"spatialReference": {"wkid": 4326},
}
expected = [
[
[
[-122.63, 45.52],
[-122.63, 45.52],
[-122.64, 45.49],
[-122.49, 45.48],
[-122.52, 45.5],
[-122.57, 45.53],
[-122.63, 45.52],
]
],
[[[-83, 35], [-74, 35], [-74, 41], [-83, 41], [-83, 35]]],
]
output = arcgis2geojson(input)
self.assertEqual(output["coordinates"], expected)
self.assertEqual(output["type"], "MultiPolygon")
def test_strip_invalid_rings_in_convert_arcgis_polygon_to_geojson_polygon(self):
input = {
"rings": [
[
[-122.63, 45.52],
[-122.57, 45.53],
[-122.52, 45.50],
[-122.49, 45.48],
[-122.64, 45.49],
[-122.63, 45.52],
[-122.63, 45.52],
],
[[-83, 35], [-74, 35], [-83, 35]],
],
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(
output["coordinates"],
[
[
[-122.63, 45.52],
[-122.63, 45.52],
[-122.64, 45.49],
[-122.49, 45.48],
[-122.52, 45.5],
[-122.57, 45.53],
[-122.63, 45.52],
]
],
)
self.assertEqual(output["type"], "Polygon")
def test_close_rings_in_convert_arcgis_polygon_to_geojson_multipolygon(self):
input = {
"rings": [
[
[-122.63, 45.52],
[-122.57, 45.53],
[-122.52, 45.50],
[-122.49, 45.48],
[-122.64, 45.49],
],
[[-83, 35], [-74, 35], [-74, 41], [-83, 41]],
],
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(
output["coordinates"],
[
[
[
[-122.63, 45.52],
[-122.64, 45.49],
[-122.49, 45.48],
[-122.52, 45.5],
[-122.57, 45.53],
[-122.63, 45.52],
]
],
[[[-83, 35], [-74, 35], [-74, 41], [-83, 41], [-83, 35]]],
],
)
self.assertEqual(output["type"], "MultiPolygon")
def test_parse_arcgis_multipolygon_with_holes_to_geojson_multipolygon(self):
input = {
"type": "Polygon",
"rings": [
[
[-100.74462180954974, 39.95017165502381],
[-94.50439384003792, 39.91647453608879],
[-94.41650267263967, 34.89313438177965],
[-100.78856739324887, 34.85708140996771],
[-100.74462180954974, 39.95017165502381],
],
[
[-99.68993678392353, 39.341088433448896],
[-99.68993678392353, 38.24507658785885],
[-98.67919734199646, 37.86444431771113],
[-98.06395917020868, 38.210554846669694],
[-98.06395917020868, 39.341088433448896],
[-99.68993678392353, 39.341088433448896],
],
[
[-96.83349180978595, 37.23732027507514],
[-97.31689323047635, 35.967330282988534],
[-96.5698183075912, 35.57512048069255],
[-95.42724211456674, 36.357601429255965],
[-96.83349180978595, 37.23732027507514],
],
[
[-101.4916967324349, 38.24507658785885],
[-101.44775114873578, 36.073960493943744],
[-103.95263145328033, 36.03843312329154],
[-103.68895795108557, 38.03770050767439],
[-101.4916967324349, 38.24507658785885],
],
],
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(
output["coordinates"],
[
[
[
[-100.74462180954974, 39.95017165502381],
[-100.78856739324887, 34.85708140996771],
[-94.41650267263967, 34.89313438177965],
[-94.50439384003792, 39.91647453608879],
[-100.74462180954974, 39.95017165502381],
],
[
[-96.83349180978595, 37.23732027507514],
[-95.42724211456674, 36.357601429255965],
[-96.5698183075912, 35.57512048069255],
[-97.31689323047635, 35.967330282988534],
[-96.83349180978595, 37.23732027507514],
],
[
[-99.68993678392353, 39.341088433448896],
[-98.06395917020868, 39.341088433448896],
[-98.06395917020868, 38.210554846669694],
[-98.67919734199646, 37.86444431771113],
[-99.68993678392353, 38.24507658785885],
[-99.68993678392353, 39.341088433448896],
],
],
[
[
[-101.4916967324349, 38.24507658785885],
[-103.68895795108557, 38.03770050767439],
[-103.95263145328033, 36.03843312329154],
[-101.44775114873578, 36.073960493943744],
[-101.4916967324349, 38.24507658785885],
]
],
],
)
self.assertEqual(output["type"], "MultiPolygon")
def test_parse_holes_outside_outer_rings_in_arcgis_polygon_with_holes_to_geojson_polygon(
self,
):
input = {
"rings": [
[
[-122.45, 45.63],
[-122.45, 45.68],
[-122.39, 45.68],
[-122.39, 45.63],
[-122.45, 45.63],
],
[
[-122.46, 45.64],
[-122.4, 45.64],
[-122.4, 45.66],
[-122.46, 45.66],
[-122.46, 45.64],
],
],
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(
output["coordinates"],
[
[
[-122.45, 45.63],
[-122.39, 45.63],
[-122.39, 45.68],
[-122.45, 45.68],
[-122.45, 45.63],
],
[
[-122.46, 45.64],
[-122.46, 45.66],
[-122.4, 45.66],
[-122.4, 45.64],
[-122.46, 45.64],
],
],
)
self.assertEqual(output["type"], "Polygon")
def test_parse_arcgis_feature_to_geojson_feature(self):
input = {
"geometry": {
"rings": [
[
[41.8359375, 71.015625],
[56.953125, 33.75],
[21.796875, 36.5625],
[41.8359375, 71.015625],
]
],
"spatialReference": {"wkid": 4326},
},
"attributes": {"foo": "bar"},
}
output = arcgis2geojson(input)
self.assertEqual(
output["geometry"]["coordinates"],
[
[
[41.8359375, 71.015625],
[21.796875, 36.5625],
[56.953125, 33.75],
[41.8359375, 71.015625],
]
],
)
self.assertEqual(output["geometry"]["type"], "Polygon")
def test_convert_arcgis_feature_array_to_geojson_featurecollection(self):
input = {
"displayFieldName": "prop0",
"fieldAliases": {"prop0": "prop0"},
"geometryType": "esriGeometryPolygon",
"fields": [
{
"length": 20,
"name": "prop0",
"type": "esriFieldTypeString",
"alias": "prop0",
},
{"name": "OBJECTID", "type": "esriFieldTypeOID", "alias": "OBJECTID"},
{"name": "FID", "type": "esriFieldTypeDouble", "alias": "FID"},
],
"spatialReference": {"wkid": 4326},
"features": [
{
"geometry": {"x": 102, "y": 0.5},
"attributes": {"prop0": "value0", "FID": 0, "OBJECTID": 0},
},
{
"geometry": {"paths": [[[102, 0], [103, 1], [104, 0], [105, 1]]]},
"attributes": {"prop0": None, "FID": 1, "OBJECTID": None},
},
{
"geometry": {
"rings": [[[100, 0], [100, 1], [101, 1], [101, 0], [100, 0]]]
},
"attributes": {"prop0": None, "FID": 30.25, "OBJECTID": 2},
},
],
}
output = arcgis2geojson(input, "prop0")
self.assertEqual(
output,
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {"prop0": "value0", "OBJECTID": 0, "FID": 0},
"id": "value0",
"geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
},
{
"type": "Feature",
"properties": {"prop0": None, "OBJECTID": None, "FID": 1},
"id": 1,
"geometry": {
"type": "LineString",
"coordinates": [
[102.0, 0.0],
[103.0, 1.0],
[104.0, 0.0],
[105.0, 1.0],
],
},
},
{
"type": "Feature",
"properties": {"prop0": None, "OBJECTID": 2, "FID": 30.25},
"id": 2,
"geometry": {
"type": "Polygon",
"coordinates": [
[
[100.0, 0.0],
[101.0, 0.0],
[101.0, 1.0],
[100.0, 1.0],
[100.0, 0.0],
]
],
},
},
],
},
)
def test_parse_arcgis_feature_with_objectid(self):
input = {
"geometry": {
"rings": [
[
[41.8359375, 71.015625],
[56.953125, 33.75],
[21.796875, 36.5625],
[41.8359375, 71.015625],
]
],
"spatialReference": {"wkid": 4326},
},
"attributes": {"OBJECTID": 123},
}
output = arcgis2geojson(input)
self.assertEqual(output["id"], 123)
def test_parse_arcgis_feature_with_fid(self):
input = {
"geometry": {
"rings": [
[
[41.8359375, 71.015625],
[56.953125, 33.75],
[21.796875, 36.5625],
[41.8359375, 71.015625],
]
],
"spatialReference": {"wkid": 4326},
},
"attributes": {"FID": 123},
}
output = arcgis2geojson(input)
self.assertEqual(output["id"], 123)
def test_parse_arcgis_feature_with_custom_id(self):
input = {
"geometry": {
"rings": [
[
[41.8359375, 71.015625],
[56.953125, 33.75],
[21.796875, 36.5625],
[41.8359375, 71.015625],
]
],
"spatialReference": {"wkid": 4326},
},
"attributes": {"FooID": 123},
}
output = arcgis2geojson(input, "FooID")
self.assertEqual(output["id"], 123)
def test_parse_arcgis_feature_with_empty_attributes(self):
input = {
"geometry": {
"rings": [
[
[41.8359375, 71.015625],
[56.953125, 33.75],
[21.796875, 36.5625],
[41.8359375, 71.015625],
]
],
"spatialReference": {"wkid": 4326},
},
"attributes": {},
}
output = arcgis2geojson(input)
self.assertEqual(
output["geometry"]["coordinates"],
[
[
[41.8359375, 71.015625],
[21.796875, 36.5625],
[56.953125, 33.75],
[41.8359375, 71.015625],
]
],
)
self.assertEqual(output["geometry"]["type"], "Polygon")
self.assertEqual(output["properties"], {})
def test_parse_arcgis_feature_with_no_attributes(self):
input = {
"geometry": {
"rings": [
[
[41.8359375, 71.015625],
[56.953125, 33.75],
[21.796875, 36.5625],
[41.8359375, 71.015625],
]
],
"spatialReference": {"wkid": 4326},
}
}
output = arcgis2geojson(input)
self.assertEqual(
output["geometry"]["coordinates"],
[
[
[41.8359375, 71.015625],
[21.796875, 36.5625],
[56.953125, 33.75],
[41.8359375, 71.015625],
]
],
)
self.assertEqual(output["geometry"]["type"], "Polygon")
self.assertEqual(output["properties"], None)
def test_parse_arcgis_feature_with_no_geometry(self):
input = {"attributes": {"foo": "bar"}}
output = arcgis2geojson(input)
self.assertEqual(output["geometry"], None)
self.assertEqual(output["properties"]["foo"], "bar")
def test_custom_id_field(self):
input = {
"x": -66.796875,
"y": 20.0390625,
"spatialReference": {"wkid": 4326},
"attributes": {
"OBJECTID": 123,
"some_field": 456,
},
}
output = arcgis2geojson(input, "some_field")
self.assertEqual(456, output["id"])
def test_id_must_be_string_or_number(self):
input = {
"x": -66.796875,
"y": 20.0390625,
"spatialReference": {"wkid": 4326},
"attributes": {
"OBJECTID": 123,
"some_field": {"not a number": "or a string"},
},
}
output = arcgis2geojson(input, "some_field")
# 'some_field' isn't a number or string - fall back to OBJECTID
self.assertEqual(123, output["id"])
def test_null_id_not_allowed(self):
input = {
"x": -66.796875,
"y": 20.0390625,
"spatialReference": {"wkid": 4326},
# no 'OBJECTID' or 'FID' in 'attributes'
"attributes": {"foo": "bar"},
}
output = arcgis2geojson(input)
self.assertTrue("id" not in output)
@patch("arcgis2geojson.logger")
def test_warning_if_crs_not_4326(self, mock_logger):
input = {"x": 392917.31, "y": 298521.34, "spatialReference": {"wkid": 27700}}
output = arcgis2geojson(input)
mock_logger.warning.assert_called_with(
"Object converted in non-standard crs - {'wkid': 27700}"
)
self.assertTrue("crs" not in output)
self.assertEqual(output["coordinates"], [392917.31, 298521.34])
@patch("arcgis2geojson.logger")
def test_warning_if_true_curve_element(self, mock_logger):
input = {"curvePaths": [[[0, 0], {"c": [[3, 3], [1, 4]]}]]}
output = arcgis2geojson(input)
mock_logger.warning.assert_called_with(
"Element of type 'curvePaths' (Curved Polyline) can not be convered to GeoJSON. Converting to null geometry"
)
self.assertEqual(output["geometry"], None)
def test_do_not_modify_original_arcgis_geometry(self):
input = {
"geometry": {
"rings": [
[
[41.8359375, 71.015625],
[56.953125, 33.75],
[21.796875, 36.5625],
[41.8359375, 71.015625],
]
],
"spatialReference": {"wkid": 4326},
},
"attributes": {"foo": "bar"},
}
expected = deepcopy(input)
arcgis2geojson(input)
self.assertEqual(input, expected)
def test_convert_arcgis_extent_to_geojson_polygon(self):
input = {
"xmax": -35.5078125,
"ymax": 41.244772343082076,
"xmin": -13.7109375,
"ymin": 54.36775852406841,
"spatialReference": {"wkid": 4326},
}
output = arcgis2geojson(input)
self.assertEqual(
output["coordinates"],
[
[
[-35.5078125, 41.244772343082076],
[-13.7109375, 41.244772343082076],
[-13.7109375, 54.36775852406841],
[-35.5078125, 54.36775852406841],
[-35.5078125, 41.244772343082076],
]
],
)
def test_cli(self):
input = (
'{ "x": -66.796875, "y": 20.0390625, "spatialReference": { "wkid": 4326 } }'
)
with patch("sys.stdin", io.StringIO(input)):
with io.StringIO() as buf, redirect_stdout(buf):
self.assertEqual(0, main())
self.assertEqual(buf.getvalue().strip(), arcgis2geojson(input))
def test_cli_stdin_is_tty(self):
with patch("sys.stdin.isatty", return_value=True):
with io.StringIO() as buf, redirect_stdout(buf):
self.assertEqual(0, main())
self.assertIn("Convert ArcGIS JSON to GeoJSON", buf.getvalue().strip())
if __name__ == "__main__":
unittest.main()