def test_parse_data(self): act = Activity({"id": 5, "verb": "post", \ "actor": {"objectType": "actor", "id": 1232, "published": '2012-07-05T12:00:00Z'}, \ "target": {"objectType": "target", "id": 4325, "published": '2012-07-05T12:00:00Z'}, \ "object": {"objectType": "something", "id": 4353, "published": '2012-07-05T12:00:00Z'}, "icon": {'url': "http://example.org/something"}}, backend=MagicMock()) act_dict = act.parse_data(act._dict) eq_( { 'target': { 'objectType': 'target', 'id': 4325, 'published': '2012-07-05T12:00:00Z' }, 'object': { 'objectType': 'something', 'id': 4353, 'published': '2012-07-05T12:00:00Z' }, 'actor': { 'objectType': 'actor', 'id': 1232, 'published': '2012-07-05T12:00:00Z' }, 'verb': 'post', 'id': '5', 'icon': { 'url': 'http://example.org/something' } }, act_dict)
def test_parse_data_with_audience_targeting(self): act = Activity({ 'id': '4213', 'to': [{'objectType': 'user1', 'id': 'user:id:1', 'published': '2012-07-05T12:00:00Z'}, {'objectType': 'user2', 'id': 'user:id:2', 'published': '2012-07-05T12:00:00Z'}], 'bto': [{'objectType': 'user3', 'id': 'user:id:3', 'published': '2012-07-05T12:00:00Z'}, {'objectType': 'user4', 'id': 'user:id:4', 'published': '2012-07-05T12:00:00Z'}, {'objectType': 'user5', 'id': 'user:id:5', 'published': '2012-07-05T12:00:00Z'}], 'cc': [{'objectType': 'user6', 'id': 'user:id:6', 'published': '2012-07-05T12:00:00Z'}], 'bcc': [], }, backend=MagicMock()) act_dict = act.parse_data(act._dict) eq_({ 'cc': [{'published': '2012-07-05T12:00:00Z', 'id': 'user:id:6', 'objectType': 'user6'}], 'bcc': [], 'to': [{'published': '2012-07-05T12:00:00Z', 'id': 'user:id:1', 'objectType': 'user1'}, {'published': '2012-07-05T12:00:00Z', 'id': 'user:id:2', 'objectType': 'user2'}], 'bto': [{'published': '2012-07-05T12:00:00Z', 'id': 'user:id:3', 'objectType': 'user3'}, {'published': '2012-07-05T12:00:00Z', 'id': 'user:id:4', 'objectType': 'user4'}, {'published': '2012-07-05T12:00:00Z', 'id': 'user:id:5', 'objectType': 'user5'}], 'id': '4213' }, act_dict)
def test_parse_data(self): act = Activity({"id": 5, "verb": "post", \ "actor": {"objectType": "actor", "id": 1232, "published": '2012-07-05T12:00:00Z'}, \ "target": {"objectType": "target", "id": 4325, "published": '2012-07-05T12:00:00Z'}, \ "object": {"objectType": "something", "id": 4353, "published": '2012-07-05T12:00:00Z'}, "icon": {'url': "http://example.org/something"}}, backend=MagicMock()) act_dict = act.parse_data(act._dict) eq_({ 'target': {'objectType': 'target', 'id': 4325, 'published': '2012-07-05T12:00:00Z'}, 'object': {'objectType': 'something', 'id': 4353, 'published': '2012-07-05T12:00:00Z'}, 'actor': {'objectType': 'actor', 'id': 1232, 'published': '2012-07-05T12:00:00Z'}, 'verb': 'post', 'id': '5', 'icon': {'url': 'http://example.org/something'} }, act_dict)
def test_parse_data_with_audience_targeting(self): act = Activity( { 'id': '4213', 'to': [{ 'objectType': 'user1', 'id': 'user:id:1', 'published': '2012-07-05T12:00:00Z' }, { 'objectType': 'user2', 'id': 'user:id:2', 'published': '2012-07-05T12:00:00Z' }], 'bto': [{ 'objectType': 'user3', 'id': 'user:id:3', 'published': '2012-07-05T12:00:00Z' }, { 'objectType': 'user4', 'id': 'user:id:4', 'published': '2012-07-05T12:00:00Z' }, { 'objectType': 'user5', 'id': 'user:id:5', 'published': '2012-07-05T12:00:00Z' }], 'cc': [{ 'objectType': 'user6', 'id': 'user:id:6', 'published': '2012-07-05T12:00:00Z' }], 'bcc': [], }, backend=MagicMock()) act_dict = act.parse_data(act._dict) eq_( { 'cc': [{ 'published': '2012-07-05T12:00:00Z', 'id': 'user:id:6', 'objectType': 'user6' }], 'bcc': [], 'to': [{ 'published': '2012-07-05T12:00:00Z', 'id': 'user:id:1', 'objectType': 'user1' }, { 'published': '2012-07-05T12:00:00Z', 'id': 'user:id:2', 'objectType': 'user2' }], 'bto': [{ 'published': '2012-07-05T12:00:00Z', 'id': 'user:id:3', 'objectType': 'user3' }, { 'published': '2012-07-05T12:00:00Z', 'id': 'user:id:4', 'objectType': 'user4' }, { 'published': '2012-07-05T12:00:00Z', 'id': 'user:id:5', 'objectType': 'user5' }], 'id': '4213' }, act_dict)