From da9a37a406997a46fc42113be4ee05a17014cd44 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Tue, 2 Aug 2016 04:58:00 +0200 Subject: [PATCH] Fixes in tests and add check_login function to admin cntroller --- paramecio/console.py | 9 +++++++++ paramecio/modules/admin/index.py | 4 ++-- tests/arrayfieldtest.py | 3 ++- tests/datetimetest.py | 5 ++++- tests/dictfieldtest.py | 5 ++--- tests/fieldstest.py | 2 ++ tests/i18nfieldtest.py | 4 +++- tests/imagefieldtest.py | 3 +++ tests/sendmailtest.py | 3 +++ tests/slugifytest.py | 4 +++- 10 files changed, 33 insertions(+), 9 deletions(-) diff --git a/paramecio/console.py b/paramecio/console.py index 81ee08d..d3bc9ca 100644 --- a/paramecio/console.py +++ b/paramecio/console.py @@ -22,6 +22,8 @@ def start(): parser.add_argument('--symlink', help='Set if create direct symlink to paramecio in new site', required=False, nargs='?', const='1') + parser.add_argument('--tests', help='Create a symlink to tests for check into paramecio site', required=False, nargs='?', const='1') + # Options for deploy parser.add_argument('--domain', help='The base domain for this site', required=True) @@ -125,6 +127,13 @@ def start(): except: print('Error: cannot symlink paramecio in new site') + + if args.tests!=None: + try: + os.symlink(workdir, args.path+'/paramecio/', True) + + except: + print('Error: cannot symlink paramecio in new site') with open(path_settings+'/config.py', 'r') as f: conf=f.read() diff --git a/paramecio/modules/admin/index.py b/paramecio/modules/admin/index.py index 1a0e860..67a7071 100644 --- a/paramecio/modules/admin/index.py +++ b/paramecio/modules/admin/index.py @@ -10,7 +10,7 @@ from bottle import get,post,response,request from settings import config from settings import config_admin from paramecio.citoplasma.lists import SimpleList -from paramecio.citoplasma.adminutils import get_menu, get_language, make_admin_url +from paramecio.citoplasma.adminutils import get_menu, get_language, make_admin_url, check_login from paramecio.citoplasma.generate_admin_class import GenerateAdminClass from paramecio.citoplasma.httputils import GetPostFiles from paramecio.cromosoma.formsutils import show_form, pass_values_to_form, set_extra_forms_user @@ -72,7 +72,7 @@ def home(module='', submodule=''): s=get_session() - if 'login' in s: + if check_login(): s['id']=s.get('id', 0) diff --git a/tests/arrayfieldtest.py b/tests/arrayfieldtest.py index 3e49a31..d6ea96f 100644 --- a/tests/arrayfieldtest.py +++ b/tests/arrayfieldtest.py @@ -28,4 +28,5 @@ class TestFieldMethods(unittest.TestCase): self.assertEqual(json_encoded, '["trick", "mytuquito", "25"]') - +if __name__ == '__main__': + unittest.main() diff --git a/tests/datetimetest.py b/tests/datetimetest.py index 833e50a..08cd045 100644 --- a/tests/datetimetest.py +++ b/tests/datetimetest.py @@ -66,4 +66,7 @@ class TestFieldMethods(unittest.TestCase): self.assertEqual(value, '00:24:21') print(datetime.local_to_utc('20121221232421', tz)) - """ \ No newline at end of file + """ + +if __name__ == '__main__': + unittest.main() diff --git a/tests/dictfieldtest.py b/tests/dictfieldtest.py index 16df61a..4a3c6ef 100644 --- a/tests/dictfieldtest.py +++ b/tests/dictfieldtest.py @@ -54,6 +54,5 @@ class TestFieldMethods(unittest.TestCase): self.assertEqual(value_two, value_real) - - - +if __name__ == '__main__': + unittest.main() diff --git a/tests/fieldstest.py b/tests/fieldstest.py index fe22f49..8fabed5 100644 --- a/tests/fieldstest.py +++ b/tests/fieldstest.py @@ -57,3 +57,5 @@ class TestFieldMethods(unittest.TestCase): self.assertFalse(emailfield.error) +if __name__ == '__main__': + unittest.main() diff --git a/tests/i18nfieldtest.py b/tests/i18nfieldtest.py index 33b77f2..b4c57c2 100644 --- a/tests/i18nfieldtest.py +++ b/tests/i18nfieldtest.py @@ -36,4 +36,6 @@ class TestFieldMethods(unittest.TestCase): #self.assertEqual(phrase, 'this---is-a-crap-phrase-o---f-oh-yeah--') - \ No newline at end of file + +if __name__ == '__main__': + unittest.main() diff --git a/tests/imagefieldtest.py b/tests/imagefieldtest.py index 5fd5a85..eaa36da 100644 --- a/tests/imagefieldtest.py +++ b/tests/imagefieldtest.py @@ -63,3 +63,6 @@ class TestImageFieldMethods(unittest.TestCase): self.assertEqual(value, "injection_\\'")""" + +if __name__ == '__main__': + unittest.main() diff --git a/tests/sendmailtest.py b/tests/sendmailtest.py index 085ba21..1905322 100644 --- a/tests/sendmailtest.py +++ b/tests/sendmailtest.py @@ -20,3 +20,6 @@ class TestFieldMethods(unittest.TestCase): self.assertTrue( s.send(config.portal_email, [config.email_test], 'This is a test', 'A message for test a simple email method in html and attachments', content_type='html', attachments=['tests/images/image.jpg']) ) #s.quit() + +if __name__ == '__main__': + unittest.main() diff --git a/tests/slugifytest.py b/tests/slugifytest.py index a177fd0..5a49b93 100644 --- a/tests/slugifytest.py +++ b/tests/slugifytest.py @@ -10,4 +10,6 @@ class TestFieldMethods(unittest.TestCase): self.assertEqual(phrase, 'this---is-a-crap-phrase-o---f-oh-yeah--') - \ No newline at end of file + +if __name__ == '__main__': + unittest.main()