Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Django 2.2 #388

Merged
merged 7 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,52 @@ verify_ssl = true

[dev-packages]
kegbot = {editable = true,path = "."}
black = "*"
flake8 = "*"
pytest = "*"
pytest-django = "*"
requests-mock = "*"
sphinx-issues = "*"
sphinx = "*"
vcrpy = "*"

[packages]
celery = "*"
coloredlogs = "*"
dj-database-url = "==0.4.2"
django-bootstrap-pagination = "==1.6.2"
django-crispy-forms = "==1.6.1"
django-imagekit = "==4.0.1"
django-redis = "==4.8.0"
django-registration = "==2.2"
flake8 = "*"
dj-database-url = "*"
django-bootstrap-pagination = "*"
django-crispy-forms = "*"
django-imagekit = "*"
django-redis = "*"
django-registration = "*"
foursquare = "==1!2016.9.12"
gunicorn = "*"
httplib2 = "*"
isodate = "*"
jsonfield = "==2.0.2"
mock = "==2.0.0"
jsonfield = "*"
oauthlib = "*"
pilkit = "*"
protobuf = "*"
python-gflags = "*"
pytz = "*"
redis = "*"
requests-mock = "*"
requests-oauthlib = "*"
requests = "*"
tweepy = "*"
vcrpy = "*"
whitenoise = "==3.3.0"
Django = "==1.11.28"
whitenoise = "*"
Django = "<3"
Pillow = "*"
PyYAML = "*"
mysqlclient = "*"
sphinx = "*"
pytest = "*"
pytest-django = "*"
future = "*"
addict = "*"
kegbot-api = "*"
sphinx-issues = "*"

[scripts]
kegbot = "python bin/kegbot"

[requires]
python_version = "3"

[pipenv]
allow_prereleases = true
626 changes: 399 additions & 227 deletions Pipfile.lock

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ This software is offered under the **GPLv2** license. Your use of
Kegbot Server constitutes your agreement to that license. Please see
``LICENSE.txt`` for the full license.

Code and documentation are **Copyright 2014 Bevbot LLC**,
unless otherwise noted. Graphics and images distributed with Kegbot,
such as the Kegbot logo, are also copyrighted works of Bevbot LLC
unless otherwise noted, and may not be reused without permission.


## Contributing

We love getting patches! Send us a pull request, or hop on to IRC if
Expand Down
2 changes: 1 addition & 1 deletion bin/kegbot
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# Copyright 2010 Mike Wakerly <[email protected]>
# Copyright 2014 Kegbot Project contributors
#
# This file is part of the Pykeg package of the Kegbot project.
# For more information on Pykeg or Kegbot, see http://kegbot.org/
Expand Down
2 changes: 1 addition & 1 deletion bin/setup-kegbot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# Copyright 2014 Bevbot LLC, All Rights Reserved
# Copyright 2014 Kegbot Project contributors
#
# This file is part of the Pykeg package of the Kegbot project.
# For more information on Pykeg or Kegbot, see http://kegbot.org/
Expand Down
29 changes: 0 additions & 29 deletions deploy/travis/local_settings.py

This file was deleted.

3 changes: 1 addition & 2 deletions docs/source/release-notes/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ For a detailed look at what's new in version 1.3, see :ref:`version-13-release-n

**Other Changes**

* Internal: Upgraded to Django 1.11.
* Upgraded to Python 3 and Django 2.
* Internal: Improved static file serving (:issue:`368`)
* Internal: Developer tests now use ``pytest``
* Upgraded to Python 3.

Version 1.2.3 (2015-01-12)
--------------------------
Expand Down
4 changes: 4 additions & 0 deletions docs/source/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ These values can be set in the shell environment of the server program.

**Example:** ``mysql://kegbot@localhost/kegbot``

.. data:: KEGBOT_EMAIL_FROM_ADDRESS

The "From:" address to use in emails from the system. No default.

.. data:: KEGBOT_REDIS_URL

