ianklatzco / atprototools

easy-to-use and ergonomic library for interacting with bluesky
MIT License
62 stars 11 forks source link

Parse DID correctly #14

Closed cobanov closed 1 year ago

cobanov commented 1 year ago

Previously, the code was not parsed the DID response correctly, resulting in incorrect data being parsed. This commit fixes the issue by properly splitting and parsing the DID.

ianklatzco commented 1 year ago

taking a look.....

ianklatzco commented 1 year ago

This change causes 2 tests to fail:

F....F..
======================================================================
FAIL: test_follow (tests.test_main.TestSessionLogin)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/user/atprototools/tests/test_main.py", line 35, in test_follow
    self.assertEqual(resp.status_code, 200)
AssertionError: 400 != 200

======================================================================
FAIL: test_post_skoot (tests.test_main.TestSessionLogin)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/user/atprototools/tests/test_main.py", line 54, in test_post_skoot
    self.assertEqual(resp.status_code, 200)
AssertionError: 400 != 200

----------------------------------------------------------------------
Ran 8 tests in 7.731s

FAILED (failures=2)

In test_follow and follow,

https://github.com/ianklatzco/atprototools/blob/52e1b027ee30d16cf09845ae6e21ba5f17df61e1/atprototools/__init__.py#L236-L240

The record is expected to contain "repo": "did:plc:blahblahblah"

Splitting the DID sends only blahblahblah.

It might be better to manually put did:plc in follow, but I'm not sure.

What do you think? ^^

(thanks for the PR!)

cobanov commented 1 year ago

as you can see here each function which using 'DID' expecting in that format, what do you think maybe we can init another attribute self.DID_key maybe?

https://gist.github.com/cobanov/023f497e6790b74e79c44c76ce67e68b

ianklatzco commented 1 year ago

i think it might be better to have the user manually do a session.DID.split(":")[-1] or add did:plc: back whenever they need to ^^

although, atprototools is a bit inconsistent in some places (e.g. usage of did vs username, which_case theCodeIsUsing). that would be a good thing to look at ^^

ianklatzco commented 1 year ago

here's the related issue ^^ https://github.com/ianklatzco/atprototools/issues/12