Commits

Harley Holt committed 7fd7c54

Impleted tests for named award, named good, and named level resources

Comments (0)

Files changed (11)

src/bigdoorkit/client.py

         url = self._abs_from_rel(endpoint)
         par, pay = self._sign_request(method, url, par, pay)
         func = getattr(self.conn, method)
-
+        print url
         if method in ['post', 'put']:
             par['payload'] = pay
 

tests/data/get_currency_4921.json

+[
+    {
+        "end_user_description": "can only be purchased", 
+        "modified_timestamp": 1281659800, 
+        "pub_title": "Coins", 
+        "currency_type_title": "Purchase", 
+        "currency_type_id": 1, 
+        "exchange_rate": "900.00", 
+        "resource_name": "currency", 
+        "urls": [], 
+        "created_timestamp": 1281659800, 
+        "pub_description": "an example of the Purchase currency type", 
+        "end_user_title": "Coins", 
+        "relative_weight": 2, 
+        "id": 4921, 
+        "currency_type_description": null
+    }, 
+    {}
+]

tests/data/get_named_award_7193.json

+[
+    {
+        "end_user_description": "congratulations", 
+        "named_award_collection_id": 1920, 
+        "modified_timestamp": 1282003299, 
+        "pub_title": "obligatory early achievement", 
+        "collection_uri": "/api/publisher/b1bf60c2bf1a4ae298faa4e4b12acbc0/named_award_collection/1920", 
+        "resource_name": "named_award", 
+        "urls": [], 
+        "created_timestamp": 1282003299, 
+        "pub_description": "early achievement", 
+        "end_user_title": "just breath", 
+        "relative_weight": 1, 
+        "id": 7193
+    }, 
+    {}
+]

tests/data/get_named_award_7193.json~

+[
+    {
+        "end_user_description": "congratulations", 
+        "named_award_collection_id": 1920, 
+        "modified_timestamp": 1282003299, 
+        "pub_title": "obligatory early achievement ", 
+        "collection_uri": "/api/publisher/b1bf60c2bf1a4ae298faa4e4b12acbc0/named_award_collection/1920", 
+        "resource_name": "named_award", 
+        "urls": [], 
+        "created_timestamp": 1282003299, 
+        "pub_description": "early achievement", 
+        "end_user_title": "just breath", 
+        "relative_weight": 1, 
+        "id": 7193
+    }, 
+    {}
+]

tests/data/get_named_award_collection.json

+[
+    [
+        {
+            "end_user_description": "things you can get", 
+            "modified_timestamp": 1282003152, 
+            "pub_title": "application achievements", 
+            "named_awards": [
+                {
+                    "end_user_description": "congratulations you rock so hard; keep on breathing", 
+                    "named_award_collection_id": 1920, 
+                    "modified_timestamp": 1282003299, 
+                    "pub_title": "obligatory early achievement ", 
+                    "collection_uri": "/api/publisher/b1bf60c2bf1a4ae298faa4e4b12acbc0/named_award_collection/1920", 
+                    "resource_name": "named_award", 
+                    "urls": [], 
+                    "created_timestamp": 1282003299, 
+                    "pub_description": "the sort of achievement you get when you can turn on an xbox", 
+                    "end_user_title": "just breath", 
+                    "relative_weight": 1, 
+                    "id": 7193
+                }
+            ], 
+            "resource_name": "named_award_collection", 
+            "urls": [], 
+            "created_timestamp": 1282003152, 
+            "pub_description": "a set of achievements that the user can earn", 
+            "end_user_title": "achievements", 
+            "id": 1920
+        }
+    ], 
+    {}
+]

tests/data/get_named_good_6169.json

+[
+    {
+        "end_user_description": "something you can purchase", 
+        "modified_timestamp": 1282003379, 
+        "pub_title": "example good", 
+        "named_good_collection_id": 1237, 
+        "collection_uri": "/api/publisher/b1bf60c2bf1a4ae298faa4e4b12acbc0/named_good_collection/1237", 
+        "resource_name": "named_good", 
+        "urls": [], 
+        "attributes": [], 
+        "created_timestamp": 1282003379, 
+        "pub_description": "something you can purchase", 
+        "end_user_title": "example good", 
+        "relative_weight": 1, 
+        "id": 6169
+    }, 
+    {}
+]

tests/data/get_named_good_collection.json