URL to the Kegbot Redis instance, in the format ``redis://:PASSWORD@HOST:PORT/DATABASE``. ``PASSWORD`` and ``PORT`` are optional.
Expand Down
2 changes: 1 addition & 1 deletion pykeg/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2014 Bevbot LLC, All Rights Reserved
# Copyright 2014 Kegbot Project contributors
#
# This file is part of the Pykeg package of the Kegbot project.
# For more information on Pykeg or Kegbot, see http://kegbot.org/
Expand Down
2 changes: 1 addition & 1 deletion pykeg/backend/backends.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2014 Bevbot LLC, All Rights Reserved
# Copyright 2014 Kegbot Project contributors
#
# This file is part of the Pykeg package of the Kegbot project.
# For more information on Pykeg or Kegbot, see http://kegbot.org/
Expand Down
72 changes: 36 additions & 36 deletions pykeg/backend/backends_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2014 Bevbot LLC, All Rights Reserved
# Copyright 2014 Kegbot Project contributors
#
# This file is part of the Pykeg package of the Kegbot project.
# For more information on Pykeg or Kegbot, see http://kegbot.org/
Expand Down Expand Up @@ -45,17 +45,17 @@ def setUp(self):
def test_delete_keg(self):
site = models.KegbotSite.get()
original_stats = site.get_stats()
self.assertEquals(755, original_stats['total_pours'])
self.assertEqual(755, original_stats['total_pours'])

keg = models.Keg.objects.get(pk=2)
keg_stats = keg.get_stats()
keg_drinks = keg.drinks.all()
self.assertEquals(185, len(keg_drinks))
self.assertEqual(185, len(keg_drinks))
self.backend.cancel_keg(keg)

stats = site.get_stats()
self.assertEquals(755 - 185, stats['total_pours'])
self.assertEquals(original_stats['total_volume_ml'] - keg_stats['total_volume_ml'],
self.assertEqual(755 - 185, stats['total_pours'])
self.assertEqual(original_stats['total_volume_ml'] - keg_stats['total_volume_ml'],
stats['total_volume_ml'])


Expand All @@ -79,51 +79,51 @@ def test_drink_management(self):
style_name=FAKE_BEER_STYLE)
self.assertIsNotNone(keg)

self.assertEquals(0, keg.served_volume())
self.assertEqual(0, keg.served_volume())
drink = self.backend.record_drink(METER_NAME, ticks=2200)
self.assertIsNotNone(drink)
self.assertEquals(2200, drink.ticks)
self.assertEqual(2200, drink.ticks)
self.assertAlmostEqual(1000.0, drink.volume_ml, places=3)
keg = models.Keg.objects.get(pk=keg.id)
self.assertAlmostEqual(1000.0, keg.served_volume(), places=3)
self.assertEquals('', drink.shout)
self.assertEquals(0, drink.duration)
self.assertEqual('', drink.shout)
self.assertEqual(0, drink.duration)

drink = self.backend.record_drink(METER_NAME, ticks=1100)
keg = models.Keg.objects.get(pk=keg.id)
self.assertIsNotNone(drink)
self.assertEquals(1100, drink.ticks)
self.assertEqual(1100, drink.ticks)
self.assertAlmostEqual(500.0, drink.volume_ml, places=3)
self.assertAlmostEqual(1500.0, keg.served_volume(), places=3)

# Add with volume, taking precedence over ticks.
drink = self.backend.record_drink(METER_NAME, ticks=1100, volume_ml=1)
keg = models.Keg.objects.get(pk=keg.id)
self.assertIsNotNone(drink)
self.assertEquals(1100, drink.ticks)
self.assertEqual(1100, drink.ticks)
self.assertAlmostEqual(1.0, drink.volume_ml, places=3)
self.assertAlmostEqual(1501.0, keg.served_volume(), places=3)

# Add with a user.
user = models.User.objects.create(username='testy')
drink = self.backend.record_drink(METER_NAME, ticks=2200, username=user.username)
self.assertIsNotNone(drink)
self.assertEquals(user, drink.user)
self.assertEqual(user, drink.user)

