def create_root(self, author, env): if self.get_env_root(env) < 0: root = Value() root.name = env root.active = True root.author = author root.first_last = True root.override = '' root.protect = False root.parent = -1 root.save() return root.id return False
def test_update_value(api_client): """ checks if update is successful """ value_one = Value(title="Value #1", text="Description #1") value_one.save() path = reverse("value-detail", kwargs={"pk": value_one.pk}) response = api_client.get(path) assert response.status_code == status.HTTP_200_OK data = response.json() data["title"] = "New title" data["text"] = "New text" response = api_client.put(path, data=data, format="json") assert response.status_code == status.HTTP_200_OK value_one.refresh_from_db() assert value_one.title == data["title"] assert value_one.text == data["text"]
def create(self, user, parent, name, value, override=''): create = Value() create.active = True create.parent = parent create.protect = False create.author = user create.name = name create.entry = value create.override = override create.first_last = True create.save() return create.id
def test_value_save(self): val = Value() val.active = True val.author = 'test_user' val.first_last = True val.name = 'test value' val.entry = '' val.override = '' val.parent = 1 val.protect = False val.save() self.assertEqual(val.pk, val.id) self.assertIsNotNone(val.datetime)