Repository: Coffee-fueled-deadlines/OSRSBytes (language: python)

Issue:
Merge Actions into Dev



Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index 2440270..30d5997 100644
--- a/.gitignore
+++ b/.gitignore
@@ -106,7 +106,5 @@ venv.bak/
 .mypy_cache/
 readme.md
 .readme.md
-hiscores_test.py
-items_test.py
 setup.py
 .setup.py
diff --git a/OSRSBytes/Hiscores.py b/OSRSBytes/Hiscores.py
index 8da216d..b7b54b6 100644
--- a/OSRSBytes/Hiscores.py
+++ b/OSRSBytes/Hiscores.py
@@ -52,6 +52,9 @@ class LMSArenaError(Exception):
 class BossError(Exception):
     pass
 
+class BountyError(Exception):
+    pass
+
 ############################
 #  Do not run if __main__  #
 ############################


Test patch:
diff --git a/OSRSBytes/tests/__init__.py b/OSRSBytes/tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/OSRSBytes/tests/hiscores_test.py b/OSRSBytes/tests/hiscores_test.py
new file mode 100644
index 0000000..0e03f11
--- /dev/null
+++ b/OSRSBytes/tests/hiscores_test.py
@@ -0,0 +1,74 @@
+from OSRSBytes import Hiscores
+
+def test(verbose = True):
+    pvp_user = Hiscores("C Engineer")
+    boss_user = Hiscores("Hess")
+    failed_tests = []
+
+    for skill in boss_user.getSkillsGenerator():
+        try:
+            assert boss_user.skill(skill, "rank"), "Failed"        
+            assert boss_user.skill(skill, "level"), "Failed"
+        except:
+            failed_tests.append(skill)
+        if (verbose):
+            print("Skill: {}\n\tRank: {}\n\tLevel: {}"
+                .format(skill, boss_user.skill(skill,"rank"), boss_user.skill(skill,"level")))
+
+    for activity in pvp_user.getPVPGenerator():
+        try:
+            assert pvp_user.lms_arena_sw(activity, "rank"), "Failed"
+            assert pvp_user.lms_arena_sw(activity, "score"), "Failed"
+        except:
+            failed_tests.append(activity)
+        if (verbose):
+            print("Activity: {}\n\tRank: {}\n\tScore: {}"
+                .format(activity, pvp_user.lms_arena_sw(activity,"rank"), pvp_user.lms_arena_sw(activity,"score")))
+
+    for clue in boss_user.getClueGenerator():
+        try:
+            assert boss_user.clue(clue, "rank"), "Failed"
+            assert boss_user.clue(clue, "score"), "Failed"
+        except:
+            failed_tests.append(clue)
+        if (verbose):
+            print("Clue Tier: {}\n\tRank: {}\n\tScore: {}"
+                .format(clue, boss_user.clue(clue, "rank"), boss_user.clue(clue, "score")))
+
+    for bounty in pvp_user.getBountyGenerator():
+        try:
+            assert pvp_user.bounty(bounty, "rank"), "Failed"
+            assert pvp_user.bounty(bounty, "score"), "Failed"
+        except:
+            failed_tests.append(bounty)
+        if (verbose):
+            print("Bounty Type: {}\n\tRank: {}\n\tScore: {}"
+                .format(bounty, pvp_user.bounty(bounty, "rank"), pvp_user.bounty(bounty, "score")))
+
+    for boss in boss_user.getBossGenerator():
+        try:
+            assert boss_user.boss(boss, "rank"), "Failed"
+            assert boss_user.boss(boss, "score"), "Failed"
+        except:
+            failed_tests.append(boss)
+        if (verbose):
+            print("Boss Name: {}\n\tRank: {}\n\tScore: {}"
+                .format(boss, boss_user.boss(boss, "rank"), boss_user.boss(boss, "score")))
+
+    assert len(failed_tests) == 0
+    if (verbose):
+        if len(failed_tests) == 0:
+            print("\nTest Passed!")
+            return True
+        else:
+            print("\nTest Failed!")
+            print("\n\tNumber of Fails: {}".format(len(failed_tests)))
+            print("\nTests that failed:")
+            for fail in failed_tests:
+                print("\t\t{}".format(fail))
+            return False
+    else:
+        if len(failed_tests) == 0:
+            return True
+        else:
+            return False
\ No newline at end of file
diff --git a/OSRSBytes/tests/items_test.py b/OSRSBytes/tests/items_test.py
new file mode 100644
index 0000000..2dcec27
--- /dev/null
+++ b/OSRSBytes/tests/items_test.py
@@ -0,0 +1,167 @@
+from OSRSBytes import Items
+
+def test(verbose = False):
+    items = Items()
+    test_item = ["rune dagger",1213]
+    failed_list = []
+
+    # getItem Method Test
+    try:
+        items.getItem(test_item[0])
+        getItem_test = "Passed"
+    except:
+        getItem_test = "Failed"
+        failed_list.append("getItem")
+
+    # getName Method Test
+    try:
+        name = items.getName(test_item[1])
+        if name == test_item[0]:
+            getName_test = "Passed"
+        else:
+            getName_test = "Failed"
+    except:
+        getName_test = "Failed"
+        failed_list.append("getName")
+
+    # getItemID Method Test
+    try:
+        item_id = items.getItemID(test_item[0])
+        if item_id == test_item[1]:
+            getItemID_test = "Passed"
+        else:
+            getItemID_test = "Failed"
+    except:
+        getItemID_test = "Failed"
+        failed_list.append("getItemID")
+
+    # getBuyAverage Method Test
+    try:
+        getBuyAverage_test = "Passed"
+        if not items.getBuyAverage(test_item[0]):
+            getBuyAverage_test = "Failed"
+            failed_list.append("getBuyAverage")
+    except:
+        getBuyAverage_test = "Failed"
+        failed_list.append("getBuyAverage")
+
+    # getSellAverage Method Test
+    try:
+        getSellAverage_test = "Passed"
+        if not items.getSellAverage(test_item[0]):
+            getSellAverage_test = "Failed"
+            failed_list.append("getSellAverage")
+    except:
+        getSellAverage_test = "Failed"
+        failed_list.append("getSellAverage")
+
+    # getBuyQuantity Method Test
+    try:
+        getBuyQuantity_test = "Passed"
+        if not items.getBuyQuantity(test_item[0]):
+            getBuyQuantity_test = "Failed"
+            failed_list.append("getBuyQuantity")
+    except:
+        getBuyQuantity_test = "Failed"
+        failed_list.append("getBuyQuantity")    
+
+    # getSellQuantity Method Test
+    try:
+        getSellQuantity_test = "Passed"
+        if not items.getSellQuantity(test_item[0]):
+            getSellQuantity_test = "Failed"
+            failed_list.append("getSellQuantity")
+    except:
+        getSellQuantity_test = "Failed"
+        failed_list.append("getSellQuantity")    
+
+    # getBuyLimit Method Test
+    try:
+        getBuyLimit_test = "Passed"
+        if not items.getBuyLimit(test_item[0]):
+            getBuyLimit_test = "Failed"
+            failed_list.append("getBuyLimit")
+    except:
+        getBuyLimit_test = "Failed"
+        failed_list.append("getBuyLimit")
+
+    # getShopPrice Method Test
+    try:
+        getShopPrice_test = "Passed"
+        if not items.getShopPrice(test_item[0]):
+            getShopPrice_test = "Failed"
+            failed_list.append("getShopPrice")
+    except:
+        getShopPrice_test = "Failed"
+        failed_list.append("getShopPrice")
+
+    # getLowAlchValue Method Test
+    try:
+        getLowAlchValue_test = "Passed"
+        if not items.getLowAlchValue(test_item[0]):
+            getLowAlchValue_test = "Failed"
+            failed_list.append("getLowAlchValue")
+    except:
+        getLowAlchValue_test = "Failed"
+        failed_list.append("getLowAlchValue")
+
+    # getHighAlchValue Method Test
+    try:
+        getHighAlchValue_test = "Passed"
+        if not items.getHighAlchValue(test_item[0]):
+            getHighAlchValue_test = "Failed"
+            failed_list.append("getHighAlchValue")
+    except:
+        getHighAlchValue_test = "Failed"
+        failed_list.append("getHighAlchValue")
+
+    # isMembers Method Test
+    try:
+        isMembers_test = "Passed"
+        if items.isMembers(test_item[0]) != False:
+            isMembers_test = "Failed"
+            failed_list.append("isMembers")
+    except:
+        isMembers_test = "Failed"
+        failed_list.append("isMembers")
+
+    # update Method Test
+    try:
+        update_test = "Passed"
+        items.update()
+        items.getName(test_item[1]) # Lets get some info
+    except:
+        update_test = "Failed"
+        failed_list.append("update")
+
+    if (verbose):
+        print("getItem Test: {}".format(getItem_test))
+        print("getName Test: {}".format(getName_test))
+        print("getItemID Test: {}".format(getItemID_test))
+        print("getBuyAverage Test: {}".format(getBuyAverage_test))
+        print("getSellAverage Test: {}".format(getSellAverage_test))
+        print("getBuyQuantity Test: {}".format(getBuyQuantity_test))
+        print("getSellQuantity Test: {}".format(getSellQuantity_test))
+        print("getBuyLimit Test: {}".format(getBuyLimit_test))
+        print("getShopPrice Test: {}".format(getShopPrice_test))
+        print("getLowAlchValue Test: {}".format(getLowAlchValue_test))
+        print("getHighAlchValue Test: {}".format(getHighAlchValue_test))
+        print("isMembers Test: {}".format(isMembers_test))
+        print("update Test: {}".format(update_test))
+
+        # Additional Tests above this comment
+        assert len(failed_list)==0
+        print("\nNumber of Failed Tests: {}".format(len(failed_list)))
+        if failed_list:
+            print("\n\tFailed tests:")
+            for fail in failed_list:
+                print("\t\t{}".format(fail))
+
+        if len(failed_list)==0:
+            print("Test Passed!")
+            return True
+        return False
+    else:
+        if len(failed_list)==0:
+            return True
+        return False