def run_command(self, args): source_id = args.sourceid data_version = parse_string_to_date_time(args.date) sample = args.sample id = self.database.get_collection_id(source_id, data_version, sample) if id: print("Already exists! The ID is {}".format(id)) return id = self.database.get_or_create_collection_id(source_id, data_version, sample) print("Created! The ID is {}".format(id))
def _load_collection_variables(self, request): # get source, test self.collection_source = request.form.get('collection_source') if not self.collection_source: return False # get data_version, test self.collection_data_version = parse_string_to_date_time( request.form.get('collection_data_version')) if not self.collection_data_version: return False # get sample (No test because if it's not there it is read as False and that's fine) self.collection_sample = parse_string_to_boolean( request.form.get('collection_sample', False)) # all passed so ... return True
def test_parse_string_to_date_time_2(): date = parse_string_to_date_time("2019-04-01-10-11-12") assert "2019-04-01 10-11-12" == date.strftime("%Y-%m-%d %H-%M-%S")