From 500ced23bf37c36a16c75185a1ec34df9ded350e Mon Sep 17 00:00:00 2001
From: anonymous <anonymous>
Date: Wed, 9 Jan 2019 13:17:00 +0100
Subject: [PATCH] add kiel text and fix login problem

---
 ckanext/odsh/commands/initialization.py |  2 +-
 ckanext/odsh/templates/macros/form.html |  6 ++---
 ckanext/odsh/tests/test_user.py         | 35 +++++++++++++++++++------
 3 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/ckanext/odsh/commands/initialization.py b/ckanext/odsh/commands/initialization.py
index a5a8b5b7..043d8e8f 100755
--- a/ckanext/odsh/commands/initialization.py
+++ b/ckanext/odsh/commands/initialization.py
@@ -113,7 +113,7 @@ class Initialization(CkanCommand):
                 'active': True,
                 'owner_org': "landeshauptstadt-kiel",
                 'frequency': "MANUAL",
-                'notes': "Kommunalverwaltung"
+                'notes': "Die Stadt Kiel ist die nördlichste Großstadt Deutschlands und die Landeshauptstadt Schleswig-Holsteins. Als kreisfreie Stadt erledigt sie neben den kommunalen Selbstverwaltungsaufgaben auch Aufgaben einer unteren staatlichen Verwaltungsbehörde und erzeugt, erhebt und verarbeitet als Gebietskörperschaft eine Vielzahl von Daten mit lokalem Bezug."
             },
             "Statistisches Amt für Hamburg und Schleswig-Holstein - Anstalt des öffentlichen Rechts - (Statistikamt Nord)": {
                 'name': u"statistikamt-nord",
diff --git a/ckanext/odsh/templates/macros/form.html b/ckanext/odsh/templates/macros/form.html
index d519c3fe..7ad0a9f0 100644
--- a/ckanext/odsh/templates/macros/form.html
+++ b/ckanext/odsh/templates/macros/form.html
@@ -31,10 +31,10 @@ is_required=false) %}
             placeholder="{{ placeholder }}" {{ onFocus }} {{ attributes(attrs) }} />
     </div>
     <div class="span6 inline-error">
-        {% if error is string %}
-        {{error}}
-        {% else %}
+        {% if error is iterable and error is not string %}
         {{error|first}}
+        {% else %}
+        {{error}}
         {% endif %}
     </div>
 </div>
diff --git a/ckanext/odsh/tests/test_user.py b/ckanext/odsh/tests/test_user.py
index 1d3ed028..fe209c8e 100644
--- a/ckanext/odsh/tests/test_user.py
+++ b/ckanext/odsh/tests/test_user.py
@@ -31,12 +31,10 @@ class TestUser(helpers.FunctionalTestBase):
 
     @odsh_test()
     def test_user_logout(self):
-        app = self._get_test_app()
-
-        logout_url = url_for(controller='user', action='logout')
-        logout_response = app.get(logout_url, status=302)
-        final_response = helpers.webtest_maybe_follow(logout_response)
+        #act
+        final_response = self._logout()
 
+        # assert
         assert_true('You are now logged out.' in final_response)
 
     @odsh_test()
@@ -48,10 +46,21 @@ class TestUser(helpers.FunctionalTestBase):
         # act
         response = self._open_url('/user/'+user['name'])
 
-        # arrange
+        # assert
         # we land on the default search page
         response.mustcontain('API Key')
 
+    @odsh_test()
+    def test_user_login_wrong_password(self):
+        # arrange
+        user = factories.User()
+
+        # act
+        response = self._login_user(user, 'wrong')
+
+        # assert
+        response.mustcontain('Login failed. Bad username or password.')
+
     def _open_url(self, url):
         app = self._get_test_app()
         return app.get(url)
@@ -61,11 +70,21 @@ class TestUser(helpers.FunctionalTestBase):
         # let's go to the last redirect in the chain
         return helpers.webtest_maybe_follow(submit_response)
 
-    def _login_user(self, user):
+    def _login_user(self, user, password=None):
         response = self._open_url('/user/login')
         login_form = response.forms[0]
 
         login_form['login'] = user['name']
-        login_form['password'] = 'pass'
+        if password is None:
+            password = 'pass'
+        login_form['password'] = password
 
         return self._submit_form(login_form)
+
+    def _logout(self):
+        app = self._get_test_app()
+
+        logout_url = url_for(controller='user', action='logout')
+        logout_response = app.get(logout_url, status=302)
+        final_response = helpers.webtest_maybe_follow(logout_response)
+        return final_response
\ No newline at end of file
-- 
GitLab