Skip to content

Commit

Permalink
Adds license information
Browse files Browse the repository at this point in the history
  • Loading branch information
nezhar committed Sep 6, 2017
1 parent dd37fb7 commit 56807bf
Show file tree
Hide file tree
Showing 7 changed files with 337 additions and 10 deletions.
81 changes: 81 additions & 0 deletions test/fixtures/pypi-package3-1.0.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"info": {
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"cheesecake_code_kwalitee_id": null,
"keywords": "",
"package_url": "http://pypi.python.org/pypi/package3",
"author": "Package 3 author",
"author_email": "[email protected]",
"download_url": "",
"platform": "",
"version": "1.0.0",
"cheesecake_documentation_id": null,
"_pypi_hidden": false,
"description": "UNKNOWN\n\n\n",
"release_url": "http://pypi.python.org/pypi/package3/1.0.1",
"downloads": {
"last_month": 0,
"last_week": 0,
"last_day": 0
},
"_pypi_ordering": 141,
"requires_dist": [],
"classifiers": [],
"name": "Package3",
"bugtrack_url": "",
"license": "GPL-2.0",
"summary": "Python package",
"home_page": "https://www.url.tld/",
"cheesecake_installability_id": null
},
"releases": {
"1.0.0": [
{
"has_sig": false,
"upload_time": "2011-09-29T23:34:21",
"comment_text": "",
"python_version": "source",
"url": "",
"md5_digest": "",
"downloads": 0,
"filename": "package.tar.gz",
"packagetype": "sdist",
"path": "f0/package.tar.gz",
"size": 1234
}
],
"2.0.0": [
{
"has_sig": false,
"upload_time": "2013-11-29T23:34:21",
"comment_text": "",
"python_version": "source",
"url": "",
"md5_digest": "",
"downloads": 0,
"filename": "package.tar.gz",
"packagetype": "sdist",
"path": "f0/package.tar.gz",
"size": 1234
}
],
"3.0.0": [
{
"has_sig": false,
"upload_time": "2015-09-29T23:34:21",
"comment_text": "",
"python_version": "source",
"url": "",
"md5_digest": "",
"downloads": 0,
"filename": "package.tar.gz",
"packagetype": "sdist",
"path": "f0/package.tar.gz",
"size": 1234
}
]
}
}
81 changes: 81 additions & 0 deletions test/fixtures/pypi-package3-2.0.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"info": {
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"cheesecake_code_kwalitee_id": null,
"keywords": "",
"package_url": "http://pypi.python.org/pypi/package3",
"author": "Package 3 author",
"author_email": "[email protected]",
"download_url": "",
"platform": "",
"version": "2.0.0",
"cheesecake_documentation_id": null,
"_pypi_hidden": false,
"description": "UNKNOWN\n\n\n",
"release_url": "http://pypi.python.org/pypi/package3/1.0.1",
"downloads": {
"last_month": 0,
"last_week": 0,
"last_day": 0
},
"_pypi_ordering": 141,
"requires_dist": [],
"classifiers": [],
"name": "Package3",
"bugtrack_url": "",
"license": "GPL-3.0",
"summary": "Python package",
"home_page": "https://www.url.tld/",
"cheesecake_installability_id": null
},
"releases": {
"1.0.0": [
{
"has_sig": false,
"upload_time": "2011-09-29T23:34:21",
"comment_text": "",
"python_version": "source",
"url": "",
"md5_digest": "",
"downloads": 0,
"filename": "package.tar.gz",
"packagetype": "sdist",
"path": "f0/package.tar.gz",
"size": 1234
}
],
"2.0.0": [
{
"has_sig": false,
"upload_time": "2013-11-29T23:34:21",
"comment_text": "",
"python_version": "source",
"url": "",
"md5_digest": "",
"downloads": 0,
"filename": "package.tar.gz",
"packagetype": "sdist",
"path": "f0/package.tar.gz",
"size": 1234
}
],
"3.0.0": [
{
"has_sig": false,
"upload_time": "2015-09-29T23:34:21",
"comment_text": "",
"python_version": "source",
"url": "",
"md5_digest": "",
"downloads": 0,
"filename": "package.tar.gz",
"packagetype": "sdist",
"path": "f0/package.tar.gz",
"size": 1234
}
]
}
}
81 changes: 81 additions & 0 deletions test/fixtures/pypi-package3-3.0.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"info": {
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"cheesecake_code_kwalitee_id": null,
"keywords": "",
"package_url": "http://pypi.python.org/pypi/package3",
"author": "Package 3 author",
"author_email": "[email protected]",
"download_url": "",
"platform": "",
"version": "3.0.0",
"cheesecake_documentation_id": null,
"_pypi_hidden": false,
"description": "UNKNOWN\n\n\n",
"release_url": "http://pypi.python.org/pypi/package3/1.0.1",
"downloads": {
"last_month": 0,
"last_week": 0,
"last_day": 0
},
"_pypi_ordering": 141,
"requires_dist": [],
"classifiers": [],
"name": "Package3",
"bugtrack_url": "",
"license": "MIT",
"summary": "Python package",
"home_page": "https://www.url.tld/",
"cheesecake_installability_id": null
},
"releases": {
"1.0.0": [
{
"has_sig": false,
"upload_time": "2011-09-29T23:34:21",
"comment_text": "",
"python_version": "source",
"url": "",
"md5_digest": "",
"downloads": 0,
"filename": "package.tar.gz",
"packagetype": "sdist",
"path": "f0/package.tar.gz",
"size": 1234
}
],
"2.0.0": [
{
"has_sig": false,
"upload_time": "2013-11-29T23:34:21",
"comment_text": "",
"python_version": "source",
"url": "",
"md5_digest": "",
"downloads": 0,
"filename": "package.tar.gz",
"packagetype": "sdist",
"path": "f0/package.tar.gz",
"size": 1234
}
],
"3.0.0": [
{
"has_sig": false,
"upload_time": "2015-09-29T23:34:21",
"comment_text": "",
"python_version": "source",
"url": "",
"md5_digest": "",
"downloads": 0,
"filename": "package.tar.gz",
"packagetype": "sdist",
"path": "f0/package.tar.gz",
"size": 1234
}
]
}
}
6 changes: 4 additions & 2 deletions test/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
PATH = os.path.dirname(os.path.realpath(__file__))


