Beispiel #1
0
    def test_barrier_completion_percentage_changed_commodity_only(self):
        barrier = Barrier()
        barrier.save()

        barrier.commodities.set((CommodityFactory(code="010410"), ))
        barrier.save()

        barrier_completion_percentage_changed(sender=Barrier, instance=barrier)

        barrier.refresh_from_db()

        assert barrier.completion_percent == 16
    def setUp(self):
        super().setUp()

        self.user = User.objects.create_user("foo", "*****@*****.**", "bar")
        self.user.profile.sso_user_id = self.mock_uuids["1"]
        self.user.profile.save()
        self.user2 = User.objects.create_user("foo2", "*****@*****.**",
                                              "bar2")
        self.user2.profile.sso_user_id = self.mock_uuids["2"]
        self.user2.profile.save()
        self.user3 = User.objects.create_user("foo3", "*****@*****.**",
                                              "bar3")
        self.user3.profile.sso_user_id = self.mock_uuids["3"]
        self.user3.profile.save()

        self.mock_barrier = Barrier()
        self.mock_barrier.code = "example code"
        self.mock_barrier.title = "example title"
        self.mock_barrier.created_by = self.user
        self.mock_barrier.save()
Beispiel #3
0
    def test_barrier_completion_percentage_changed_category_only(self):
        barrier = Barrier()
        barrier.save()

        category = CategoryFactory()
        barrier.categories.add(category)
        barrier.save()

        barrier_completion_percentage_changed(sender=Barrier, instance=barrier)

        barrier.refresh_from_db()

        assert barrier.completion_percent == 16
Beispiel #4
0
    def test_barrier_completion_percentage_changed_sector_only(self):
        barrier = Barrier()
        barrier.sectors = ["75debee7-a182-410e-bde0-3098e4f7b822"]
        barrier.save()

        barrier_completion_percentage_changed(sender=Barrier, instance=barrier)

        barrier.refresh_from_db()

        assert barrier.completion_percent == 16
Beispiel #5
0
    def test_barrier_completion_percentage_changed_source_only(self):
        barrier = Barrier()
        barrier.source = "Ketchup"
        barrier.save()

        barrier_completion_percentage_changed(sender=Barrier, instance=barrier)

        barrier.refresh_from_db()

        assert barrier.completion_percent == 16
Beispiel #6
0
    def test_barrier_completion_percentage_changed_summary_only(self):
        barrier = Barrier()
        barrier.summary = "This... Is... A SUMMARY!"
        barrier.save()

        barrier_completion_percentage_changed(sender=Barrier, instance=barrier)

        barrier.refresh_from_db()

        assert barrier.completion_percent == 18
Beispiel #7
0
    def test_barrier_completion_percentage_changed_location_only(self):
        barrier = Barrier()
        barrier.country = "a05f66a0-5d95-e211-a939-e4115bead28a"
        barrier.save()

        barrier_completion_percentage_changed(sender=Barrier, instance=barrier)

        barrier.refresh_from_db()

        assert barrier.completion_percent == 18
Beispiel #8
0
    def test_barrier_completion_percentage_changed_none(self):
        barrier = Barrier()
        barrier.save()

        barrier.refresh_from_db()

        barrier_completion_percentage_changed(sender=Barrier, instance=barrier)

        assert barrier.completion_percent == 0