kopia lustrzana https://github.com/snarfed/bridgy-fed
User.get_or_create: if the id is a copy, return the original
...which will be in a different protocol! worried this will break something. hrm.pull/968/head
rodzic
0f89b0750a
commit
506de7fd1d
|
@ -244,6 +244,8 @@ class User(StringIdModel, metaclass=ProtocolUserMeta):
|
|||
if not propagate:
|
||||
return user
|
||||
else:
|
||||
if orig := get_original(id):
|
||||
return orig
|
||||
user = cls(id=id, **kwargs)
|
||||
user.existing = False
|
||||
|
||||
|
|
|
@ -138,6 +138,11 @@ class UserTest(TestCase):
|
|||
self.assertEqual('y.z', got.key.id())
|
||||
assert got.existing
|
||||
|
||||
def test_get_or_create_by_copies(self):
|
||||
other = self.make_user(id='other:ab', cls=OtherFake,
|
||||
copies=[Target(uri='fake:ab', protocol='fake')])
|
||||
self.assert_entities_equal(other, Fake.get_or_create('fake:ab'))
|
||||
|
||||
def test_get_or_create_opted_out(self):
|
||||
user = self.make_user('fake:user', cls=Fake,
|
||||
obj_as1 = {'summary': '#nobridge'})
|
||||
|
|
Ładowanie…
Reference in New Issue