-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #443 from jernst/develop
Fix invalid HTML escaping. 'role' not required in pre-existing accounts.
- Loading branch information
Showing
5 changed files
with
111 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
""" | ||
Test that Accounts and NonExistingAccounts are parsed correctly when given in a TestPlan that | ||
specifies a FallbackFediverseNode | ||
specifies a FallbackFediverseNode. This is the test in which the Accounts have pre-assigned roles. | ||
""" | ||
|
||
from typing import cast | ||
|
@@ -63,7 +63,7 @@ def test_plan_fixture() -> TestPlan: | |
return ret | ||
|
||
|
||
def test_parse(test_plan_fixture: TestPlan) -> None: | ||
def test_populate(test_plan_fixture: TestPlan) -> None: | ||
""" | ||
Tests parsing the TestPlan | ||
""" | ||
|
@@ -79,8 +79,14 @@ def test_parse(test_plan_fixture: TestPlan) -> None: | |
assert acc1.role == 'role1' | ||
assert acc1.actor_acct_uri == 'acct:[email protected]' | ||
|
||
acc11 = account_manager.obtain_account_by_role('role1') | ||
assert acc11 == acc1 | ||
|
||
non_acc1 = cast(FediverseNonExistingAccount | None, account_manager.get_non_existing_account_by_role('nonrole1')) | ||
assert non_acc1 | ||
assert non_acc1.role == 'nonrole1' | ||
assert non_acc1.actor_acct_uri == 'acct:[email protected]' | ||
|
||
non_acc11 = account_manager.obtain_non_existing_account_by_role('nonrole1') | ||
assert non_acc11 == non_acc1 | ||
|
91 changes: 91 additions & 0 deletions
91
tests.unit/test_40_fallback_fediverse_accounts_without_roles_from_testplan.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
""" | ||
Test that Accounts and NonExistingAccounts are parsed correctly when given in a TestPlan that | ||
specifies a FallbackFediverseNode. This is the test in which the Accounts do not have pre-assigned roles. | ||
""" | ||
|
||
from typing import cast | ||
|
||
import pytest | ||
|
||
import feditest | ||
from feditest.nodedrivers.saas import FediverseSaasNodeDriver | ||
from feditest.protocols.fediverse import ( | ||
USERID_ACCOUNT_FIELD, | ||
USERID_NON_EXISTING_ACCOUNT_FIELD, | ||
FediverseAccount, | ||
FediverseNonExistingAccount | ||
) | ||
from feditest.testplan import TestPlan, TestPlanConstellation, TestPlanConstellationNode, TestPlanSessionTemplate | ||
|
||
|
||
HOSTNAME = 'localhost' | ||
NODE1_ROLE = 'node1-role' | ||
|
||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def init(): | ||
""" Clean init """ | ||
feditest.all_tests = {} | ||
feditest._registered_as_test = {} | ||
feditest._registered_as_test_step = {} | ||
feditest._loading_tests = True | ||
|
||
feditest._loading_tests = False | ||
feditest._load_tests_pass2() | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def test_plan_fixture() -> TestPlan: | ||
node_driver = FediverseSaasNodeDriver() | ||
parameters = { | ||
'hostname' : 'example.com', # Avoid interactive question | ||
'app' : 'test-dummy' # Avoid interactive question | ||
} | ||
plan_accounts = [ | ||
{ | ||
USERID_ACCOUNT_FIELD.name : 'foo' | ||
} | ||
] | ||
plan_non_existing_accounts = [ | ||
{ | ||
USERID_NON_EXISTING_ACCOUNT_FIELD.name : 'nonfoo' | ||
} | ||
] | ||
node1 = TestPlanConstellationNode(node_driver, parameters, plan_accounts, plan_non_existing_accounts) | ||
constellation = TestPlanConstellation({ NODE1_ROLE : node1 }) | ||
session_template = TestPlanSessionTemplate([]) | ||
ret = TestPlan(session_template, [ constellation ]) | ||
ret.properties_validate() | ||
return ret | ||
|
||
|
||
def test_populate(test_plan_fixture: TestPlan) -> None: | ||
""" | ||
Tests parsing the TestPlan | ||
""" | ||
node1 = test_plan_fixture.constellations[0].roles[NODE1_ROLE] | ||
node_driver = node1.nodedriver | ||
|
||
node_config, account_manager = node_driver.create_configuration_account_manager(NODE1_ROLE, node1) | ||
node_driver.provision_node('test', node_config, account_manager) | ||
|
||
acc1 = cast(FediverseAccount | None, account_manager.get_account_by_role('role1')) | ||
|
||
assert acc1 is None | ||
|
||
acc1 = account_manager.obtain_account_by_role('role1') | ||
|
||
assert acc1 | ||
assert acc1.role is None | ||
assert acc1.actor_acct_uri == 'acct:[email protected]' | ||
|
||
non_acc1 = cast(FediverseNonExistingAccount | None, account_manager.get_non_existing_account_by_role('nonrole1')) | ||
|
||
assert non_acc1 is None | ||
|
||
non_acc1 = account_manager.obtain_non_existing_account_by_role('nonrole1') | ||
|
||
assert non_acc1 | ||
assert non_acc1.role is None | ||
assert non_acc1.actor_acct_uri == 'acct:[email protected]' | ||
|