Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions census/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ def tables(self, *args, **kwargs):
self._switch_endpoints(kwargs.get('year', self.default_year))
return super(ACSClient, self).tables(*args, **kwargs)

def fields(self, *args, **kwargs):
self._switch_endpoints(kwargs.get('year', self.default_year))
return super(ACSClient, self).fields(*args, **kwargs)

def get(self, *args, **kwargs):
self._switch_endpoints(kwargs.get('year', self.default_year))

Expand Down Expand Up @@ -466,6 +470,10 @@ def tables(self, *args, **kwargs):
self._switch_endpoints(kwargs.get('year', self.default_year))
return super(SF1Client, self).tables(*args, **kwargs)

def fields(self, *args, **kwargs):
self._switch_endpoints(kwargs.get('year', self.default_year))
return super(SF1Client, self).fields(*args, **kwargs)

def get(self, *args, **kwargs):
self._switch_endpoints(kwargs.get('year', self.default_year))

Expand Down Expand Up @@ -548,6 +556,10 @@ def tables(self, *args, **kwargs):
self._switch_endpoints(kwargs.get('year', self.default_year))
return super(PLClient, self).tables(*args, **kwargs)

def fields(self, *args, **kwargs):
self._switch_endpoints(kwargs.get('year', self.default_year))
return super(PLClient, self).fields(*args, **kwargs)

def get(self, *args, **kwargs):
self._switch_endpoints(kwargs.get('year', self.default_year))

Expand Down
10 changes: 10 additions & 0 deletions census/tests/test_census.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@ def test_tables(self):
self.client('sf1').tables()
self.client('pl').tables()

def test_fields(self):
# Regression for #138: fields() needs the same endpoint switch
# that tables() and get() do. Otherwise calling fields() before
# anything else on an ACS/SF1/PL client hits the wrong URL and
# 404s.
self.client('acs5').fields()
self.client('acs5').fields(2010)
self.client('sf1').fields()
self.client('pl').fields()

def test_acs5(self):

tests = (
Expand Down