Skip to content

Commit

Permalink
Misc Improvements (#423)
Browse files Browse the repository at this point in the history
Update python and some dependencies, fix some warnings and tests.
  • Loading branch information
amCap1712 authored Aug 10, 2023
1 parent d11531e commit c9a1cc2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PYTHON_BASE_IMAGE_VERSION=3.8-20210115
ARG PYTHON_BASE_IMAGE_VERSION=3.11-20221221
ARG NODE_VERSION=16-alpine
FROM metabrainz/python:$PYTHON_BASE_IMAGE_VERSION as metabrainz-dev

Expand Down
12 changes: 6 additions & 6 deletions metabrainz/api/views/musicbrainz_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,39 @@ def test_replication_info(self):

resp = self.client.get(url_for('api_musicbrainz.replication_info', token=self.token))
self.assert200(resp)
self.assertEquals(resp.json, {
self.assertEqual(resp.json, {
'last_packet': None,
})

open(os.path.join(self.path, 'replication-1.tar.bz2'), 'a').close()
resp = self.client.get(url_for('api_musicbrainz.replication_info', token=self.token))
self.assert200(resp)
self.assertEquals(resp.json, {
self.assertEqual(resp.json, {
'last_packet': 'replication-1.tar.bz2',
})

open(os.path.join(self.path, 'replication-99999.tar.bz2'), 'a').close()
open(os.path.join(self.path, 'replication-100000.tar.bz2'), 'a').close()
resp = self.client.get(url_for('api_musicbrainz.replication_info', token=self.token))
self.assert200(resp)
self.assertEquals(resp.json, {
self.assertEqual(resp.json, {
'last_packet': 'replication-100000.tar.bz2',
})

def test_replication_check(self):
resp = self.client.get('/api/musicbrainz/replication-check')
self.assert200(resp)
self.assertEquals(resp.data, b"UNKNOWN no replication packets available")
self.assertEqual(resp.data, b"UNKNOWN no replication packets available")

open(os.path.join(self.path, 'replication-1.tar.bz2'), 'a').close()
resp = self.client.get('/api/musicbrainz/replication-check')
self.assert200(resp)
self.assertEquals(resp.data, b"OK")
self.assertEqual(resp.data, b"OK")

open(os.path.join(self.path, 'replication-3.tar.bz2'), 'a').close()
resp = self.client.get('/api/musicbrainz/replication-check')
self.assert200(resp)
self.assertEquals(resp.data, b"CRITICAL Replication packet 2 is missing")
self.assertEqual(resp.data, b"CRITICAL Replication packet 2 is missing")

open(os.path.join(self.path, 'replication-2.tar.bz2'), 'a').close()
os.utime(os.path.join(self.path, 'replication-3.tar.bz2'), (0, 0))
Expand Down
17 changes: 9 additions & 8 deletions metabrainz/model/payment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,26 +380,27 @@ def setUp(self):
@patch("stripe.PaymentIntent")
def test_log_stripe_charge_donation(self, mock_stripe):
# Function should execute without any exceptions
mock_stripe.retrieve.return_value = self.payment_intent
session = self.session_without_metadata.copy()
session["metadata"] = {
payment_intent = self.payment_intent.copy()
payment_intent["metadata"] = {
"is_donation": "True",
"editor": "lucifer",
"anonymous": "False",
"can_contact": "False"
}
Payment.log_stripe_charge(session)
mock_stripe.retrieve.return_value = payment_intent
session = self.session_without_metadata.copy()
Payment.log_one_time_charge(session)
self.assertEqual(len(Payment.query.all()), 1)

@patch("stripe.PaymentIntent")
def test_log_stripe_charge_payment(self, mock_stripe):
# Function should execute without any exceptions
mock_stripe.retrieve.return_value = self.payment_intent
session = self.session_without_metadata.copy()
session["metadata"] = {
payment_intent = self.payment_intent.copy()
payment_intent["metadata"] = {
"is_donation": "False",
"email": "[email protected]",
"invoice_number": 42,
}
Payment.log_stripe_charge(session)
mock_stripe.retrieve.return_value = payment_intent
Payment.log_one_time_charge(self.session_without_metadata)
self.assertEqual(len(Payment.query.all()), 1)
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ certifi
click==8.1.3
email_validator==1.0.5
Flask==2.3.2
Flask-Admin==1.6.0
Flask-Babel==3.0.1
Flask-Admin==1.6.1
Flask-Babel==3.1.0
Flask-DebugToolbar==0.13.1
Flask-Login==0.6.2
Flask-SQLAlchemy==3.0.3
Expand All @@ -14,23 +14,23 @@ git+https://github.com/maxcountryman/flask-uploads.git@f66d7dc93e68#egg=Flask_Up
git+https://github.com/metabrainz/[email protected]
idna==2.7
importlib-metadata>=3.10.0
intuit-oauth==1.2.3
intuit-oauth==1.2.4
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.2
mbdata==26.0.1
msgpack-python==0.5.6
psycopg2-binary==2.8.6
pytest==6.2.1
pytest-cov==2.11.0
psycopg2-binary==2.9.7
pytest==7.4.0
pytest-cov==4.1.0
python-dateutil==2.8.0
python-quickbooks==0.8.4
python-quickbooks==0.9.3
pytz==2022.7.1
rauth==0.7.3
redis==4.5.4
reportlab==3.6.12
requests==2.31.0
sentry-sdk[flask]==1.14.0
sentry-sdk[flask]==1.29.2
six==1.16.0
SQLAlchemy==1.4.18
sqlalchemy-dst>=1.0.1
Expand Down

0 comments on commit c9a1cc2

Please sign in to comment.