Example #1
0
 def test_encoder(self):
     dict_ = json.loads(json.dumps(self.dict_))
     self.assertEquals(self.dict_, dict_)
Example #2
0
simple_resource = dict(type='simple')
has_simple = dict(type='has_simple', simple=simple_resource)
github_dict = dict(
    id=1,
    name='name_test',
    date='2008-01-14T04:33:35Z',
    simple=simple_resource,
    list_collection=[has_simple] * 2,
    items_collections=dict(arg1=has_simple, arg2=has_simple)
)
github_dict_nested = github_dict.copy()
github_dict.update({'self_nested': github_dict_nested})
github_dict.update({'self_nested_list': [github_dict_nested] * 2})
github_dict.update({'self_nested_dict': dict(arg1=github_dict_nested)})
github_return = json.dumps(github_dict)


class TestResourceMapping(TestCase):

    def setUp(self):
        self.r = Nested.loads(github_return)

    def test_attrs_map(self):
        self.assertEqual(self.r.id, 1)
        self.assertEqual(self.r.name, 'name_test')
        self.assertEqual(self.r.date, datetime(2008, 1, 14, 4, 33, 35))

    def test_MAPS(self):
        self.assertIsInstance(self.r.simple, Simple)
        self.assertEqual(self.r.simple.type, 'simple')
Example #3
0
 def dumps(self):
     if not self.schema:
         return self.content or None
     return json.dumps(self.parse())
Example #4
0
 def test_encoder(self):
     to_json = json.dumps(self.dict_)
     self.assertEquals(to_json, self.json_)
Example #5
0
 def test_encoder(self):
     to_json = json.dumps(self.dict_)
     self.assertEquals(to_json, self.json_)
Example #6
0
 def dumps(self):
     if not self.schema:
         return self.content or None
     return json.dumps(self.parse())
Example #7
0
from pygithub3.tests.utils.core import TestCase
from pygithub3.tests.utils.resources import Nested, Simple, HasSimple

simple_resource = dict(type='simple')
has_simple = dict(type='has_simple', simple=simple_resource)
github_dict = dict(id=1,
                   name='name_test',
                   date='2008-01-14T04:33:35Z',
                   simple=simple_resource,
                   list_collection=[has_simple] * 2,
                   items_collections=dict(arg1=has_simple, arg2=has_simple))
github_dict_nested = github_dict.copy()
github_dict.update({'self_nested': github_dict_nested})
github_dict.update({'self_nested_list': [github_dict_nested] * 2})
github_dict.update({'self_nested_dict': dict(arg1=github_dict_nested)})
github_return = json.dumps(github_dict)


class TestResourceMapping(TestCase):
    def setUp(self):
        self.r = Nested.loads(github_return)

    def test_attrs_map(self):
        self.assertEqual(self.r.id, 1)
        self.assertEqual(self.r.name, 'name_test')
        self.assertEqual(self.r.date, datetime(2008, 1, 14, 4, 33, 35))

    def test_MAPS(self):
        self.assertIsInstance(self.r.simple, Simple)
        self.assertEqual(self.r.simple.type, 'simple')