def test_append_to_synonyms_entire_dataset(self):
        """ Update by passing the entire dataset to the API"""

        data = PropertyTemplate(
            "First Name",
            "firstname",
            "administrative",
            "The first name of a person",
            synonyms=["forename"],
        )

        res = requests.post(url=self.url, json=data.to_dict())
        self.assertEqual(res.status_code, 201)

        # Update the entry
        data.synonyms = ["forename", "given name"]

        entry_id = res.json()["id"]
        url_id = self.url + f"/id/{entry_id}"

        res = requests.put(url=url_id, json=data.to_dict())
        self.assertEqual(res.status_code, 200)

        res = requests.get(url=url_id)
        self.assertEqual(res.status_code, 200)
        self.assertEqual(res.json()["synonyms"], ["forename", "given name"])
    def test_append_to_synonyms_partial(self):
        """ Updating by just passing the key-value pair which changed"""

        data = PropertyTemplate(
            "First Name",
            "firstname",
            "administrative",
            "The first name of a person",
            synonyms=["forename"],
        )

        res = requests.post(url=self.url, json=data.to_dict())
        self.assertEqual(res.status_code, 201)

        # Only change the attribute
        update = {"synonyms": ["forename", "given name"]}

        entry_id = res.json()["id"]
        url_id = self.url + f"/id/{entry_id}"

        res = requests.put(url=url_id, json=update)
        self.assertEqual(res.status_code, 200)

        res = requests.get(url=url_id)
        self.assertEqual(res.status_code, 200)
        self.assertEqual(res.json()["synonyms"], ["forename", "given name"])
    def test_post_property_cv(self):
        """ Insert property with vocabulary other than cv"""

        data = PropertyTemplate("string", "string", "string", "string")

        res = requests.post(url=self.url, json=data.to_dict())
        self.assertEqual(res.status_code, 201)
Beispiel #4
0
    def test_post_property_cv_reference(self):
        """ Insert property with correct cv """

        data = PropertyTemplate("string", "string", "string", "string",
                                ValueTypeTemplate("ctrl_voc",
                                                  ControlledVocabularyTemplate("Test CV", "Test CV", "Test CV")
                                                  .add_item(ItemTemplate("test 1", "test 1", "First item"))
                                                  .add_item(ItemTemplate("test 2", "test 2", "First item"))))

        res = requests.post(url=self.url, json=data.to_dict())
        self.assertEqual(res.status_code, 201)