just renaming

pull/4/head
heck 2 years ago
parent 61174d0136
commit 23829e2507
  1. 18
      tests/conftest.py
  2. 4
      tests/constants.py
  3. 24
      tests/test_identity.py
  4. 4
      tests/test_message.py

@ -42,37 +42,37 @@ def ctx_init(tmpdir_factory, request):
@pytest.fixture()
def alice_sec_key_data(datadir):
def alice_key_sec(datadir):
key_data = datadir.read('alice@openpgp.example.sec.asc')
return key_data
@pytest.fixture()
def bob_pub_key_data(datadir):
def bob_key_pub(datadir):
key_data = datadir.read('bob@openpgp.example.pub.asc')
return key_data
@pytest.fixture()
def import_identity_alice(ctx_init, alice_sec_key_data):
def import_identity_alice(ctx_init, alice_key_sec):
import pEp
pEp.import_key(alice_sec_key_data)
pEp.import_key(alice_key_sec)
alice = pEp.Identity(
constants.ALICE_ADDRESS, constants.ALICE_NAME,
constants.ALICE_NAME_ADDR, constants.ALICE_FP, 0, ''
constants.ALICE_NAME_ADDR, constants.ALICE_FPR, 0, ''
)
pEp.set_own_key(alice, constants.ALICE_FP)
pEp.set_own_key(alice, constants.ALICE_FPR)
return alice
@pytest.fixture()
def import_identity_bob(ctx_init, bob_pub_key_data):
def import_identity_bob(ctx_init, bob_key_pub):
import pEp
pEp.import_key(bob_pub_key_data)
pEp.import_key(bob_key_pub)
bob = pEp.Identity(
constants.BOB_ADDRESS, constants.BOB_NAME, '',
constants.BOB_FP, 56, ''
constants.BOB_FPR, 56, ''
)
return bob

@ -11,12 +11,12 @@ NAME_ADDR = "{} {}"
BOB_NAME = "Bob Babagge"
BOB_ADDRESS = "bob@openpgp.example"
BOB_FP = "D1A66E1A23B182C9980F788CFBFCC82A015E7330"
BOB_FPR = "D1A66E1A23B182C9980F788CFBFCC82A015E7330"
BOB_NAME_ADDR = NAME_ADDR.format(BOB_NAME, ANGLE_ADDR.format(BOB_ADDRESS))
ALICE_NAME = "Alice Lovelace"
ALICE_ADDRESS = "alice@openpgp.example"
ALICE_FP = "EB85BB5FA33A75E15E944E63F231550C4F47E38E"
ALICE_FPR = "EB85BB5FA33A75E15E944E63F231550C4F47E38E"
ALICE_NAME_ADDR = NAME_ADDR.format(ALICE_NAME, ANGLE_ADDR.format(ALICE_ADDRESS))
SUBJECT = "This is a subject"

@ -11,11 +11,11 @@ def test_create_one_identity_succeed(ctx_init):
alice = pEp.Identity()
alice.address = constants.ALICE_ADDRESS
alice.username = constants.ALICE_NAME
alice.fpr = constants.ALICE_FP
alice.fpr = constants.ALICE_FPR
expected_alice = pEp.Identity(
constants.ALICE_ADDRESS, constants.ALICE_NAME, '',
constants.ALICE_FP, 0, ''
constants.ALICE_FPR, 0, ''
)
# XXX: Can't compare objects
@ -44,29 +44,29 @@ def test_create_one_identity_succeed(ctx_init):
assert alice.flags == expected_alice.flags
def test_two_identities_succeed(ctx_init, bob_pub_key_data):
def test_two_identities_succeed(ctx_init, bob_key_pub):
import pEp
alice = pEp.Identity(
constants.ALICE_ADDRESS, constants.ALICE_NAME, '',
constants.ALICE_FP, 0, ''
constants.ALICE_FPR, 0, ''
)
assert alice.address == constants.ALICE_ADDRESS
assert alice.username == constants.ALICE_NAME
assert alice.fpr == constants.ALICE_FP
assert alice.fpr == constants.ALICE_FPR
assert alice.user_id == ""
assert alice.comm_type == 0
assert alice.flags == 0
pEp.import_key(bob_pub_key_data)
pEp.import_key(bob_key_pub)
bob = pEp.Identity()
bob.address = constants.BOB_ADDRESS
bob.username = constants.BOB_NAME
bob.fpr = constants.BOB_FP
bob.fpr = constants.BOB_FPR
expected_bob = pEp.Identity(
constants.BOB_ADDRESS, constants.BOB_NAME, '',
constants.BOB_FP, 56, ''
constants.BOB_FPR, 56, ''
)
assert str(bob) == constants.BOB_NAME_ADDR
@ -88,19 +88,19 @@ def test_two_identities_succeed(ctx_init, bob_pub_key_data):
assert bob.flags == 0
def test_set_own_key(ctx_init, alice_sec_key_data):
def test_set_own_key(ctx_init, alice_key_sec):
import pEp
pEp.import_key(alice_sec_key_data)
pEp.import_key(alice_key_sec)
alice = pEp.Identity()
alice.address = constants.ALICE_ADDRESS
alice.username = constants.ALICE_NAME
alice.fpr = constants.ALICE_FP
alice.fpr = constants.ALICE_FPR
alice.user_id = constants.ALICE_NAME_ADDR
expected_alice = pEp.Identity(
constants.ALICE_ADDRESS, constants.ALICE_NAME, '',
constants.ALICE_FP, 0, ''
constants.ALICE_FPR, 0, ''
)
pEp.set_own_key(alice, alice.fpr)

@ -43,8 +43,8 @@ def test_msg_enc_dec_roundtrip(import_identity_alice, import_identity_bob):
assert rating == pEp._pEp.rating.reliable
# The first 2 keys are Alice's ones, the last is Bob's one.
assert key_list[0] == key_list[1] == constants.ALICE_FP
assert key_list[-1] == constants.BOB_FP
assert key_list[0] == key_list[1] == constants.ALICE_FPR
assert key_list[-1] == constants.BOB_FPR
assert dec_msg.shortmsg == constants.SUBJECT
assert dec_msg.longmsg.replace("\r", "") == msg.longmsg
dec_lines = str(dec_msg).replace("\r", "").split("\n")

Loading…
Cancel
Save