Skip to content

Commit

Permalink
Freeze black version and fix black formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekram committed May 8, 2021
1 parent 4808921 commit b7a7bdb
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test:
@(py.test --cov-report term --cov-config .coveragerc --cov=pyas2 --color=yes pyas2/tests/ -k 'not concurrency')
@(py.test --cov-report term --cov-config .coveragerc --cov=pyas2 --color=yes pyas2/tests/ --black --pylama pyas2)

serve:
@(ENV=example python manage.py migrate && python manage.py runserver)
Expand Down
12 changes: 6 additions & 6 deletions pyas2/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Organization(models.Model):

@property
def as2org(self):
""" Returns an object of pyas2lib's Organization class"""
"""Returns an object of pyas2lib's Organization class"""
params = {"as2_name": self.as2_name, "mdn_url": settings.MDN_URL}
if self.signature_key:
params["sign_key"] = bytes(self.signature_key.key)
Expand Down Expand Up @@ -262,7 +262,7 @@ class Partner(models.Model):

@property
def as2partner(self):
""" Returns an object of pyas2lib's Partner class"""
"""Returns an object of pyas2lib's Partner class"""
params = {
"as2_name": self.as2_name,
"compress": self.compress,
Expand Down Expand Up @@ -414,7 +414,7 @@ class Meta:

@property
def as2message(self):
""" Returns an object of pyas2lib's Message class"""
"""Returns an object of pyas2lib's Message class"""
if self.direction == "IN":
as2m = As2Message(
sender=self.partner.as2partner, receiver=self.organization.as2org
Expand All @@ -431,7 +431,7 @@ def as2message(self):

@property
def status_icon(self):
""" Return the icon for message status """
"""Return the icon for message status"""
if self.status == "S":
return "admin/img/icon-yes.svg"
elif self.status == "E":
Expand All @@ -442,7 +442,7 @@ def status_icon(self):
return "admin/img/icon-unknown.svg"

def send_message(self, header, payload):
""" Send the message to the partner"""
"""Send the message to the partner"""
logger.info(
f'Sending message {self.message_id} from organization "{self.organization}" '
f'to partner "{self.partner}".'
Expand Down Expand Up @@ -595,7 +595,7 @@ def __str__(self):
return self.mdn_id

def send_async_mdn(self):
""" Send the asynchronous MDN to the partner"""
"""Send the asynchronous MDN to the partner"""

# convert the mdn headers to dictionary
headers = HeaderParser().parsestr(self.headers.read().decode())
Expand Down
2 changes: 1 addition & 1 deletion pyas2/templatetags/pyas2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

@register.filter
def readfilefield(field):
""" Template filter for rendering data from a file field """
"""Template filter for rendering data from a file field"""
with field.open("r") as f:
return f.read()
6 changes: 3 additions & 3 deletions pyas2/tests/test_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def tearDownClass(cls):
mdn.payload.delete()

def test_post_send_command(self):
""" Test that the command after successful send gets executed."""
"""Test that the command after successful send gets executed."""

partner = Partner.objects.create(
name="AS2 Server",
Expand Down Expand Up @@ -153,7 +153,7 @@ def test_post_send_command_async(self, mock_request):
os.remove(touch_file)

def test_post_receive_command(self):
""" Test that the command after successful receive gets executed."""
"""Test that the command after successful receive gets executed."""
# settings.DATA_DIR = TEST_DIR
# add the post receive command and save it
self.partner.cmd_receive = "touch %s/$filename.received" % TEST_DIR
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_post_receive_command(self):
# settings.DATA_DIR = None

def test_use_received_filename(self):
""" Test using the filename of the payload received while saving the file."""
"""Test using the filename of the payload received while saving the file."""

# add the post receive command and save it
self.partner.cmd_receive = "touch %s/$filename.received" % TEST_DIR
Expand Down
2 changes: 1 addition & 1 deletion pyas2/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def tearDown(self):
mdn.payload.delete()

def testEndpoint(self):
""" Test if the as2 reveive endpoint is active """
"""Test if the as2 reveive endpoint is active"""

response = self.client.get("/pyas2/as2receive")
self.assertEqual(response.status_code, 200)
Expand Down
4 changes: 2 additions & 2 deletions pyas2/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

@pytest.mark.django_db
def test_sendbulk_command(mocker, partner, organization):
""" Test the command for sending all files in the outbox folder """
"""Test the command for sending all files in the outbox folder"""
mocked_call_command = mocker.patch(
"pyas2.management.commands.sendas2bulk.call_command"
)
Expand Down Expand Up @@ -51,7 +51,7 @@ def test_sendbulk_command(mocker, partner, organization):

@pytest.mark.django_db
def test_sendmessage_command(mocker, organization, partner):
""" Test the command for sending an as2 message """
"""Test the command for sending an as2 message"""
test_message = os.path.join(TEST_DIR, "testmessage.edi")

# Try to run with invalid org and client
Expand Down
9 changes: 4 additions & 5 deletions pyas2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ def find_message(message_id, partner_id):

@staticmethod
def check_message_exists(message_id, partner_id):
""" Check if the message already exists in the system """
"""Check if the message already exists in the system"""
return Message.objects.filter(
message_id=message_id, partner_id=partner_id.strip()
).exists()

@staticmethod
def find_organization(org_id):
""" Find the org using the As2 Id and return its pyas2 version"""
"""Find the org using the As2 Id and return its pyas2 version"""
org = Organization.objects.filter(as2_name=org_id).first()
if org:
return org.as2org

@staticmethod
def find_partner(partner_id):
""" Find the partner using the As2 Id and return its pyas2 version"""
"""Find the partner using the As2 Id and return its pyas2 version"""
partner = Partner.objects.filter(as2_name=partner_id).first()
if partner:
return partner.as2partner
Expand Down Expand Up @@ -172,7 +172,6 @@ def post(self, request, *args, **kwargs):
return HttpResponse(_("AS2 message has been received"))

def get(self, request, *args, **kwargs):
""""""
return HttpResponse(
_("To submit an AS2 message, you must POST the message to this URL")
)
Expand Down Expand Up @@ -246,7 +245,7 @@ def form_valid(self, form):


class DownloadFile(View):
""" A generic view for downloading files such as payload, certificates..."""
"""A generic view for downloading files such as payload, certificates..."""

def get(self, request, obj_type, obj_id, *args, **kwargs):
filename = ""
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pyas2lib==1.3.3
requests
requests==2.25.1
django>=2.2.18
1 change: 1 addition & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pytest-mock==3.5.1
pylama==7.7.1
pylint==2.7.3
pytest-black==0.3.12
black==21.5b0
django-environ==0.4.5

0 comments on commit b7a7bdb

Please sign in to comment.