diff --git a/apps/parcel/management/commands/match_parcels.py b/apps/parcel/management/commands/match_parcels.py index 5f0e4e0..2268f0d 100644 --- a/apps/parcel/management/commands/match_parcels.py +++ b/apps/parcel/management/commands/match_parcels.py @@ -24,6 +24,8 @@ def add_arguments(self, parser): help='Name of Zooniverse workflow to process, e.g. "Ramsey County"') parser.add_argument('-l', '--local', action='store_true', help='Save to local CSV in "analysis" dir, rather than Django object/S3') + parser.add_argument('-t', '--test', action='store_true', + help="Don't save match report, this is only a test") def match_parcel(self, parcel_lookup, target_obj, subject_obj): ''' Separate subject necessary because you also have to run this on the ExtraParcelCandidate objects and then link the result to its subject''' @@ -88,7 +90,7 @@ def tag_matched_parcels(self, workflow): # Now do ManualCovenant records Parcel.objects.filter(workflow=workflow, manualcovenant__isnull=False).update(bool_covenant=True) - def write_match_report(self, workflow, bool_local=False): + def write_match_report(self, workflow, bool_local=False, bool_test=False): fieldnames = ['join_string', 'match', 'subject_id', 'metadata', 'parcel_metadata', 'num_parcels'] @@ -112,7 +114,9 @@ def write_match_report(self, workflow, bool_local=False): filename_tail = f'{workflow.slug}_match_report_{timestamp}.csv' - if bool_local: + if bool_test: + pass + elif bool_local: outfile_path = os.path.join( settings.BASE_DIR, 'data', 'analysis', filename_tail) @@ -173,4 +177,5 @@ def handle(self, *args, **kwargs): self.tag_matched_parcels(workflow) bool_local = kwargs['local'] - self.write_match_report(workflow, bool_local) + bool_test = kwargs['test'] + self.write_match_report(workflow, bool_local, bool_test) diff --git a/apps/plat/tests.py b/apps/plat/tests.py index 6daea63..253681a 100644 --- a/apps/plat/tests.py +++ b/apps/plat/tests.py @@ -40,7 +40,7 @@ def test_subdivision_parcel_match(self): with self.settings(ZOONIVERSE_QUESTION_LOOKUP=TEST_ZOON_SETTINGS): call_command("rebuild_parcel_spatial_lookups", workflow='Ramsey County') call_command("rebuild_covenant_spatial_lookups", workflow='Ramsey County') - call_command("match_parcels", workflow='Ramsey County') + call_command("match_parcels", '--test', workflow='Ramsey County') parcels_to_match = Parcel.objects.filter(workflow=1, plat_name='LYNDALE BEACH 2ND ADDN') parcels_count = parcels_to_match.count()