From 2f15a5389a10201f62ab91e21408a0df8dc92eac Mon Sep 17 00:00:00 2001 From: Angela Gloyna Date: Wed, 25 Oct 2023 13:05:54 -0500 Subject: [PATCH] #816 Airtable.get_records() fields argument can be either str or list (#892) * all fields to be a str object * remove newline --- parsons/airtable/airtable.py | 2 ++ test/test_airtable/test_airtable.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/parsons/airtable/airtable.py b/parsons/airtable/airtable.py index 3465d4cd2..b9fa866d8 100644 --- a/parsons/airtable/airtable.py +++ b/parsons/airtable/airtable.py @@ -94,6 +94,8 @@ def get_records( See :ref:`parsons-table` for output options. """ + if isinstance(fields, str): + fields = [fields] # Raises an error if sort is None type. Thus, only adding if populated. kwargs = { "fields": fields, diff --git a/test/test_airtable/test_airtable.py b/test/test_airtable/test_airtable.py index e85db472b..ff326c43b 100644 --- a/test/test_airtable/test_airtable.py +++ b/test/test_airtable/test_airtable.py @@ -99,6 +99,16 @@ def test_get_records_with_explicit_headers(self, m): assert airtable_res.columns == ["id", "createdTime", "Name", "SecondColumn"] + @requests_mock.Mocker() + def test_get_records_with_single_field(self, m): + m.get(self.base_uri, json=records_response_with_more_columns) + + fields = "Name" + + airtable_res = self.at.get_records(fields, sample_size=1) + + assert airtable_res.columns == ["id", "createdTime", "Name"] + @requests_mock.Mocker() def test_insert_record(self, m):