def test_drink_cancel(self):
"""Tests cancelling drinks."""
keg = self.backend.start_keg(METER_NAME, beverage_name=FAKE_BEER_NAME,
beverage_type='beer', producer_name=FAKE_BREWER_NAME,
style_name=FAKE_BEER_STYLE)
self.assertIsNotNone(keg)
self.assertEquals(0, keg.served_volume())
self.assertEqual(0, keg.served_volume())

for i in range(10):
self.backend.record_drink(METER_NAME, ticks=1, volume_ml=100)

drinks = list(models.Drink.objects.all().order_by('id'))
keg = models.Keg.objects.get(pk=keg.id)
self.assertEquals(10, len(drinks))
self.assertEqual(10, len(drinks))
self.assertAlmostEqual(1000.0, keg.served_volume(), places=3)

cancel_drink = drinks[-1]
Expand All @@ -133,18 +133,18 @@ def test_drink_cancel(self):
self.backend.cancel_drink(drinks[-1])
drinks = list(models.Drink.objects.all().order_by('id'))
keg = models.Keg.objects.get(pk=keg.id)
self.assertEquals(9, len(drinks))
self.assertEqual(9, len(drinks))
self.assertAlmostEqual(900.0, keg.served_volume(), places=3)
session = models.DrinkingSession.objects.get(id=session.id)
self.assertAlmostEqual(session.get_stats().total_volume_ml, 900.0, places=3)

keg = models.Keg.objects.get(pk=keg.id)
self.assertEquals(0, keg.spilled_ml)
self.assertEqual(0, keg.spilled_ml)

self.backend.cancel_drink(drinks[-1], spilled=True)
keg = models.Keg.objects.get(pk=keg.id)
drinks = list(models.Drink.objects.all().order_by('id'))
self.assertEquals(8, len(drinks))
self.assertEqual(8, len(drinks))
self.assertAlmostEqual(800.0, keg.served_volume(), places=3)
self.assertAlmostEqual(100.0, keg.spilled_ml, places=3)

Expand All @@ -154,22 +154,22 @@ def test_drink_cancel(self):
for d in other_drinks:
self.backend.cancel_drink(d)

self.assertEquals(first_drink.volume_ml, first_drink.session.volume_ml)
self.assertEqual(first_drink.volume_ml, first_drink.session.volume_ml)
session_id = first_drink.session.id

self.backend.cancel_drink(first_drink)

with self.assertRaises(models.DrinkingSession.DoesNotExist):
models.DrinkingSession.objects.get(pk=session_id)

self.assertEquals(num_sessions - 1, models.DrinkingSession.objects.all().count())
self.assertEqual(num_sessions - 1, models.DrinkingSession.objects.all().count())

def test_reassign_drink_with_photo(self):
keg = self.backend.start_keg(METER_NAME, beverage_name=FAKE_BEER_NAME,
beverage_type='beer', producer_name=FAKE_BREWER_NAME,
style_name=FAKE_BEER_STYLE)
self.assertIsNotNone(keg)
self.assertEquals(0, keg.served_volume())
self.assertEqual(0, keg.served_volume())

drink = self.backend.record_drink(METER_NAME, ticks=1, volume_ml=100,
photo='foo')
Expand All @@ -181,8 +181,8 @@ def test_reassign_drink_with_photo(self):

user = self.backend.create_new_user('blort', email='[email protected]')
updated_drink = self.backend.assign_drink(drink, user)
self.assertEquals(user, updated_drink.user)
self.assertEquals(user, updated_drink.picture.user)
self.assertEqual(user, updated_drink.user)
self.assertEqual(user, updated_drink.picture.user)

def test_keg_management(self):
"""Tests adding and removing kegs."""
Expand All @@ -191,7 +191,7 @@ def test_keg_management(self):

# No beer types yet.
qs = models.Beverage.objects.filter(name=FAKE_BEER_NAME)
self.assertEquals(len(qs), 0, "Beverage already exists")
self.assertEqual(len(qs), 0, "Beverage already exists")

