コード例 #1
0
    def test_limit_to_plan_version_id(self):
        plan_to_update = SoftwarePlan(name='Plan To Update')
        plan_to_update.save()
        version_to_update = SoftwarePlanVersion(
            role=self.old_role,
            plan=plan_to_update,
            product_rate=self.generic_product_rate)
        version_to_update.save()

        plan_to_ignore = SoftwarePlan(name='Plan To Ignore')
        plan_to_ignore.save()
        version_to_ignore = SoftwarePlanVersion(
            role=self.old_role,
            plan=plan_to_ignore,
            product_rate=self.generic_product_rate)
        version_to_ignore.save()

        change_role_for_software_plan_version(
            'old_role',
            'new_role',
            limit_to_plan_version_id=version_to_update.id)

        # refetch
        plan_to_update = SoftwarePlan.objects.get(name='Plan To Update')
        plan_to_ignore = SoftwarePlan.objects.get(name='Plan To Ignore')
        self.assertEqual(plan_to_update.get_version().role.slug, 'new_role')
        self.assertEqual(plan_to_ignore.get_version().role.slug, 'old_role')
コード例 #2
0
    def test_changes_inactive_versions(self):
        plan = SoftwarePlan(name='Test Plan')
        plan.save()
        inactive_version = SoftwarePlanVersion(
            role=self.old_role,
            plan=plan,
            product_rate=self.generic_product_rate,
            is_active=False,
        )
        inactive_version.save()
        self.assertEqual(inactive_version.version, 1)

        active_role = Role.objects.create(slug='active_role', name='active')
        active_version = SoftwarePlanVersion(
            role=active_role,
            plan=plan,
            product_rate=self.generic_product_rate)
        active_version.save()

        change_role_for_software_plan_version('old_role', 'new_role')

        # refetch
        plan = SoftwarePlan.objects.get(name='Test Plan')
        # ensure software plan's active version is still the active role
        self.assertEqual(plan.get_version().role.slug, 'active_role')
        inactive_version = plan.softwareplanversion_set.filter(
            is_active=False).latest('date_created')
        # ensure the inactive plan version was updated to the new role
        self.assertEqual(inactive_version.role.slug, 'new_role')
コード例 #3
0
    def test_changes_active_versions(self):
        plan = SoftwarePlan(name='Test Plan')
        plan.save()
        active_version = SoftwarePlanVersion(
            role=self.old_role,
            plan=plan,
            product_rate=self.generic_product_rate,
            is_active=True)
        active_version.save()
        self.assertEqual(active_version.version, 1)

        change_role_for_software_plan_version('old_role', 'new_role')

        # refetch
        plan = SoftwarePlan.objects.get(name='Test Plan')
        self.assertEqual(plan.get_version().version, 1)
        self.assertEqual(plan.get_version().role.slug, 'new_role')
コード例 #4
0
    def test_dry_run(self):
        plan = SoftwarePlan(name='Test Plan')
        plan.save()
        version = SoftwarePlanVersion(role=self.old_role,
                                      plan=plan,
                                      product_rate=self.generic_product_rate)
        version.save()

        change_role_for_software_plan_version('old_role',
                                              'new_role',
                                              dry_run=True)

        # refetch
        plan = SoftwarePlan.objects.get(name='Test Plan')
        self.assertEqual(plan.get_version().role.slug, 'old_role')