TestAnnounceShare.py 969 B

12345678910111213141516171819202122232425
  1. import pytest
  2. from AnnounceShare import AnnounceSharePlugin
  3. from Peer import Peer
  4. from Config import config
  5. @pytest.mark.usefixtures("resetSettings")
  6. @pytest.mark.usefixtures("resetTempSettings")
  7. class TestAnnounceShare:
  8. def testAnnounceList(self, file_server):
  9. open("%s/trackers.json" % config.data_dir, "w").write("{}")
  10. tracker_storage = AnnounceSharePlugin.tracker_storage
  11. tracker_storage.load()
  12. peer = Peer(file_server.ip, 1544, connection_server=file_server)
  13. assert peer.request("getTrackers")["trackers"] == []
  14. tracker_storage.onTrackerFound("zero://%s:15441" % file_server.ip)
  15. assert peer.request("getTrackers")["trackers"] == []
  16. # It needs to have at least one successfull announce to be shared to other peers
  17. tracker_storage.onTrackerSuccess("zero://%s:15441" % file_server.ip, 1.0)
  18. assert peer.request("getTrackers")["trackers"] == ["zero://%s:15441" % file_server.ip]