# Tap the keg.
keg = self.backend.start_keg(METER_NAME, beverage_name=FAKE_BEER_NAME,
Expand All @@ -200,18 +200,18 @@ def test_keg_management(self):
self.assertIsNotNone(keg)
self.assertTrue(keg.is_on_tap())

self.assertEquals(keg.current_tap, tap, "Tap did not become active.")
self.assertEqual(keg.current_tap, tap, "Tap did not become active.")
tap = keg.current_tap
self.assertTrue(keg.current_tap.is_active())

# Check that the beer type was created.
qs = models.Beverage.objects.filter(name=FAKE_BEER_NAME)
self.assertEquals(len(qs), 1, "Expected a single new Beverage.")
self.assertEqual(len(qs), 1, "Expected a single new Beverage.")
beverage = qs[0]
brewer = beverage.producer
style = beverage.style
self.assertEquals(brewer.name, FAKE_BREWER_NAME)
self.assertEquals(style, FAKE_BEER_STYLE)
self.assertEqual(brewer.name, FAKE_BREWER_NAME)
self.assertEqual(style, FAKE_BEER_STYLE)

# Now activate a new keg.
keg = self.backend.end_keg(tap.current_keg)
Expand All @@ -227,15 +227,15 @@ def test_keg_management(self):
self.assertTrue(new_keg.is_on_tap())

# Ensure the beer type was reused.
self.assertEquals(new_keg.type, beverage)
self.assertEqual(new_keg.type, beverage)

# Deactivate, and activate a new keg again by name.
self.backend.end_keg(tap.current_keg)
new_keg_2 = self.backend.start_keg(METER_NAME, beverage_name='Other Beer',
beverage_type='beer', producer_name=FAKE_BREWER_NAME,
style_name=FAKE_BEER_STYLE)
self.assertEquals(new_keg_2.type.producer, keg.type.producer)
self.assertEquals(new_keg_2.type.style, keg.type.style)
self.assertEqual(new_keg_2.type.producer, keg.type.producer)
self.assertEqual(new_keg_2.type.style, keg.type.style)
self.assertNotEquals(new_keg_2.type, keg.type)

# New brewer, identical beer name == new beer type.
Expand All @@ -248,7 +248,7 @@ def test_keg_management(self):
producer_name='Other Brewer',
style_name=FAKE_BEER_STYLE)
self.assertNotEquals(new_keg_3.type.producer, keg.type.producer)
self.assertEquals(new_keg_3.type.name, keg.type.name)
self.assertEqual(new_keg_3.type.name, keg.type.name)
self.assertNotEquals(new_keg_3.type, keg.type)

def test_meters(self):
Expand All @@ -275,20 +275,20 @@ def test_toggles(self):

@override_settings(KEGBOT_BASE_URL='http://example.com:8000//')
def test_urls(self):
self.assertEquals('http://example.com:8000', self.backend.get_base_url())
self.assertEqual('http://example.com:8000', self.backend.get_base_url())

keg = self.backend.start_keg(METER_NAME, beverage_name=FAKE_BEER_NAME,
beverage_type='beer', producer_name=FAKE_BREWER_NAME,
style_name=FAKE_BEER_STYLE)
self.assertEquals('http://example.com:8000/kegs/{}'.format(keg.id), keg.full_url())
self.assertEqual('http://example.com:8000/kegs/{}'.format(keg.id), keg.full_url())

drink = self.backend.record_drink(METER_NAME, ticks=1, volume_ml=100,
photo='foo')
self.assertEquals('http://example.com:8000/d/{}'.format(drink.id), drink.short_url())
self.assertEquals('http://example.com:8000/s/{}'.format(drink.session.id),
self.assertEqual('http://example.com:8000/d/{}'.format(drink.id), drink.short_url())
self.assertEqual('http://example.com:8000/s/{}'.format(drink.session.id),
drink.session.short_url())

start = drink.session.start_time
datepart = '{}/{}/{}'.format(start.year, start.month, start.day)
self.assertEquals('http://example.com:8000/sessions/{}/{}'.format(datepart,
self.assertEqual('http://example.com:8000/sessions/{}/{}'.format(datepart,
drink.session.id), drink.session.full_url())
Loading