def test_entity_is_validated__success(self, private_key): entity = Share( actor_id="https://localhost.local/foo", id="https://localhost.local/bar", created_at=datetime.now(), target_id="https://localhost.local/bar", ) get_outbound_entity(entity, private_key)
def test_entity_is_validated__fail(self, private_key): entity = Share( actor_id="https://localhost.local/foo", id="https://localhost.local/bar", created_at=datetime.now(), ) with pytest.raises(ValueError): get_outbound_entity(entity, private_key)
def test_already_fine_entities_are_returned_as_is(self, private_key): entity = ActivitypubAccept() entity.validate = Mock() assert get_outbound_entity(entity, private_key) == entity entity = ActivitypubFollow() entity.validate = Mock() assert get_outbound_entity(entity, private_key) == entity entity = ActivitypubProfile() entity.validate = Mock() assert get_outbound_entity(entity, private_key) == entity
def test_profile_is_converted_to_activitypubprofile(self, private_key): entity = Profile() assert isinstance(get_outbound_entity(entity, private_key), ActivitypubProfile)
def test_follow_is_converted_to_activitypubfollow(self, private_key): entity = Follow() assert isinstance(get_outbound_entity(entity, private_key), ActivitypubFollow)
def test_accept_is_converted_to_activitypubaccept(self, private_key): entity = Accept() assert isinstance(get_outbound_entity(entity, private_key), ActivitypubAccept)