+[
+    [
+        {
+            "end_user_description": "goods", 
+            "modified_timestamp": 1282003353, 
+            "pub_title": "a bunch of goods the user can get", 
+            "resource_name": "named_good_collection", 
+            "urls": [], 
+            "attributes": [], 
+            "created_timestamp": 1282003353, 
+            "pub_description": "some goods", 
+            "end_user_title": "goods you can get", 
+            "id": 1237, 
+            "named_goods": [
+                {
+                    "end_user_description": "something you can purchase", 
+                    "modified_timestamp": 1282003379, 
+                    "pub_title": "example good", 
+                    "named_good_collection_id": 1237, 
+                    "collection_uri": "/api/publisher/b1bf60c2bf1a4ae298faa4e4b12acbc0/named_good_collection/1237", 
+                    "resource_name": "named_good", 
+                    "urls": [], 
+                    "attributes": [], 
+                    "created_timestamp": 1282003379, 
+                    "pub_description": "something you can purchase", 
+                    "end_user_title": "example good", 
+                    "relative_weight": 1, 
+                    "id": 6169
+                }
+            ]
+        }
+    ], 
+    {}
+]

tests/data/get_named_level_7859.json

+[
+    {
+        "end_user_description": "you don't know jack", 
+        "named_level_collection_id": 2092, 
+        "modified_timestamp": 1281661237, 
+        "pub_title": "level1", 
+        "collection_uri": "/api/publisher/b1bf60c2bf1a4ae298faa4e4b12acbc0/named_level_collection/2092", 
+        "created_timestamp": 1281661237, 
+        "resource_name": "named_level", 
+        "urls": [], 
+        "threshold": 1, 
+        "pub_description": "level1 description", 
+        "end_user_title": "novice", 
+        "id": 7859
+    }, 
+    {}
+]

tests/data/get_named_level_collection.json

             "pub_title": "test title", 
             "named_levels": [
                 {
-                    "end_user_description": "dl1 user description", 
+                    "end_user_description": "you don't know jack", 
                     "named_level_collection_id": 2092, 
                     "modified_timestamp": 1281661237, 
-                    "pub_title": "dl1", 
+                    "pub_title": "level1", 
                     "collection_uri": "/api/publisher/b1bf60c2bf1a4ae298faa4e4b12acbc0/named_level_collection/2092", 
                     "created_timestamp": 1281661237, 
                     "resource_name": "named_level", 
                     "urls": [], 
                     "threshold": 1, 
-                    "pub_description": "dl1 description", 
-                    "end_user_title": "dl1u", 
+                    "pub_description": "level1 description", 
+                    "end_user_title": "novice", 
                     "id": 7859
+                }, 
+                {
+                    "end_user_description": "you kinda know something", 
+                    "named_level_collection_id": 2092, 
+                    "modified_timestamp": 1282003614, 
+                    "pub_title": "level2", 
+                    "collection_uri": "/api/publisher/b1bf60c2bf1a4ae298faa4e4b12acbc0/named_level_collection/2092", 
+                    "created_timestamp": 1282003614, 
+                    "resource_name": "named_level", 
+                    "urls": [], 
+                    "threshold": 20, 
+                    "pub_description": "level2 description", 
+                    "end_user_title": "Neophyte", 
+                    "id": 7928
+                }, 
+                {
+                    "end_user_description": "you rock", 
+                    "named_level_collection_id": 2092, 
+                    "modified_timestamp": 1282003643, 
+                    "pub_title": "level3", 
+                    "collection_uri": "/api/publisher/b1bf60c2bf1a4ae298faa4e4b12acbc0/named_level_collection/2092", 
+                    "created_timestamp": 1282003643, 
+                    "resource_name": "named_level", 
+                    "urls": [], 
+                    "threshold": 100, 
+                    "pub_description": "level3 example", 
+                    "end_user_title": "Expert", 
+                    "id": 7929
                 }
             ], 
-            "currency_id": 4922, 
+            "currency_id": 4920, 
             "resource_name": "named_level_collection", 
             "urls": [], 
             "created_timestamp": 1281661166, 
             "pub_description": "test description", 
             "end_user_title": "test user title", 
-            "id": 1
+            "id": 2092
         }
     ], 
     {}

tests/data/get_named_level_collection_2092.json

