Exemplo n.º 1
0
def test_tracker_send_methods(
    is_frozen,
    use_analytics,
    metrics_shared,
    method,
    arguments,
    manager_factory,
    monkeypatch,
):
    def post(*args, **kwargs):
        nonlocal checkpoint
        checkpoint = True

    # We need an engine to test custom dimensions (here it is unused and so we use "_")
    manager, _ = manager_factory()

    Options.is_frozen = is_frozen
    Options.use_analytics = use_analytics
    checkpoint = False

    with manager:
        tracker = Tracker(manager, uid="")
        monkeypatch.setattr(tracker._session, "post", post)
        getattr(tracker, method)(*arguments)

    assert checkpoint is metrics_shared
Exemplo n.º 2
0
def test_tracker_instance_and_attrs(manager_factory):
    """Naive checks to ensure the class and principal methods are functional."""

    Options.is_frozen = True
    Options.use_analytics = True

    with manager_factory(with_engine=False) as manager:
        tracker = Tracker(manager, uid="")
        assert repr(tracker)
Exemplo n.º 3
0
def test_tracker_instance_and_attrs(manager_factory):
    """Naive checks to ensure the class and principal methods are functional."""

    with manager_factory(with_engine=False) as manager:
        tracker = Tracker(manager, uid="")
        assert repr(tracker)

        assert tracker.current_locale
        assert tracker.user_agent
Exemplo n.º 4
0
def test_tracker_send_methods(manager_factory, monkeypatch):
    def send(*args, **kwargs):
        pass

    # We need an engine to test custom dimensions (here it is unused and so we use "_")
    manager, _ = manager_factory()

    with manager:
        tracker = Tracker(manager, uid="")
        monkeypatch.setattr(tracker._tracker, "send", send)

        tracker._send_directedit_open("Jean-Michel Jarre - Oxygen")
        tracker._send_directedit_edit("Jean-Michel Jarre - Oxygen.ogg")
        tracker._send_stats()
Exemplo n.º 5
0
def test_tracker_send_methods(manager_factory, monkeypatch):
    def send(*args, **kwargs):
        pass

    # We need an engine to test custom dimensions (here it is unused and so we use "_")
    manager, _ = manager_factory()

    metrics = {
        "start_time": 0,
        "end_time": 42,
        "speed": 42,
        "handler": "test_tracker_send_methods",
    }

    with manager:
        tracker = Tracker(manager, uid="")
        monkeypatch.setattr(tracker._tracker, "send", send)

        tracker._send_directedit_open("Jean-Michel Jarre - Oxygen")
        tracker._send_directedit_edit("Jean-Michel Jarre - Oxygen.ogg")
        tracker._send_sync_event(metrics)
        tracker._send_stats()
Exemplo n.º 6
0
def test_tracker_send_methods(manager_factory, monkeypatch):
    def post(*args, **kwargs):
        pass

    Options.is_frozen = True
    Options.use_analytics = True

    # We need an engine to test custom dimensions (here it is unused and so we use "_")
    manager, _ = manager_factory()

    metrics = {"start_ns": monotonic_ns(), "handler": "locally_created"}

    with manager:
        tracker = Tracker(manager, uid="")
        monkeypatch.setattr(tracker._session, "post", post)

        tracker.send_directedit_open("Jean-Michel Jarre - Oxygen", 42)
        tracker.send_directedit_open("Jean-Michel Jarre - Oxygen.ogg", 42)
        tracker.send_directedit_edit("Jean-Michel Jarre - Oxygen", 42)
        tracker.send_directedit_edit("Jean-Michel Jarre - Oxygen.ogg", 42)
        tracker.send_direct_transfer(True, 0)
        tracker.send_direct_transfer(False, 42)
        tracker.send_sync_event(metrics)
        tracker._poll()
Exemplo n.º 7
0
 def _create_tracker(self):
     from nxdrive.engine.tracker import Tracker
     self._tracker = Tracker(self)
     # Start the tracker when we launch
     self.started.connect(self._tracker._thread.start)
     return self._tracker