浏览代码

drop invasions api (should be moved to separate package)

Fabian Peter Hammerle 4 年之前
父节点
当前提交
f856b47fdd
共有 3 个文件被更改,包括 6 次插入40 次删除
  1. 3 0
      CHANGELOG.md
  2. 3 8
      tests/test_.py
  3. 0 32
      tooncher/__init__.py

+ 3 - 0
CHANGELOG.md

@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Removed
 - `argcomplete`
+- `tooncher.INVASIONS_API_URL`
+- `tooncher.InvasionProgress`
+- `tooncher.request_active_invasions`
 
 ## [0.4.1] - 2019-12-22
 ### Fixed

+ 3 - 8
tests/test_.py

@@ -1,8 +1,8 @@
-# -*- coding: utf-8 -*-
-import pytest
-
 import shutil
 import subprocess
+
+import pytest
+
 import tooncher
 
 
@@ -20,8 +20,3 @@ def test_start_engine():
     env = stdout.strip().split(b"\n")
     assert b"TTR_GAMESERVER=gameserver" in env
     assert b"TTR_PLAYCOOKIE=cookie" in env
-
-
-def test_api_request_invasions():
-    resp_data = tooncher.api_request(tooncher.INVASIONS_API_URL)
-    assert "invasions" in resp_data

+ 0 - 32
tooncher/__init__.py

@@ -13,7 +13,6 @@ https://github.com/ToontownRewritten/api-doc/blob/master/login.md
 https://github.com/ToontownRewritten/api-doc/blob/master/invasions.md
 """
 
-INVASIONS_API_URL = "https://www.toontownrewritten.com/api/invasions?format=json"
 LOGIN_API_URL = "https://www.toontownrewritten.com/api/login?format=json"
 
 if sys.platform == "darwin":
@@ -132,34 +131,3 @@ def launch(
         p.wait()
     else:
         raise Exception(repr(result))
-
-
-class InvasionProgress:
-    def __init__(self, district, date, cog_type, despawned_number, total_number):
-        self.district = district
-        self.date = date
-        self.cog_type = cog_type
-        self.despawned_number = despawned_number
-        self.total_number = total_number
-
-    @property
-    def remaining_number(self):
-        return self.total_number - self.despawned_number
-
-
-def request_active_invasions(validate_ssl_certs=True):
-    resp_data = api_request(INVASIONS_API_URL)
-    if resp_data["error"] is not None:
-        raise Exception(resp_data["error"])
-    else:
-        invs = {}
-        for district, inv_data in resp_data["invasions"].items():
-            despawned_number, total_number = inv_data["progress"].split("/")
-            invs[district] = InvasionProgress(
-                district=district,
-                date=datetime.datetime.utcfromtimestamp(inv_data["asOf"]),
-                cog_type=inv_data["type"],
-                despawned_number=int(despawned_number),
-                total_number=int(total_number),
-            )
-        return invs