+[
+    {
+        "end_user_description": "you must get higher", 
+        "modified_timestamp": 1281661166, 
+        "pub_title": "levels", 
+        "named_levels": [
+            {
+                "end_user_description": "you don't know jack", 
+                "named_level_collection_id": 2092, 
+                "modified_timestamp": 1281661237, 
+                "pub_title": "level1", 
+                "collection_uri": "/api/publisher/b1bf60c2bf1a4ae298faa4e4b12acbc0/named_level_collection/2092", 
+                "created_timestamp": 1281661237, 
+                "resource_name": "named_level", 
+                "urls": [], 
+                "threshold": 1, 
+                "pub_description": "level1 description", 
+                "end_user_title": "novice", 
+                "id": 7859
+            }, 
+            {
+                "end_user_description": "you kinda know something", 
+                "named_level_collection_id": 2092, 
+                "modified_timestamp": 1282003614, 
+                "pub_title": "level2", 
+                "collection_uri": "/api/publisher/b1bf60c2bf1a4ae298faa4e4b12acbc0/named_level_collection/2092", 
+                "created_timestamp": 1282003614, 
+                "resource_name": "named_level", 
+                "urls": [], 
+                "threshold": 20, 
+                "pub_description": "level2 description", 
+                "end_user_title": "Neophyte", 
+                "id": 7928
+            }, 
+            {
+                "end_user_description": "you rock", 
+                "named_level_collection_id": 2092, 
+                "modified_timestamp": 1282003643, 
+                "pub_title": "level3", 
+                "collection_uri": "/api/publisher/b1bf60c2bf1a4ae298faa4e4b12acbc0/named_level_collection/2092", 
+                "created_timestamp": 1282003643, 
+                "resource_name": "named_level", 
+                "urls": [], 
+                "threshold": 100, 
+                "pub_description": "level3 example", 
+                "end_user_title": "Expert", 
+                "id": 7929
+            }
+        ], 
+        "currency_id": 4920, 
+        "resource_name": "named_level_collection", 
+        "urls": [], 
+        "created_timestamp": 1281661166, 
+        "pub_description": "example levels", 
+        "end_user_title": "levels", 
+        "id": 2092
+    }, 
+    {}
+]

tests/test_resource.py

 from nose import SkipTest
 from unittest import TestCase
 
-from tests import *
+from tests import TEST_APP_KEY, TEST_APP_SECRET
 
 from bigdoorkit.client import Client
-from bigdoorkit.resources.level import NamedLevelCollection
+from bigdoorkit.resources.level import NamedLevelCollection, NamedLevel
+from bigdoorkit.resources.award import NamedAwardCollection, NamedAward
+from bigdoorkit.resources.good import NamedGoodCollection, NamedGood
 
 class TestNamedLevelCollection(TestCase):
 
     def setUp(self):
         self.client = Client(TEST_APP_SECRET, TEST_APP_KEY)
 
-    def test_get_no_params(self):
+    def test_get(self):
         """ test of getting a list of named level collections """
 
         named_level_collections = NamedLevelCollection.all(self.client)
         assert_equal(nlc.pub_description, 'test description')
         assert_equal(nlc.end_user_title, 'test user title')
         assert_equal(nlc.end_user_description, 'test user description')
-        assert_equal(nlc.currency_id, 4922)
+        assert_equal(nlc.currency_id, 4920)
+
+class TestNamedLevel(TestCase):
+
+    def setUp(self):
+        self.client = Client(TEST_APP_SECRET, TEST_APP_KEY)
+        
+    def test_get(self):
+        named_level = NamedLevel.get(7859, self.client)
+        assert named_level
+        assert named_level.named_level_collection_id
+        assert_equal(named_level.named_level_collection_id, 2092)
+
+class TestNamedAward(TestCase):
+
+    def setUp(self):
+        self.client = Client(TEST_APP_SECRET, TEST_APP_KEY)
+
+    def test_get(self):
+        
+        named_award = NamedAward.get(7193, self.client)
+        assert named_award.named_award_collection_id
+        assert_equal(named_award.named_award_collection_id, 1920)
+        assert_equal(named_award.pub_title, 'obligatory early achievement')
+        assert_equal(named_award.pub_description, 'early achievement')
+        assert_equal(named_award.end_user_title, 'just breath')
+        assert_equal(named_award.end_user_description, 'congratulations')
+        assert_equal(named_award.id, 7193)
+
+class TestNamedAwardCollection(TestCase):
+
+    def setUp(self):
+        self.client = Client(TEST_APP_SECRET, TEST_APP_KEY)
+
+    
+    def test_all(self):
+
+        nac = NamedAwardCollection.all(self.client)
+        assert nac
+        assert len(nac) == 1
+        nac = nac[0]
+        assert_equal(nac.pub_title, 'application achievements')
+        assert_equal(nac.pub_description, 'a set of achievements that the '+\
+                        'user can earn')
+        assert_equal(nac.end_user_title, 'achievements')
+        assert_equal(nac.end_user_description, 'things you can get')
+        assert_equal(nac.id, 1920)
+
+class TestNamedGood(TestCase):
+
+    def setUp(self):
+        self.client = Client(TEST_APP_SECRET, TEST_APP_KEY)
+
+    def test_get(self):
+
+        ng = NamedGood.get(6169, self.client)
+        assert ng
+        assert_equal(ng.pub_title, 'example good')
+        assert_equal(ng.pub_description, 'something you can purchase')
+        assert_equal(ng.end_user_title, 'example good')
+        assert_equal(ng.end_user_description, 'something you can purchase')
+        assert_equal(ng.id, 6169)
+        assert_equal(ng.id, 6169)