From b63f2839d148bdcea36819b7cd786343bec907c7 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 15 2017 15:45:02 +0000 Subject: Fix running the unit-tests against faitout --- diff --git a/tests/test_pagure_flask_api_project.py b/tests/test_pagure_flask_api_project.py index 6f5d2cc..9e510a3 100644 --- a/tests/test_pagure_flask_api_project.py +++ b/tests/test_pagure_flask_api_project.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ - (c) 2015 - Copyright Red Hat Inc + (c) 2015-2017 - Copyright Red Hat Inc Authors: Pierre-Yves Chibon @@ -374,6 +374,7 @@ class PagureFlaskApiProjecttests(tests.Modeltests): """ Test the api_new_project method of the flask api. """ p_gga.return_value = True + tests.create_projects(self.session) tests.create_projects_git(os.path.join(self.path, 'tickets')) tests.create_tokens(self.session) tests.create_tokens_acl(self.session) @@ -437,7 +438,8 @@ class PagureFlaskApiProjecttests(tests.Modeltests): self.assertDictEqual( data, { - "error": "The tickets repo \"test.git\" already exists", + "error": "The project repo \"test\" already exists " + "in the database", "error_code": "ENOCODE" } ) diff --git a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py index 63daf1c..a9fb004 100644 --- a/tests/test_pagure_lib_git.py +++ b/tests/test_pagure_lib_git.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ - (c) 2015 - Copyright Red Hat Inc + (c) 2015-2017 - Copyright Red Hat Inc Authors: Pierre-Yves Chibon @@ -12,11 +12,14 @@ __requires__ = ['SQLAlchemy >= 0.8'] import pkg_resources -import unittest +import datetime +import os import shutil import sys -import os import tempfile +import time +import unittest + import pygit2 from mock import patch @@ -1206,6 +1209,12 @@ index 0000000..60f7480 #print patch self.assertEqual(patch, exp) + # Enforce having a different last_updated field + # This is required as the test run fine and fast with sqlite but is + # much slower with postgresql so we end-up with an updated + # last_updated in postgresql but not with sqlite + time.sleep(1) + # Test again after adding a comment msg = pagure.lib.add_issue_comment( session=self.session, @@ -1232,7 +1241,7 @@ diff --git a/123 b/456 index 458821a..77674a8 --- a/123 +++ b/456 -@@ -3,7 +3,25 @@ +@@ -3,13 +3,31 @@ "blocks": [], "close_status": null, "closed_at": null, @@ -1259,6 +1268,13 @@ index 458821a..77674a8 "content": "We should work on this", "custom_fields": [], "date_created": null, + "depends": [], + "id": 1, +- "last_updated": "", ++ "last_updated": "", + "milestone": null, + "priority": null, + "private": false, """ npatch = [] @@ -1288,6 +1304,9 @@ index 458821a..77674a8 row = '--- a/123' elif row.startswith('+++ b/'): row = '+++ b/456' + elif 'last_updated' in row: + t = row.split(': ')[0] + row = '%s: "",' % t npatch.append(row) patch = '\n'.join(npatch) #print patch diff --git a/tests/test_pagure_lib_model.py b/tests/test_pagure_lib_model.py index 336ecfe..48e45eb 100644 --- a/tests/test_pagure_lib_model.py +++ b/tests/test_pagure_lib_model.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ - (c) 2015 - Copyright Red Hat Inc + (c) 2015-2017 - Copyright Red Hat Inc Authors: Pierre-Yves Chibon @@ -205,7 +205,7 @@ class PagureLibModeltests(tests.Modeltests): group_name='testgrp', display_name='Test group', description=None, - group_type='users', + group_type='user', user_id=1, # pingou ) item.close_status = ['Invalid', 'Fixed', 'Duplicate']