def test_aggregate(self):
     output = get_temp_jsonfile_path()
     mongo_to_geojson(MONGO_URI, COLLECTION, output, pipeline=PIPELINE)
     output_created = os.path.exists(output)
     if output_created:
         os.remove(output)
     self.assertTrue(output_created)
 def test_collection_dump(self):
     output = get_temp_jsonfile_path()
     mongo_to_geojson(MONGO_URI, 'cities', output)
     output_created = os.path.exists(output)
     if output_created:
         os.remove(output)
     self.assertTrue(output_created)
 def test_find_without_projection(self):
     output = get_temp_jsonfile_path()
     mongo_to_geojson(MONGO_URI, COLLECTION, output, query=QUERY)
     output_created = os.path.exists(output)
     if output_created:
         os.remove(output)
     self.assertTrue(output_created)
Ejemplo n.º 4
0
 def test_collection_dump(self):
     output = get_temp_jsonfile_path()
     cmd = " ".join(['mongo2geojson', MONGO_URI, COLLECTION, output])
     return_code = subprocess.check_call(cmd, shell=True)
     output_created = os.path.exists(output)
     if os.path.exists(output):
         os.remove(output)
     self.assertTrue(return_code == 0)
     self.assertTrue(output_created)
    def test_find_with_projection(self):
        output = get_temp_jsonfile_path()
        mongo_to_geojson(MONGO_URI, COLLECTION, output, QUERY, PROJECTION)
        output_created = os.path.exists(output)
        if output_created:
            with open(output, 'r') as o:
                feature_collection = json.load(o)
                first_feature = feature_collection['features'][0]
                property_count = len(list(first_feature['properties'].keys()))
            os.remove(output)

        self.assertEqual(property_count, 3)
Ejemplo n.º 6
0
 def test_find_from_jsonstring_without_projection(self):
     output = get_temp_jsonfile_path()
     cmd = " ".join([
         'mongo2geojson', MONGO_URI, COLLECTION, output,
         "--query='{0}'".format(json.dumps(QUERY))
     ])
     return_code = subprocess.check_call(cmd, shell=True)
     output_created = os.path.exists(output)
     if os.path.exists(output):
         os.remove(output)
     self.assertTrue(return_code == 0)
     self.assertTrue(output_created)
Ejemplo n.º 7
0
 def test_aggregate_from_jsonstring_no_opts(self):
     output = get_temp_jsonfile_path()
     cmd = " ".join([
         'mongo2geojson', MONGO_URI, COLLECTION, output,
         "--agg_pipeline='{0}'".format(json.dumps(PIPELINE))
     ])
     return_code = subprocess.check_call(cmd, shell=True)
     output_created = os.path.exists(output)
     if os.path.exists(output):
         os.remove(output)
     self.assertTrue(return_code == 0)
     self.assertTrue(output_created)
Ejemplo n.º 8
0
 def test_aggregate_from_jsonfile_no_opts(self):
     pipeline = create_parameter_file_input(PIPELINE)
     output = get_temp_jsonfile_path()
     cmd = " ".join([
         'mongo2geojson', MONGO_URI, COLLECTION, output,
         '--agg_pipeline={0}'.format(pipeline)
     ])
     return_code = subprocess.check_call(cmd, shell=True)
     output_created = os.path.exists(output)
     if os.path.exists(output):
         os.remove(output)
     self.assertTrue(return_code == 0)
     self.assertTrue(output_created)
Ejemplo n.º 9
0
 def test_find_from_jsonfile_with_projection(self):
     query = create_parameter_file_input(QUERY)
     projection = create_parameter_file_input(PROJECTION)
     output = get_temp_jsonfile_path()
     cmd = " ".join([
         'mongo2geojson', MONGO_URI, COLLECTION, output,
         '--query={0}'.format(query), '--projection={0}'.format(projection)
     ])
     return_code = subprocess.check_call(cmd, shell=True)
     output_created = os.path.exists(output)
     if os.path.exists(output):
         os.remove(output)
     self.assertTrue(return_code == 0)
     self.assertTrue(output_created)