8000 start using webapp on djangoproject, add __eq__ · pythonanywhere/helper_scripts@cbbb2b2 · GitHub
[go: up one dir, main page]

Skip to content

Commit cbbb2b2

Browse files
committed
start using webapp on djangoproject, add __eq__
1 parent 8f1b4d9 commit cbbb2b2

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

pythonanywhere/api.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ def __init__(self, domain):
4444
self.domain = domain
4545

4646

47+
def __eq__(self, other):
48+
return self.domain == other.domain
49+
50+
4751
def sanity_checks(self, nuke):
4852
print(snakesay('Running API sanity checks'))
4953
token = os.environ.get('API_TOKEN')

pythonanywhere/django_project.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import subprocess
44
from textwrap import dedent
55

6+
from pythonanywhere.api import Webapp
67
from pythonanywhere.snakesay import snakesay
78
from pythonanywhere.virtualenvs import create_virtualenv
89

@@ -13,6 +14,7 @@ def __init__(self, domain):
1314
self.domain = domain
1415
self.project_path = Path('~/').expanduser() / self.domain
1516
self.wsgi_file_path = '/var/www/' + domain.replace('.', '_') + '_wsgi.py'
17+
self.webapp = Webapp(domain)
1618

1719

1820
def create_virtualenv(self, django_version, nuke):

tests/test_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ def test_init(self):
3333
assert app.domain == 'www.my-domain.com'
3434

3535

36+
def test_compare_equal(self):
37+
assert Webapp('www.my-domain.com') == Webapp('www.my-domain.com')
38+
39+
40+
def test_compare_not_equal(self):
41+
assert Webapp('www.my-domain.com') != Webapp('www.other-domain.com')
3642

3743

3844

tests/test_django_project.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pythonanywhere.django_project
77
from pythonanywhere.django_project import DjangoProject
8+
from pythonanywhere.api import Webapp
89

910

1011

@@ -19,6 +20,11 @@ def test_wsgi_file_path(self, fake_home):
1920
project = DjangoProject('mydomain.com')
2021
assert project.wsgi_file_path == '/var/www/mydomain_com_wsgi.py'
2122

23+
def test_webapp(self, fake_home):
24+
project = DjangoProject('mydomain.com')
25+
assert project.webapp == Webapp('mydomain.com')
26+
27+
2228

2329

2430
class TestCreateVirtualenv:

0 commit comments

Comments
 (0)
0