Esempio n. 1
0
 def test_value_overriding(self):
     obj = {'foo': 'FOO', 'bar': 'BAR'}
     s = jsonobject.parse(obj)
     assert s.foo == u'FOO'
     assert s.bar == u'BAR'
     assert s.json(sort_keys=True) == '{"bar": "BAR", "foo": "FOO"}'
     # With parse, you can override some values.
     t = jsonobject.parse(obj, bar='BARBAR')
     assert t.foo == u'FOO'
     assert t.bar == u'BARBAR'
     assert t.json(sort_keys=True) == '{"bar": "BARBAR", "foo": "FOO"}'
     # If no value available in the input object, a new property will be
     # created (no exception thrown).
     u = jsonobject.parse(obj, baz='BAZ')
     assert u.foo == u'FOO'
     assert u.bar == u'BAR'
     assert u.baz == u'BAZ'
     assert u.json(sort_keys=True) == ('{"bar": "BAR", "baz": "BAZ", '
                                       '"foo": "FOO"}')
Esempio n. 2
0
 def test_value_overriding(self):
     obj = {'foo': 'FOO', 'bar': 'BAR'}
     s = jsonobject.parse(obj)
     assert s.foo == u'FOO'
     assert s.bar == u'BAR'
     assert s.json(sort_keys=True) == '{"bar": "BAR", "foo": "FOO"}'
     # With parse, you can override some values.
     t = jsonobject.parse(obj, bar='BARBAR')
     assert t.foo == u'FOO'
     assert t.bar == u'BARBAR'
     assert t.json(sort_keys=True) == '{"bar": "BARBAR", "foo": "FOO"}'
     # If no value available in the input object, a new property will be
     # created (no exception thrown).
     u = jsonobject.parse(obj, baz='BAZ')
     assert u.foo == u'FOO'
     assert u.bar == u'BAR'
     assert u.baz == u'BAZ'
     assert u.json(sort_keys=True) == ('{"bar": "BAR", "baz": "BAZ", '
                                       '"foo": "FOO"}')
Esempio n. 3
0
 def test_update_ship2(self, ship_defs, ship_data):
     response = jsonobject.parse({'api_data': [ship_data]})
     ship_list = ship.ShipList()
     ship_list.update('/api_get_member/ship2', None, response,
                      {'ShipDefinitionList': ship_defs}, False)
     assert '1' in ship_list.ships
     ship_ = ship_list.ships['1']
     assert ship_.id == 1
     assert ship_.name == u'Ship 1001'
     assert ship_.level == 2
     assert ship_.hitpoint.current == 3
     assert ship_.hitpoint.maximum == 4
     assert ship_.upgrade_to == 1002