bovine.testing
bovine.testing
The goal of the testing module is to provide some examples of commonly used things to make writing tests easier.
Usage examples
For public_key and private_key
>>> from bovine.crypto.helper import pem_private_key_to_pem_public_key
>>> pem_private_key_to_pem_public_key(private_key) == public_key
True
For ed25519_key and did_key
>>> from bovine.crypto import private_key_to_did_key
>>> private_key_to_did_key(ed25519_key) == did_key
True
For activity_factory see also ActivityFactory
>>> activity_factory.like("http://bovine.example").build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Like',
'actor': 'http://actor.example',
'published': '2024-09-26T18:35:42Z',
'object': 'http://bovine.example'}
For object_factory see also ObjectFactory and the provided note
>>> object_factory.note(content="moo").build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Note',
'attributedTo': 'http://actor.example',
'published': '2024-09-26T18:35:42Z',
'content': 'moo'}
>>> note
{'@context': 'https://www.w3.org/ns/activitystreams',
'type': 'Note',
'attributedTo': 'http://actor.example',
'to': ['https://www.w3.org/ns/activitystreams#Public'],
'cc': ['http://actor.example/followers'],
'published': '...',
'content': 'moo'}
activity_factory
module-attribute
activity_factory = ActivityFactory(actor)
The activity factory for the actor
activity_factory_id
module-attribute
activity_factory_id = ActivityFactory(
actor, id_generator=make_id
)
The activity factory for the actor with predefined id generator
actor
module-attribute
actor = {
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
],
"publicKey": {
"id": "http://actor.example#name",
"owner": "http://actor.example",
"publicKeyPem": public_key,
},
"id": "http://actor.example",
"type": "Person",
"inbox": "http://actor.example/inbox",
"outbox": "http://actor.example/outbox",
"followers": "http://actor.example/followers",
}
Example of an ActivityStreams Actor
ecp256_key
module-attribute
A NIST P-256 private key
ed25519_key
module-attribute
An Ed25519 private key encoded in multibase
object_factory
module-attribute
object_factory = ObjectFactory(actor)
The object factory for the actor