feat: complete modular plugin refactor with 100% E2E coverage for interactions
This commit is contained in:
@@ -207,8 +207,11 @@ def mock_all_delays(monkeypatch, request):
|
||||
def simulate_sleep(seconds):
|
||||
clock.sleep(seconds)
|
||||
|
||||
money_sleep = lambda x: simulate_sleep(x)
|
||||
random_sleep = lambda a=1.0, b=2.0, *args, **kwargs: simulate_sleep(max(1.5, float(a)))
|
||||
def money_sleep(x):
|
||||
return simulate_sleep(x)
|
||||
|
||||
def random_sleep(a=1.0, b=2.0, *args, **kwargs):
|
||||
return simulate_sleep(max(1.5, float(a)))
|
||||
|
||||
monkeypatch.setattr(time, "sleep", money_sleep)
|
||||
monkeypatch.setattr(utils, "random_sleep", random_sleep)
|
||||
@@ -266,10 +269,9 @@ def mock_identity_guard(monkeypatch):
|
||||
@pytest.fixture
|
||||
def e2e_configs():
|
||||
import argparse
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
configs = MagicMock()
|
||||
configs.username = "testuser"
|
||||
configs.args = argparse.Namespace(
|
||||
args = argparse.Namespace(
|
||||
username="testuser",
|
||||
device="emulator-5554",
|
||||
app_id="com.instagram.android",
|
||||
@@ -281,9 +283,12 @@ def e2e_configs():
|
||||
reels=None,
|
||||
stories=None,
|
||||
interact_percentage=100,
|
||||
likes_count="2-3",
|
||||
likes_percentage=100,
|
||||
follow_percentage=100,
|
||||
comment_percentage=100,
|
||||
stories_count="1-2",
|
||||
stories_percentage=100,
|
||||
working_hours=[0.0, 24.0],
|
||||
time_delta_session=0,
|
||||
speed_multiplier=1.0,
|
||||
@@ -295,7 +300,34 @@ def e2e_configs():
|
||||
ai_telepathic_url="http://localhost",
|
||||
ai_telepathic_model="llama3",
|
||||
ai_condenser_url="http://localhost",
|
||||
dry_run_comments=False,
|
||||
visual_vibe_check_percentage=0,
|
||||
)
|
||||
|
||||
configs = MagicMock()
|
||||
configs.args = args
|
||||
configs.username = "testuser"
|
||||
|
||||
# Realistically mock get_plugin_config
|
||||
def get_plugin_config_mock(plugin_name):
|
||||
# Return a dict that simulates what's in the args for that plugin
|
||||
mapping = {
|
||||
"likes": {"count": args.likes_count, "percentage": args.likes_percentage},
|
||||
"comment": {
|
||||
"percentage": args.comment_percentage,
|
||||
"dry_run": args.dry_run_comments,
|
||||
},
|
||||
"follow": {"percentage": args.follow_percentage},
|
||||
"stories": {"count": args.stories_count, "percentage": args.stories_percentage},
|
||||
"resonance_evaluator": {"visual_vibe_check_percentage": args.visual_vibe_check_percentage},
|
||||
"carousel_browsing": {
|
||||
"percentage": getattr(args, "carousel_percentage", 0),
|
||||
"count": getattr(args, "carousel_count", "1"),
|
||||
},
|
||||
}
|
||||
return mapping.get(plugin_name, {})
|
||||
|
||||
configs.get_plugin_config.side_effect = get_plugin_config_mock
|
||||
return configs
|
||||
|
||||
|
||||
@@ -320,3 +352,51 @@ def mock_sae_perceive(request, monkeypatch):
|
||||
"perceive",
|
||||
lambda self, xml: GramAddict.core.situational_awareness.SituationType.NORMAL,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_e2e_plugin_registry():
|
||||
"""Ensures that all standard plugins are registered for E2E tests."""
|
||||
from GramAddict.core.behaviors import PluginRegistry
|
||||
from GramAddict.core.behaviors.ad_guard import AdGuardPlugin
|
||||
from GramAddict.core.behaviors.anomaly_handler import AnomalyHandlerPlugin
|
||||
from GramAddict.core.behaviors.carousel_browsing import CarouselBrowsingPlugin
|
||||
from GramAddict.core.behaviors.close_friends_guard import CloseFriendsGuardPlugin
|
||||
from GramAddict.core.behaviors.comment import CommentPlugin
|
||||
from GramAddict.core.behaviors.darwin_dwell import DarwinDwellPlugin
|
||||
from GramAddict.core.behaviors.follow import FollowPlugin
|
||||
from GramAddict.core.behaviors.grid_like import GridLikePlugin
|
||||
from GramAddict.core.behaviors.like import LikePlugin
|
||||
from GramAddict.core.behaviors.obstacle_guard import ObstacleGuardPlugin
|
||||
from GramAddict.core.behaviors.perfect_snapping import PerfectSnappingPlugin
|
||||
from GramAddict.core.behaviors.post_data_extraction import PostDataExtractionPlugin
|
||||
from GramAddict.core.behaviors.post_interaction import PostInteractionPlugin
|
||||
from GramAddict.core.behaviors.profile_guard import ProfileGuardPlugin
|
||||
from GramAddict.core.behaviors.profile_visit import ProfileVisitPlugin
|
||||
from GramAddict.core.behaviors.rabbit_hole import RabbitHolePlugin
|
||||
from GramAddict.core.behaviors.repost import RepostPlugin
|
||||
from GramAddict.core.behaviors.resonance_evaluator import ResonanceEvaluatorPlugin
|
||||
from GramAddict.core.behaviors.story_view import StoryViewPlugin
|
||||
|
||||
PluginRegistry.reset()
|
||||
plugin_registry = PluginRegistry.get_instance()
|
||||
plugin_registry.register(ProfileGuardPlugin())
|
||||
plugin_registry.register(StoryViewPlugin())
|
||||
plugin_registry.register(FollowPlugin())
|
||||
plugin_registry.register(GridLikePlugin())
|
||||
plugin_registry.register(CarouselBrowsingPlugin())
|
||||
plugin_registry.register(AdGuardPlugin())
|
||||
plugin_registry.register(CloseFriendsGuardPlugin())
|
||||
plugin_registry.register(AnomalyHandlerPlugin())
|
||||
plugin_registry.register(ObstacleGuardPlugin())
|
||||
plugin_registry.register(PerfectSnappingPlugin())
|
||||
plugin_registry.register(PostDataExtractionPlugin())
|
||||
plugin_registry.register(ResonanceEvaluatorPlugin())
|
||||
plugin_registry.register(RabbitHolePlugin())
|
||||
plugin_registry.register(DarwinDwellPlugin())
|
||||
plugin_registry.register(ProfileVisitPlugin())
|
||||
plugin_registry.register(LikePlugin())
|
||||
plugin_registry.register(CommentPlugin())
|
||||
plugin_registry.register(RepostPlugin())
|
||||
plugin_registry.register(PostInteractionPlugin())
|
||||
yield plugin_registry
|
||||
|
||||
Reference in New Issue
Block a user