From b7a7bdb20a7cf62acddf68dbec2ca2241c8469eb Mon Sep 17 00:00:00 2001 From: abhishekram Date: Sat, 8 May 2021 17:02:37 +0530 Subject: [PATCH] Freeze black version and fix black formatting issues --- Makefile | 2 +- pyas2/models.py | 12 ++++++------ pyas2/templatetags/pyas2.py | 2 +- pyas2/tests/test_advanced.py | 6 +++--- pyas2/tests/test_basic.py | 2 +- pyas2/tests/test_commands.py | 4 ++-- pyas2/views.py | 9 ++++----- requirements/base.txt | 2 +- requirements/test.txt | 1 + 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index e7d2e1e..53aefb3 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/pyas2/models.py b/pyas2/models.py index 06bd90d..73dbf93 100644 --- a/pyas2/models.py +++ b/pyas2/models.py @@ -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) @@ -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, @@ -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 @@ -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": @@ -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}".' @@ -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()) diff --git a/pyas2/templatetags/pyas2.py b/pyas2/templatetags/pyas2.py index 515e45e..69bae46 100644 --- a/pyas2/templatetags/pyas2.py +++ b/pyas2/templatetags/pyas2.py @@ -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() diff --git a/pyas2/tests/test_advanced.py b/pyas2/tests/test_advanced.py index 745e0e0..a1dff5f 100644 --- a/pyas2/tests/test_advanced.py +++ b/pyas2/tests/test_advanced.py @@ -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", @@ -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 @@ -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 diff --git a/pyas2/tests/test_basic.py b/pyas2/tests/test_basic.py index 5c98c44..7cb259c 100644 --- a/pyas2/tests/test_basic.py +++ b/pyas2/tests/test_basic.py @@ -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) diff --git a/pyas2/tests/test_commands.py b/pyas2/tests/test_commands.py index c1c3a44..eb4006d 100644 --- a/pyas2/tests/test_commands.py +++ b/pyas2/tests/test_commands.py @@ -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" ) @@ -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 diff --git a/pyas2/views.py b/pyas2/views.py index 59cdea5..f10abcf 100644 --- a/pyas2/views.py +++ b/pyas2/views.py @@ -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 @@ -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") ) @@ -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 = "" diff --git a/requirements/base.txt b/requirements/base.txt index 5037f14..6be5ebf 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,3 +1,3 @@ pyas2lib==1.3.3 -requests +requests==2.25.1 django>=2.2.18 diff --git a/requirements/test.txt b/requirements/test.txt index 03abcdc..2f99f13 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -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