Skip to content

Commit

Permalink
spdx#202 Fixing Unit test failure - test_post_submit
Browse files Browse the repository at this point in the history
  • Loading branch information
BanulaKumarage committed Mar 11, 2023
1 parent 929dc74 commit a7b3b34
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/app/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,10 +1146,11 @@ class SubmitNewLicenseViewsTestCase(TestCase):
def initialise(self):
self.fullname = "BSD Zero Clause License"
self.shortIdentifier = "0BSD"
self.exampleUrl = "testUrl"
self.sourceUrl = "http://landley.net/toybox/license.html"
self.urls = [self.sourceUrl]
self.osiApproved = "no"
self.comments = ""
self.comments = "Test Comment"
self.notes = ""
self.licenseHeader = ""
self.text ='<text> <copyrightText> <p>Copyright (C) 2006 by Rob Landley &lt;rob@landley.net&gt;</p> </copyrightText> <p>Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.</p> <p>THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</p> </text>'
Expand All @@ -1160,7 +1161,7 @@ def initialise(self):
self.data_no_author = {"fullname": self.fullname, "shortIdentifier": self.shortIdentifier,
"sourceUrl": self.sourceUrl,'osiApproved': self.osiApproved, 'notes': self.notes,
"licenseHeader": self.licenseHeader, "text": self.text, "userEmail": self.userEmail,
"urlType": "tests"}
"urlType": "tests", "exampleUrl":self.exampleUrl,"comments":self.comments}
self.data = self.data_no_author.update({"licenseAuthorName": self.licenseAuthorName})

def test_submit_new_license(self):
Expand Down
4 changes: 2 additions & 2 deletions src/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ def check_spdx_license(licenseText):
# if redis is empty build the spdx license list in the redis database
if r.keys('*') == []:
build_spdx_licenses()
spdxLicenseIds = list(r.keys())
spdxLicenseTexts = r.mget(spdxLicenseIds)
spdxLicenseIds = list(map(lambda x: x.decode('utf-8'), list(r.keys())))
spdxLicenseTexts = list(map(lambda x: x.decode('utf-8'), r.mget(spdxLicenseIds)))
licenseData = dict(list(zip(spdxLicenseIds, spdxLicenseTexts)))
matches = get_close_matches(licenseText, licenseData)
if not matches:
Expand Down

0 comments on commit a7b3b34

Please sign in to comment.