Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Jul 22, 2019
1 parent 0912efd commit b2f8bbd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ __pycache__/
*.zip

qgis_plugin_ci_testing/i18n
qgis_plugin_ci_testing/resources_rc.py


.tokens

Expand Down
4 changes: 2 additions & 2 deletions test/plugins.xml.expected
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<download_url>https://github.com/opengisch/qgis-plugin-ci/releases/download/0.1.2/qgis-plugin-ci-0.1.2.zip</download_url>
<uploaded_by>Denis Rouzaud</uploaded_by>
<create_date>1985-07-21</create_date>
<update_date>2019-07-16</update_date>
<update_date>__TODAY__</update_date>
<experimental>True</experimental>
<deprecated>False</deprecated>
<tracker>https://github.com/opengisch/qgis-plugin-ci/issues</tracker>
<repository>https://github.com/opengisch/qgis-plugin-ci</repository>
<tags></tags>
</pyqgis_plugin>
</plugins>
</plugins>
13 changes: 10 additions & 3 deletions test/test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from qgispluginci.release import release
from qgispluginci.translation import Translation
from qgispluginci.exceptions import GithubReleaseNotFound

from qgispluginci.utils import replace_in_file

# if change, also update on .travis.yml
RELEASE_VERSION_TEST = '0.1.2'
Expand All @@ -29,8 +29,12 @@ def setUp(self):
if self.github_token:
print('init Github')
self.repo = Github(self.github_token).get_repo('opengisch/qgis-plugin-ci')
self.clean_assets()

def tearDown(self):
self.clean_assets()

def clean_assets(self):
if self.repo:
rel = None
try:
Expand Down Expand Up @@ -58,19 +62,22 @@ def test_release_upload_github(self):
_, xml_repo = mkstemp(suffix='.xml')
url = 'https://github.com/opengisch/qgis-plugin-ci/releases/download/{}/plugins.xml'.format(RELEASE_VERSION_TEST)
urllib.request.urlretrieve(url, xml_repo)
self.assertTrue(filecmp.cmp('test/plugins.xml.expected', xml_repo))
replace_in_file(xml_repo, r'<update_date>[\w-]+<\/update_date>', '<update_date>__TODAY__</update_date>')
self.assertTrue(filecmp.cmp('test/plugins.xml.expected', xml_repo, shallow=False))

# compare archive file size
gh_release = self.repo.get_release(id=RELEASE_VERSION_TEST)
archive_name = 'qgis-plugin-ci-{}.zip'.format(RELEASE_VERSION_TEST)
fs = os.path.getsize(archive_name)
print('size: ', fs)
self.assertGreater(fs, 0, 'archive file size must be > 0')
found = False
for a in gh_release.get_assets():
if a.name == archive_name:
found = True
self.assertEqual(fs, a.size, 'asset size doesn\'t march archive size.')
break
self.assertTrue(False, 'asset not found')
self.assertTrue(found, 'asset not found')



Expand Down

0 comments on commit b2f8bbd

Please sign in to comment.