Esempio n. 1
0
    def test_public_view_status_history(self):
        self.barrier.public_eligibility = True
        self.barrier.public_eligibility_summary = "Allowed summary"
        self.barrier.save()
        self.public_barrier.public_view_status = PublicBarrierStatus.ELIGIBLE
        self.public_barrier.save()

        items = PublicBarrierHistoryFactory.get_history_items(
            barrier_id=self.barrier.pk
        )
        data = items[-1].data

        assert data["model"] == "public_barrier"
        assert data["field"] == "public_view_status"
        assert data["old_value"] == {
            "public_view_status": {
                "id": PublicBarrierStatus.UNKNOWN,
                "name": PublicBarrierStatus.choices[PublicBarrierStatus.UNKNOWN],
            },
            "public_eligibility": None,
            "public_eligibility_summary": "",
        }
        assert data["new_value"] == {
            "public_view_status": {
                "id": PublicBarrierStatus.ELIGIBLE,
                "name": PublicBarrierStatus.choices[PublicBarrierStatus.ELIGIBLE],
            },
            "public_eligibility": True,
            "public_eligibility_summary": "Allowed summary",
        }
Esempio n. 2
0
    def test_categories_history(self):
        self.public_barrier.categories.add("109", "115")

        items = PublicBarrierHistoryFactory.get_history_items(
            barrier_id=self.barrier.pk)
        data = items[-1].data

        assert data["model"] == "public_barrier"
        assert data["field"] == "categories"
        assert data["old_value"] == []
        assert set(data["new_value"]) == {"109", "115"}
Esempio n. 3
0
    def test_title_history(self):
        self.public_barrier.title = "New title"
        self.public_barrier.save()

        items = PublicBarrierHistoryFactory.get_history_items(
            barrier_id=self.barrier.pk)
        data = items[-1].data

        assert data["model"] == "public_barrier"
        assert data["field"] == "title"
        assert data["old_value"] == ""
        assert data["new_value"] == "New title"
Esempio n. 4
0
    def test_location_history(self):
        self.public_barrier.country = "e0f682ac-5d95-e211-a939-e4115bead28a"
        self.public_barrier.save()

        items = PublicBarrierHistoryFactory.get_history_items(
            barrier_id=self.barrier.pk)
        data = items[-1].data

        assert data["model"] == "public_barrier"
        assert data["field"] == "location"
        assert data["old_value"] == "France"
        assert data["new_value"] == "Georgia"
Esempio n. 5
0
    def test_sectors_history(self):
        self.public_barrier.sectors = ["9538cecc-5f95-e211-a939-e4115bead28a"]
        self.public_barrier.save()

        items = PublicBarrierHistoryFactory.get_history_items(
            barrier_id=self.barrier.pk
        )
        data = items[-1].data

        assert data["model"] == "public_barrier"
        assert data["field"] == "sectors"
        assert data["old_value"]["sectors"] == [
            "af959812-6095-e211-a939-e4115bead28a",
            "9538cecc-5f95-e211-a939-e4115bead28a",
        ]
        assert data["new_value"]["sectors"] == ["9538cecc-5f95-e211-a939-e4115bead28a"]
Esempio n. 6
0
    def test_status_history(self):
        self.public_barrier.status = 4
        self.public_barrier.status_date = datetime.date(2020, 5, 1)
        self.public_barrier.save()

        items = PublicBarrierHistoryFactory.get_history_items(
            barrier_id=self.barrier.pk)
        data = items[-1].data

        assert data["model"] == "public_barrier"
        assert data["field"] == "status"
        assert data["old_value"] == {
            "status": "1",
            "status_date": self.barrier.status_date,
            "is_resolved": False,
        }
        assert data["new_value"] == {
            "status": "4",
            "status_date": datetime.date(2020, 5, 1),
            "is_resolved": True,
        }