Skip to content

Commit

Permalink
Merge pull request #126 from wasade/latin1_bug
Browse files Browse the repository at this point in the history
Latin1 bug
  • Loading branch information
wasade authored Jun 28, 2023
2 parents 1900459 + 8d38b43 commit ed310d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 10 additions & 4 deletions redbiom/_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ def _parse_validate_request(req, command):
return req.json()[command]


def _format_request(context, command, other):
def _format_request(context, command, other, as_bytes=False):
"""Merge commands, context and payload"""
if context is None:
return "%s/%s.json" % (command, other)
data = "%s/%s.json" % (command, other)
else:
return "%s/%s:%s.json" % (command, context, other)
data = "%s/%s:%s.json" % (command, context, other)

if as_bytes:
return data.encode('utf-8')
else:
return data


def get_session():
Expand Down Expand Up @@ -55,7 +60,8 @@ def f(context, cmd, payload):
else:
def f(context, cmd, payload, verbose=False):
req = s.post(config['hostname'],
data=_format_request(context, cmd, payload))
data=_format_request(context, cmd, payload,
as_bytes=True))

if verbose:
print(context, cmd, payload[:100])
Expand Down
10 changes: 8 additions & 2 deletions redbiom/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,14 @@ def test_load_sample_metadata_content_type_sample_id_bug(self):
self.assertIn(cur + '.raw', obs)

def test_load_sample_metadata_full_search(self):
redbiom.admin.load_sample_metadata(metadata)
redbiom.admin.load_sample_metadata_full_search(metadata)
md = metadata.copy()

# valid portion of a name in Czech Republic, but which does not encode
# in python's http client
md.iloc[0]['STATE'] = "Vysočina"

redbiom.admin.load_sample_metadata(md)
redbiom.admin.load_sample_metadata_full_search(md)
tests = [('agp-skin', {'10317.000003302', }),

# an example of a misleading query. only those AG samples
Expand Down

0 comments on commit ed310d5

Please sign in to comment.