diff --git a/tests/__init__.py b/tests/__init__.py index 9ac0ce6c..fee0ffab 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -58,6 +58,11 @@ def clean_database(): def init_data(): clean_database() + with make_session(conf) as session: + _populate_data(session) + + +def _populate_data(session): for index in range(10): build_one = ModuleBuild() build_one.name = 'nginx' @@ -79,6 +84,8 @@ def init_data(): build_one.time_completed = \ datetime(2016, 9, 3, 11, 25, 32) + timedelta(minutes=(index * 10)) build_one.rebuild_strategy = 'changed-and-after' + session.add(build_one) + session.commit() build_one_component_release = get_rpm_release(build_one) component_one_build_one = ComponentBuild() @@ -128,6 +135,8 @@ def init_data(): build_two.time_completed = \ datetime(2016, 9, 3, 11, 27, 19) + timedelta(minutes=(index * 10)) build_two.rebuild_strategy = 'changed-and-after' + session.add(build_two) + session.commit() build_two_component_release = get_rpm_release(build_two) component_one_build_two = ComponentBuild() @@ -176,6 +185,8 @@ def init_data(): datetime(2016, 9, 3, 12, 28, 40) + timedelta(minutes=(index * 10)) build_three.time_completed = None build_three.rebuild_strategy = 'changed-and-after' + session.add(build_three) + session.commit() build_three_component_release = get_rpm_release(build_three) component_one_build_three = ComponentBuild() @@ -206,17 +217,13 @@ def init_data(): component_two_build_three.tagged = True component_two_build_three.build_time_only = True - with make_session(conf) as session: - session.add(build_one) - session.add(component_one_build_one) - session.add(component_two_build_one) - session.add(component_one_build_two) - session.add(component_two_build_two) - session.add(component_one_build_three) - session.add(component_two_build_three) - session.add(build_two) - session.add(build_three) - session.commit() + session.add(component_one_build_one) + session.add(component_two_build_one) + session.add(component_one_build_two) + session.add(component_two_build_two) + session.add(component_one_build_three) + session.add(component_two_build_three) + session.commit() def scheduler_init_data(communicator_state=None): diff --git a/tests/test_views/test_views.py b/tests/test_views/test_views.py index 7a7dc24c..2e924a6b 100644 --- a/tests/test_views/test_views.py +++ b/tests/test_views/test_views.py @@ -142,13 +142,13 @@ class TestViews(unittest.TestCase): 'task_id': 12312321, 'state': 1, 'state_reason': None, - 'nvr': 'module-build-macros-01-1.module+0+b8661ee4', + 'nvr': 'module-build-macros-01-1.module+1+b8661ee4', }, 'nginx': { 'task_id': 12312345, 'state': 1, 'state_reason': None, - 'nvr': 'nginx-1.10.1-2.module+0+b8661ee4', + 'nvr': 'nginx-1.10.1-2.module+1+b8661ee4', }, }, }) @@ -199,13 +199,13 @@ class TestViews(unittest.TestCase): 'task_id': 12312321, 'state': 1, 'state_reason': None, - 'nvr': 'module-build-macros-01-1.module+0+b8661ee4', + 'nvr': 'module-build-macros-01-1.module+1+b8661ee4', }, 'nginx': { 'task_id': 12312345, 'state': 1, 'state_reason': None, - 'nvr': 'nginx-1.10.1-2.module+0+b8661ee4', + 'nvr': 'nginx-1.10.1-2.module+1+b8661ee4', }, }, }) @@ -262,13 +262,13 @@ class TestViews(unittest.TestCase): 'tasks': { 'rpms': { 'module-build-macros': { - 'nvr': 'module-build-macros-01-1.module+0+8d3cee59', + 'nvr': 'module-build-macros-01-1.module+30+8d3cee59', 'state': 1, 'state_reason': None, 'task_id': 47384002 }, 'rubygem-rails': { - 'nvr': 'postgresql-9.5.3-4.module+0+8d3cee59', + 'nvr': 'postgresql-9.5.3-4.module+30+8d3cee59', 'state': 3, 'state_reason': None, 'task_id': 2433442 @@ -296,13 +296,13 @@ class TestViews(unittest.TestCase): 'tasks': { 'rpms': { 'module-build-macros': { - 'nvr': 'module-build-macros-01-1.module+0+0557c87d', + 'nvr': 'module-build-macros-01-1.module+29+0557c87d', 'state': 1, 'state_reason': None, 'task_id': 47384002 }, 'postgresql': { - 'nvr': 'postgresql-9.5.3-4.module+0+0557c87d', + 'nvr': 'postgresql-9.5.3-4.module+29+0557c87d', 'state': 1, 'state_reason': None, 'task_id': 2433442 @@ -391,9 +391,9 @@ class TestViews(unittest.TestCase): def test_query_component_builds_filter_nvr(self): rv = self.client.get('/module-build-service/1/component-builds/?nvr=nginx-1.10.1-2.' - 'module%2B0%2Bb8661ee4') + 'module%2B1%2Bb8661ee4') data = json.loads(rv.data) - self.assertEquals(data['meta']['total'], 10) + self.assertEquals(data['meta']['total'], 1) def test_query_component_builds_filter_task_id(self): rv = self.client.get('/module-build-service/1/component-builds/?task_id=12312346')