Skip to content

Commit

Permalink
1.0.2 Release
Browse files Browse the repository at this point in the history
- Fixed issued with logs
- Fixing issue #62
- Added ChangeLogs
  • Loading branch information
PonteIneptique committed Jan 16, 2018
1 parent c42ba2e commit 34eb3fb
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 90 deletions.
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: python
python:
- "3.4.5"
- "3.5"
- "3.6"

services:
- "redis"
Expand All @@ -21,4 +22,13 @@ after_success:
branches:
only:
- master
- documentation
- documentation


deploy:
provider: pypi
user: ponteineptique
password: $PYPASS
on:
tags: true
python: "3.5"
15 changes: 15 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Change logs
===

## 1.0.2 - 15/01/2017

By @ponteineptique

- Fixed a bug in tests where too much log would prevent the real logs to be read on travis
- Fixed a bug where logs would not be caught by .assertLogged ( Issue #60 )
- Fixed a bug introduced by Flask Caching > 1.3.0 ( Issue #62 )
- Tests were fixed to resolve bugs. Inner working of the application did not change
- Fixed a bug introduced with Werkzeug newer versions ( Issue #62 )
- Test where failing with FileSystemCache because it always leave one file after clearing (Which is a File Count variable)
- On Travis, added a monthly cronjob to check on dependencies update impact (since we are using some ">=" dependencies selector)

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Flask>=0.12
Werkzeug>=0.11.3
redis>=2.10.5
flask-caching>=1.2.0
MyCapytain>=2.0.0rc1
MyCapytain>=2.0.0
logassert
mock==2.0.0
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

setup(
name='capitains_nautilus',
version="1.0.1",
version="1.0.2",
description='Resolver for Capitains Guidelines Repository',
url='http://github.com/Capitains/nautilus',
author='Thibault Clerice',
author_email='leponteineptique@gmail.com',
license='Mozilla Public License Version 2.0',
packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
install_requires=[
"MyCapytain>=2.0.0rc1",
"MyCapytain>=2.0.0",
"tornado>=4.3",
"Flask>=0.12",
"Werkzeug>=0.11.3",
"redis>=2.10.5",
"Flask-Caching>=1.2.0"
"Flask-Caching==1.2.0"
],
test_requires=[
"logassert",
Expand Down
17 changes: 9 additions & 8 deletions tests/test_cli/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ def dispatchLatinLit(collection, path=None, **kwargs):
return dispatcher


http_cache = Cache(
config={
'CACHE_TYPE': "filesystem",
"CACHE_DIR": http_cache_dir,
"CACHE_DEFAULT_TIMEOUT": 0
}
)
nautilus_cache = FileSystemCache(subprocess_cache_dir, default_timeout=0)

resolver = NautilusCTSResolver(
Expand All @@ -45,6 +38,14 @@ def dispatchLatinLit(collection, path=None, **kwargs):
)

app = Flask("Nautilus")
http_cache = Cache(
app,
config={
'CACHE_TYPE': "filesystem",
"CACHE_DIR": http_cache_dir,
"CACHE_DEFAULT_TIMEOUT": 0
}
)
nautilus = FlaskNautilus(
app=app,
prefix="/api",
Expand All @@ -53,7 +54,7 @@ def dispatchLatinLit(collection, path=None, **kwargs):
flask_caching=http_cache
)

http_cache.init_app(app)
#http_cache.init_app(app)
app.debug = True

if __name__ == "__main__":
Expand Down
74 changes: 43 additions & 31 deletions tests/test_cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@


class TestManager(TestCase):
""" Test the manager ability to preprocess and cache some resources
.. note:: Werkzeug File System Cache leaves a cache file to indicate the number of other cache files . More in
https://github.com/Capitains/Nautilus/issues/62 and https://github.com/pallets/werkzeug/blob/8393ee88aaacf7bcd3a0b1d604511f70c222df25/werkzeug/contrib/cache.py#L773-L781
"""

@property
def app(self):
return self.__app__

class ParsingCalled(Exception):
pass
Expand All @@ -32,14 +41,18 @@ def cli(self, *args):
raise Exception("Run failed")

def setUp(self):
shutil.rmtree(subprocess_cache_dir, ignore_errors=True)
shutil.rmtree(http_cache_dir, ignore_errors=True)
self.cache = nautilus_cache
self.resolver = resolver
self.resolver.dispatcher = make_dispatcher()
self.resolver.__inventory__ = None
self.resolver.logger.disabled = True
self.former_parse = self.resolver.parse
self.nautilus = nautilus
self.app = app
self.__app__ = app
self.nautilus.flaskcache.init_app(self.app)
self.test_client = self.app.test_client()

def x(*k, **kw):
raise self.ParsingCalled("Parse should not be called")
Expand All @@ -59,54 +72,51 @@ def test_flush_inventory(self):
""" Check that parsing works and that flushing removes the cache """
self.cli("parse")
files = glob.glob(subprocess_cache_dir+"/*")
self.assertGreater(len(files), 0, "There should be caching operated by resolver")

self.assertGreater(len(files), 1, "There should be caching operated by resolver")
self.cli("flush_resolver")
files = glob.glob(subprocess_cache_dir+"/*")
self.assertEqual(len(files), 0, "Resolver Cache should be flushed")
self.assertEqual(len(files), 1, "Resolver Cache should be flushed (and only the count cache file should remain")

def test_flush_http(self):
""" Check that parsing works, that flushing removes the http cache """
self.cli("parse")

with self.app.app_context():
x = nautilus._r_GetCapabilities()
self.assertIn(
'<label xml:lang="eng">Epigrammata</label>', x[0],
"Response should be correctly produced"
)
response = self.test_client.get("/api/cts?request=GetCapabilities")
self.assertIn(
'<label xml:lang="eng">Epigrammata</label>', response.data.decode(),
"Response should be correctly produced"
)

files = glob.glob(http_cache_dir+"/*")
self.assertGreater(len(files), 0, "There should be caching operated by flask-caching")
self.assertGreater(len(files), 1, "There should be caching operated by flask-caching")

self.cli("flush_http_cache")
files = glob.glob(http_cache_dir+"/*")
self.assertEqual(len(files), 0, "There should be flushing of flask-caching")
self.assertEqual(len(files), 1, "HTTP Cache should be flushed (and only the count cache file should remain")

files = glob.glob(subprocess_cache_dir+"/*")
self.assertGreater(len(files), 0, "But not of Resolver Cache")
self.assertGreater(len(files), 1, "But not of Resolver Cache")

def test_flush_both(self):
""" Check that parsing works, that both flushing removes the http cache and resolver cache"""
self.cli("parse")

with self.app.app_context():
x = nautilus._r_GetCapabilities()
self.assertIn(
'<label xml:lang="eng">Epigrammata</label>', x[0],
"Response should be correctly produced"
)
response = self.test_client.get("/api/cts?request=GetCapabilities")
self.assertIn(
'<label xml:lang="eng">Epigrammata</label>', response.data.decode(),
"Response should be correctly produced"
)

files = glob.glob(http_cache_dir+"/*")
self.assertGreater(len(files), 0, "There should be caching operated by flask-caching")
self.assertGreater(len(files), 1, "There should be caching operated by flask-caching")
files = glob.glob(subprocess_cache_dir+"/*")
self.assertGreater(len(files), 0, "There should be caching operated by resolver")
self.assertGreater(len(files), 1, "There should be caching operated by resolver")

self.cli("flush_both")
files = glob.glob(http_cache_dir+"/*")
self.assertEqual(len(files), 0, "There should be flushing of flask-caching")
self.assertEqual(len(files), 1, "HTTP Cache should be flushed (and only the count cache file should remain")
files = glob.glob(subprocess_cache_dir+"/*")
self.assertEqual(len(files), 0, "There should be flushing of resolver")
self.assertEqual(len(files), 1, "Resolver Cache should be flushed (and only the count cache file should remain")

def test_references(self):
output = self.cli("parse")
Expand All @@ -125,28 +135,30 @@ class TestManagerClickMethod(TestManager):

def setUp(self):
# Full creation of app
self.cache = FileSystemCache(subprocess_cache_dir, default_timeout=0)
self.resolver = NautilusCTSResolver(
subprocess_repository,
dispatcher=make_dispatcher(),
cache=self.cache
)
self.__app__ = Flask("Nautilus")
self.http_cache = Cache(
self.app,
config={
'CACHE_TYPE': "filesystem",
"CACHE_DIR": http_cache_dir,
"CACHE_DEFAULT_TIMEOUT": 0
}
)
self.cache = FileSystemCache(subprocess_cache_dir, default_timeout=0)
self.resolver = NautilusCTSResolver(
subprocess_repository,
dispatcher=make_dispatcher(),
cache=self.cache
)
self.app = Flask("Nautilus")
self.nautilus = FlaskNautilus(
app=self.app,
prefix="/api",
name="nautilus",
resolver=self.resolver,
flask_caching=self.http_cache
)
self.http_cache.init_app(self.app)

self.test_client = self.app.test_client()

# Option to ensure cache works
self.former_parse = self.resolver.parse
Expand Down

0 comments on commit 34eb3fb

Please sign in to comment.