Skip to content

Commit

Permalink
Update tests to label providers as update
Browse files Browse the repository at this point in the history
Also support organisations that do not offer
hosted services
  • Loading branch information
mrchrisadams committed Jun 15, 2023
1 parent b8f3aeb commit f9ffc2e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/accounts/models/provider_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ def approve(self) -> Hostingprovider:

# set services (https://django-taggit.readthedocs.io/en/latest/api.html)
hp.services.set(list(self.services.all()))
hp.staff_labels.add("up-to-date")

# we use the tag with the slug "other-none" for
# organisations that we would need to recognise as
# using green energy, but who do not offer hosted services
if "other-none" in hp.services.slugs():
hp.showonwebsite = False
else:
hp.showonwebsite = True

hp.save()

# set user
Expand Down
32 changes: 32 additions & 0 deletions apps/accounts/tests/test_provider_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,38 @@ def test_approve_creates_hosting_provider(db):
assert hp.website == pr.website
assert hp.request == pr

# provider is visible by default
# appropriate tag is added
assert hp.showonwebsite is True
assert "up-to-date" in hp.staff_labels.slugs()
# "other-none" is the label condition check for
# when someone is just trying to get a site marked
# as green when they don't offer hosted services
assert "other-none" not in hp.services.slugs()


def test_approve_supports_orgs_not_offering_hosted_services(db):
# given: a verification request for an organisation that does
# not offer any services, but we still want ot recognise as green
other_none_service = ServiceFactory(
slug="other-none",
name="Other: we do not offer any of these services",
)
pr = ProviderRequestFactory.create(services=[other_none_service])

ProviderRequestLocationFactory.create(request=pr)
ProviderRequestEvidenceFactory.create(request=pr)

# when: the request is approved
result = pr.approve()
hp = models.Hostingprovider.objects.get(id=result.id)

# provider is visible by default
# appropriate labels and services are listed
assert hp.showonwebsite is False
assert "up-to-date" in hp.staff_labels.slugs()
assert "other-none" in hp.services.slugs()


def test_approve_creates_ip_ranges(db):
# given: a provider request with multiple IP ranges
Expand Down

0 comments on commit f9ffc2e

Please sign in to comment.