Skip to content

Commit 4802f74

Browse files
committed
Rename valid_domain to available_domain
valid_domain didn't really make as much sense, since that would be more about the formatting of the domain, but it actually checks formatting and also makes sure that there aren't any records existing for it (that it is available to be registered for a new vhost)
1 parent a502e67 commit 4802f74

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

ocfweb/account/vhost.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from ocfweb.component.session import logged_in_user
2424

2525

26-
def valid_domain(domain):
26+
def available_domain(domain):
2727
if not re.match(r'^[a-zA-Z0-9]+\.berkeley\.edu$', domain):
2828
return False
2929
return not host_exists(domain)
@@ -283,7 +283,7 @@ def clean_requested_subdomain(self):
283283
'Maybe add ".berkeley.edu" to the end?',
284284
)
285285

286-
if not valid_domain(requested_subdomain):
286+
if not available_domain(requested_subdomain):
287287
raise forms.ValidationError(
288288
'The domain you requested is not available. '
289289
'Please select a different one.',

tests/account/vhost_test.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import pytest
22

3-
from ocfweb.account.vhost import valid_domain
3+
from ocfweb.account.vhost import available_domain
44
from ocfweb.account.vhost import valid_domain_external
55

66

77
@pytest.mark.parametrize(
88
'domain,expected', [
9-
# nxdomain
9+
# nxdomain (should be available)
1010
('asdfghjkl.berkeley.edu', True),
1111
('kljasdlgjlsafdfhsadf.berkeley.edu', True),
1212
@@ -37,8 +37,8 @@
3737
('vns;alf iashf poasf bawen svn;', False),
3838
],
3939
)
40-
def test_valid_domain(domain, expected):
41-
assert valid_domain(domain) is expected
40+
def test_available_domain(domain, expected):
41+
assert available_domain(domain) is expected
4242

4343

4444
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)