def get_pypi_package_data_monkey(package_name):
with open(os.path.join(PATH, 'fixtures', 'pypi-%s.json' % package_name)) as data_file:
def get_pypi_package_data_monkey(package_name, version=None):
json_file = 'pypi-%s.json' % package_name

with open(os.path.join(PATH, 'fixtures', json_file)) as data_file:
return json.load(data_file)


Expand Down
58 changes: 58 additions & 0 deletions test/test_update_license.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python
import unittest
import os
import json

import updatable


PATH = os.path.dirname(os.path.realpath(__file__))


def get_pypi_package_data_monkey(package_name, version=None):
if version:
json_file = 'pypi-%s-%s.json' % (package_name, version)
else:
json_file = 'pypi-%s.json' % package_name

with open(os.path.join(PATH, 'fixtures', json_file)) as data_file:
return json.load(data_file)


class TestUpdateLicense(unittest.TestCase):
"""
Tests package updatability
"""

def setUp(self):
self.get_pypi_package_data_orig = updatable.get_pypi_package_data
updatable.get_pypi_package_data = get_pypi_package_data_monkey

def tearDown(self):
updatable.get_pypi_package_data = self.get_pypi_package_data_orig

def test_update_license(self):
"""
Test update count for a package that has only major releases
"""
updates = updatable.get_package_update_list('package3', '1.0.0')
self.assertEqual(updates['current_release'], '1.0.0')
self.assertEqual(updates['latest_release'], '3.0.0')
self.assertEqual(updates['current_release_license'], 'GPL-2.0')
self.assertEqual(updates['latest_release_license'], 'MIT')

updates = updatable.get_package_update_list('package3', '2.0.0')
self.assertEqual(updates['current_release'], '2.0.0')
self.assertEqual(updates['latest_release'], '3.0.0')
self.assertEqual(updates['current_release_license'], 'GPL-3.0')
self.assertEqual(updates['latest_release_license'], 'MIT')

updates = updatable.get_package_update_list('package3', '3.0.0')
self.assertEqual(updates['current_release'], '3.0.0')
self.assertEqual(updates['latest_release'], '3.0.0')
self.assertEqual(updates['current_release_license'], 'MIT')
self.assertEqual(updates['latest_release_license'], 'MIT')


if __name__ == '__main__':
unittest.main()
Loading

0 comments on commit 56807bf

Please sign in to comment.