def test_from_json_api(self): rep = { 'browsers': { 'id': '1', 'slug': 'chrome', 'name': { 'en': 'Chrome' }, 'note': None, 'links': { 'history': ['1'], 'history_current': '1', 'versions': ['1'], } }, 'links': { 'browsers.history': { 'href': ('http://example.com/api/v1/historical_browsers/' '{browsers.history}'), 'type': 'historical_browsers' }, 'browsers.history_current': { 'href': ('http://localhost:8000/api/v1/historical_browsers/' '{browsers.history_current}'), 'type': 'historical_browsers' }, 'browsers.versions': { 'href': ('http://localhost:8000/api/v1/versions/' '{browsers.versions}'), 'type': 'versions' } } } browser = Browser() self.assertIsNone(browser.id) self.assertIsNone(browser.slug) self.assertIsNone(browser.name) self.assertIsNone(browser.note) self.assertIsNone(browser.history) self.assertIsNone(browser.history_current) self.assertIsNone(browser.versions) browser.from_json_api(rep) self.assertIsInstance(browser.id, Link) self.assertEqual('1', browser.id.id) self.assertEqual('chrome', browser.slug) self.assertEqual({'en': 'Chrome'}, browser.name) self.assertIsNone(browser.note) self.assertIsInstance(browser.history, LinkList) self.assertEqual(['1'], browser.history.ids) self.assertIsInstance(browser.history_current, Link) self.assertEqual('1', browser.history_current.id) self.assertIsInstance(browser.versions, LinkList) self.assertEqual(['1'], browser.versions.ids)
def test_from_json_api(self): rep = { 'browsers': { 'id': '1', 'slug': 'chrome', 'name': {'en': 'Chrome'}, 'note': None, 'links': { 'history': ['1'], 'history_current': '1', 'versions': ['1'], } }, 'links': { 'browsers.history': { 'href': ( 'http://example.com/api/v1/historical_browsers/' '{browsers.history}'), 'type': 'historical_browsers' }, 'browsers.history_current': { 'href': ( 'http://localhost:8000/api/v1/historical_browsers/' '{browsers.history_current}'), 'type': 'historical_browsers' }, 'browsers.versions': { 'href': ( 'http://localhost:8000/api/v1/versions/' '{browsers.versions}'), 'type': 'versions' } } } browser = Browser() self.assertIsNone(browser.id) self.assertIsNone(browser.slug) self.assertIsNone(browser.name) self.assertIsNone(browser.note) self.assertIsNone(browser.history) self.assertIsNone(browser.history_current) self.assertIsNone(browser.versions) browser.from_json_api(rep) self.assertIsInstance(browser.id, Link) self.assertEqual('1', browser.id.id) self.assertEqual('chrome', browser.slug) self.assertEqual({'en': 'Chrome'}, browser.name) self.assertIsNone(browser.note) self.assertIsInstance(browser.history, LinkList) self.assertEqual(['1'], browser.history.ids) self.assertIsInstance(browser.history_current, Link) self.assertEqual('1', browser.history_current.id) self.assertIsInstance(browser.versions, LinkList) self.assertEqual(['1'], browser.versions.ids)
def test_from_json_api(self): rep = { "browsers": { "id": "1", "slug": "chrome", "name": {"en": "Chrome"}, "note": None, "links": { "history": ["1"], "history_current": "1", "versions": ["1"], } }, "links": { "browsers.history": { "href": ( "http://example.com/api/v1/historical_browsers/" "{browsers.history}"), "type": "historical_browsers" }, "browsers.history_current": { "href": ( "http://localhost:8000/api/v1/historical_browsers/" "{browsers.history_current}"), "type": "historical_browsers" }, "browsers.versions": { "href": ( "http://localhost:8000/api/v1/versions/" "{browsers.versions}"), "type": "versions" } } } browser = Browser() self.assertIsNone(browser.id) self.assertIsNone(browser.slug) self.assertIsNone(browser.name) self.assertIsNone(browser.note) self.assertIsNone(browser.history) self.assertIsNone(browser.history_current) self.assertIsNone(browser.versions) browser.from_json_api(rep) self.assertIsInstance(browser.id, Link) self.assertEqual("1", browser.id.id) self.assertEqual("chrome", browser.slug) self.assertEqual({'en': 'Chrome'}, browser.name) self.assertIsNone(browser.note) self.assertIsInstance(browser.history, LinkList) self.assertEqual(["1"], browser.history.ids) self.assertIsInstance(browser.history_current, Link) self.assertEqual("1", browser.history_current.id) self.assertIsInstance(browser.versions, LinkList) self.assertEqual(["1"], browser.versions.ids)