-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create new export() method in PageObjectRegistry
- Loading branch information
Showing
21 changed files
with
203 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
"""This tests the expected behavior of importing multiple different POPs such | ||
that they don't leak the OverrideRules from other POPs that use the same | ||
``default_registry``. | ||
Packacking and exporting a given POP should be resilient from such cases. | ||
In particular, this tests the :meth:`PageObjectRegistry.export` functionality. | ||
""" | ||
|
||
def test_base_A(): | ||
from tests_pop import base_A_package | ||
|
||
reg = base_A_package.REGISTRY | ||
|
||
assert len(reg) == 2 | ||
assert base_A_package.site_1.A_Site1 in reg | ||
assert base_A_package.site_2.A_Site2 in reg | ||
|
||
|
||
def test_base_B(): | ||
from tests_pop import base_B_package | ||
|
||
reg = base_B_package.REGISTRY | ||
|
||
assert len(reg) == 2 | ||
assert base_B_package.site_2.B_Site2 in reg | ||
assert base_B_package.site_3.B_Site3 in reg | ||
|
||
|
||
def test_improved_A(): | ||
from tests_pop import improved_A_package, base_A_package | ||
|
||
reg = improved_A_package.REGISTRY | ||
|
||
assert len(reg) == 3 | ||
assert improved_A_package.site_1.A_Improved_Site1 in reg | ||
assert improved_A_package.base_A_package.site_1.A_Site1 in reg | ||
assert improved_A_package.base_A_package.site_2.A_Site2 in reg | ||
|
||
|
||
def test_combine_A_B(): | ||
from tests_pop import combine_A_B_package, base_A_package, base_B_package | ||
|
||
reg = combine_A_B_package.REGISTRY | ||
|
||
assert len(reg) == 4 | ||
assert combine_A_B_package.base_A_package.site_1.A_Site1 in reg | ||
assert combine_A_B_package.base_A_package.site_2.A_Site2 in reg | ||
assert combine_A_B_package.base_B_package.site_2.B_Site2 in reg | ||
assert combine_A_B_package.base_B_package.site_3.B_Site3 in reg | ||
|
||
|
||
def test_combine_A_B_subset(): | ||
from tests_pop import combine_A_B_subset_package, improved_A_package, base_B_package | ||
|
||
reg = combine_A_B_subset_package.REGISTRY | ||
|
||
assert len(reg) == 2 | ||
assert combine_A_B_subset_package.improved_A_package.site_1.A_Improved_Site1 in reg | ||
assert combine_A_B_subset_package.base_B_package.site_3.B_Site3 in reg |
Empty file.
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,3 @@ | ||
from web_poet import default_registry | ||
|
||
REGISTRY = default_registry.export(__package__) |
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,2 @@ | ||
class BasePage: | ||
... |
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,8 @@ | ||
from web_poet import handle_urls | ||
|
||
from .base import BasePage | ||
|
||
|
||
@handle_urls("site_1.com", overrides=BasePage) | ||
class A_Site1: | ||
... |
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,8 @@ | ||
from web_poet import handle_urls | ||
|
||
from .base import BasePage | ||
|
||
|
||
@handle_urls("site_2.com", overrides=BasePage) | ||
class A_Site2: | ||
... |
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,3 @@ | ||
from web_poet import default_registry | ||
|
||
REGISTRY = default_registry.export(__package__) |
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,2 @@ | ||
class BasePage: | ||
... |
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,8 @@ | ||
from web_poet import handle_urls | ||
|
||
from .base import BasePage | ||
|
||
|
||
@handle_urls("site_2.com", overrides=BasePage) | ||
class B_Site2: | ||
... |
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,8 @@ | ||
from web_poet import handle_urls | ||
|
||
from .base import BasePage | ||
|
||
|
||
@handle_urls("site_3.com", overrides=BasePage) | ||
class B_Site3: | ||
... |
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,9 @@ | ||
"""This POP simply wants to repackage POP "A" and "B" into one unifying package.""" | ||
|
||
from web_poet import PageObjectRegistry | ||
|
||
from . import base_A_package | ||
from . import base_B_package | ||
|
||
combined = {**base_A_package.REGISTRY, **base_B_package.REGISTRY} | ||
REGISTRY = PageObjectRegistry(combined) |
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 @@ | ||
../base_A_package |
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 @@ | ||
../base_B_package |
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,16 @@ | ||
"""This POP simply wants to repackage POP "A" and "B" into one unifying package.""" | ||
|
||
from web_poet import PageObjectRegistry | ||
|
||
from . import improved_A_package | ||
from . import base_B_package | ||
|
||
rules_A_improved = improved_A_package.REGISTRY.search_overrides( | ||
use=improved_A_package.site_1.A_Improved_Site1 # type:ignore | ||
) | ||
rules_B = base_B_package.REGISTRY.search_overrides( | ||
use=base_B_package.site_3.B_Site3 # type: ignore | ||
) | ||
|
||
combined_rules = rules_A_improved + rules_B | ||
REGISTRY = PageObjectRegistry.from_override_rules(combined_rules) |
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 @@ | ||
../base_B_package |
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 @@ | ||
../improved_A_package |
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,3 @@ | ||
from web_poet import default_registry | ||
|
||
REGISTRY = default_registry.export(__package__) |
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 @@ | ||
../base_A_package |
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,9 @@ | ||
from web_poet import handle_urls | ||
|
||
from .base_A_package.base import BasePage | ||
from .base_A_package.site_1 import A_Site1 | ||
|
||
|
||
@handle_urls("site_1.com", overrides=BasePage) | ||
class A_Improved_Site1(A_Site1): | ||
... # some improvements here after subclassing the original one. |
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