def test_update_membership_serializer(self): data = { "label": "sweemeng land lubber" } membership = Membership.objects.untranslated().get(id="0a44195b-c3c9-4040-8dbf-be1aa250b700") serializer = MembershipSerializer(membership, data=data, partial=True, language="en") serializer.is_valid() self.assertEqual(serializer.errors, {}) serializer.save() membership = Membership.objects.language("en").get(id="0a44195b-c3c9-4040-8dbf-be1aa250b700") self.assertEqual(membership.label, "sweemeng land lubber")
def test_create_membership_with_post_serializer(self): data = { "label": "test membership", "person_id":"8497ba86-7485-42d2-9596-2ab14520f1f4", "post_id": "c1f0f86b-a491-4986-b48d-861b58a3ef6e" } serializer = MembershipSerializer(data=data, language="en") serializer.is_valid() self.assertEqual(serializer.errors, {}) serializer.save() membership = Membership.objects.language("en").get(label="test membership") self.assertEqual(membership.person_id, "8497ba86-7485-42d2-9596-2ab14520f1f4")
def test_update_membership_on_behalf_of(self): data = { "on_behalf_of_id": "612943b1-864d-4188-8d79-ca387ed19b32" } membership = Membership.objects.untranslated().get(id="7185cab2521c4f6db18b40d8d6506d36") serializer = MembershipSerializer(membership, language="en", data=data, partial=True) serializer.is_valid() self.assertEqual(serializer.errors, {}) serializer.save() membership = Membership.objects.language("en").get(id="7185cab2521c4f6db18b40d8d6506d36") self.assertEqual(membership.on_behalf_of_id, "612943b1-864d-4188-8d79-ca387ed19b32") self.assertEqual(membership.on_behalf_of.id, "612943b1-864d-4188-8d79-ca387ed19b32")
def test_create_membership_with_organization_serializer(self): data = { "label": "test membership", "person_id":"8497ba86-7485-42d2-9596-2ab14520f1f4", "organization_id": "e4e9fcbf-cccf-44ff-acf6-1c5971ec85ec" } serializer = MembershipSerializer(data=data, language="en") serializer.is_valid() self.assertEqual(serializer.errors, {}) serializer.save() membership = Membership.objects.language("en").get(label="test membership") self.assertEqual(membership.person_id, "8497ba86-7485-42d2-9596-2ab14520f1f4")
def test_update_membership_unauthorized_translated(self): data = { "label": "sweemeng adalah land lubber" } membership = Membership.objects.untranslated().get(id="0a44195b-c3c9-4040-8dbf-be1aa250b700") logging.warn(membership.get_available_languages()) serializer = MembershipSerializer(membership, data=data, partial=True, language="ms") serializer.is_valid() self.assertEqual(serializer.errors, {}) serializer.save() membership = Membership.objects.language("ms").get(id="0a44195b-c3c9-4040-8dbf-be1aa250b700") self.assertEqual(membership.label, "sweemeng adalah land lubber")
def test_create_membership_on_behalf_of(self): data = { "label": "test membership", "person_id": "8497ba86-7485-42d2-9596-2ab14520f1f4", "organization_id": "e4e9fcbf-cccf-44ff-acf6-1c5971ec85ec", "on_behalf_of_id": "612943b1-864d-4188-8d79-ca387ed19b32" } serializer = MembershipSerializer(data=data, language="en") serializer.is_valid() self.assertEqual(serializer.errors, {}) serializer.save() membership = Membership.objects.language("en").get(label="test membership") self.assertEqual(membership.on_behalf_of_id, "612943b1-864d-4188-8d79-ca387ed19b32")
def test_update_membership_update_link_serializer(self): data = { "links": [ { "id": "239edef4-af68-4ffb-adce-96d17cbea79d", "label": "Captain's page" } ] } membership = Membership.objects.untranslated().get(id="b351cdc2-6961-4fc7-9d61-08fca66e1d44") serializer = MembershipSerializer(membership, data=data, partial=True, language="en") serializer.is_valid() self.assertEqual(serializer.errors, {}) serializer.save() link = Link.objects.language("en").get(id="239edef4-af68-4ffb-adce-96d17cbea79d") self.assertEqual(link.label, "Captain's page")
def test_update_membership_create_link_serializer(self): data = { "links": [ { "url": "http://thecaptain.tumblr.com", "label": "Captain's Tumblr" } ] } membership = Membership.objects.untranslated().get(id="b351cdc2-6961-4fc7-9d61-08fca66e1d44") serializer = MembershipSerializer(membership, data=data, partial=True, language="en") serializer.is_valid() self.assertEqual(serializer.errors, {}) serializer.save() link = Link.objects.language("en").get(label="Captain's Tumblr") self.assertEqual(link.url, "http://thecaptain.tumblr.com")
def test_update_membership_update_contact_serializer(self): data = { "contact_details": [ { "id": "78a35135-52e3-4af9-8c32-ea3f557354fd", "label": "captain's email" } ] } membership = Membership.objects.untranslated().get(id="b351cdc2-6961-4fc7-9d61-08fca66e1d44") serializer = MembershipSerializer(membership, data=data, partial=True, language="en") serializer.is_valid() self.assertEqual(serializer.errors, {}) serializer.save() contact = ContactDetail.objects.language("en").get(id="78a35135-52e3-4af9-8c32-ea3f557354fd") self.assertEqual(contact.label, "captain's email")
def test_update_membership_create_contact_serializer(self): data = { "contact_details": [ { "type": "phone", "value": "755-2525", "label": "captain's phone" } ] } membership = Membership.objects.untranslated().get(id="b351cdc2-6961-4fc7-9d61-08fca66e1d44") serializer = MembershipSerializer(membership, data=data, partial=True, language="en") serializer.is_valid() self.assertEqual(serializer.errors, {}) serializer.save() contact = ContactDetail.objects.language("en").get(label="captain's phone") self.assertEqual(contact.label, "captain's phone")
def test_update_membership_contact_citation_serializer(self): data = { "contact_details": [ { "id": "78a35135-52e3-4af9-8c32-ea3f557354fd", "links": [ { "id": "adebb549-e7a0-4ba6-a9ff-60eb2656c15b", "label": "contact link" } ] } ] } membership = Membership.objects.untranslated().get(id="b351cdc2-6961-4fc7-9d61-08fca66e1d44") serializer = MembershipSerializer(membership, data=data, partial=True, language="en") serializer.is_valid() self.assertEqual(serializer.errors, {}) serializer.save() contacts = membership.contact_details.language('en').get(id="78a35135-52e3-4af9-8c32-ea3f557354fd") link = contacts.links.language("en").get(id="adebb549-e7a0-4ba6-a9ff-60eb2656c15b") self.assertEqual(link.label, "contact link")