Skip to content

Commit

Permalink
tests/i: clean tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Jun 18, 2020
1 parent 0d8ea68 commit b58c523
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 23 deletions.
34 changes: 21 additions & 13 deletions tests/integration/test_data_store_mgr.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest

from cylc.flow.data_store_mgr import (
DataStoreMgr, task_mean_elapsed_time, ID_DELIM,
FAMILY_PROXIES, TASKS, TASK_PROXIES, WORKFLOW
FAMILY_PROXIES,
TASKS,
TASK_PROXIES,
WORKFLOW
)


Expand All @@ -12,10 +29,7 @@ async def harness(mod_flow, mod_scheduler, mod_run, mod_one_conf):
reg = mod_flow(mod_one_conf)
schd = mod_scheduler(reg)
async with mod_run(schd):
# TODO - sleep or do the generation here
data = schd.data_store_mgr.data[schd.data_store_mgr.workflow_id]
# schd.data_store_mgr.generate_definition_elements()
# schd.data_store_mgr.apply_deltas()
yield schd, data


Expand Down Expand Up @@ -63,9 +77,6 @@ def test_get_entire_workflow(harness):
def test_increment_graph_elements(harness):
"""Test method that adds and removes elements by cycle point."""
schd, data = harness
# schd.data_store_mgr.generate_definition_elements()
# schd.data_store_mgr.increment_graph_elements()
# schd.data_store_mgr.apply_deltas()
assert schd.data_store_mgr.pool_points
assert len(data[TASK_PROXIES]) == 1

Expand Down Expand Up @@ -94,7 +105,6 @@ def test_update_data_structure(harness):
"""Test update_data_structure. This method will generate and
apply deltas/updates given."""
schd, data = harness
# TODO: this was == 0 before
assert len(collect_states(data, TASK_PROXIES)) == 1
update_tasks = schd.pool.get_all_tasks()
schd.data_store_mgr.update_data_structure(update_tasks)
Expand All @@ -106,7 +116,6 @@ def test_update_family_proxies(harness):
"""Test update_family_proxies. This method will update all
DataStoreMgr task_proxies of given cycle point strings."""
schd, data = harness
# TODO: this was == 0 before
assert len(collect_states(data, FAMILY_PROXIES)) == 1
update_tasks = schd.pool.get_all_tasks()
update_points = set((str(t.point) for t in update_tasks))
Expand All @@ -129,7 +138,6 @@ def test_update_task_proxies(harness):
task instances (TaskProxy), and update any corresponding
DataStoreMgr task_proxies."""
schd, data = harness
# TODO: this was == 0 before
assert len(collect_states(data, TASK_PROXIES)) == 1
update_tasks = schd.pool.get_all_tasks()
schd.data_store_mgr.clear_deltas()
Expand All @@ -139,6 +147,7 @@ def test_update_task_proxies(harness):
assert len(update_tasks) == len(collect_states(data, TASK_PROXIES))


@pytest.mark.skip('TODO: fix this test')
def test_update_workflow(harness):
"""Test method that updates the dynamic fields of the workflow msg."""
schd, data = harness
Expand All @@ -148,5 +157,4 @@ def test_update_workflow(harness):
schd.data_store_mgr.update_workflow()
schd.data_store_mgr.apply_deltas()
new_time = data[WORKFLOW].last_updated
# assert new_time > old_time
# TODO: this test no longer works
assert new_time > old_time
20 changes: 17 additions & 3 deletions tests/integration/test_publisher.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from async_timeout import timeout
import pytest

Expand All @@ -7,6 +22,7 @@
)


@pytest.mark.skip('TODO: the delta doesnt seem to have an id for some reason')
@pytest.mark.asyncio
async def test_publisher(flow, scheduler, run, one_conf, port_range):
"""It should publish deltas when the flow starts."""
Expand All @@ -26,6 +42,4 @@ async def test_publisher(flow, scheduler, run, one_conf, port_range):
btopic, msg = await subscriber.socket.recv_multipart()

_, delta = process_delta_msg(btopic, msg, None)
# assert schd.id == delta.id
assert True # TODO
# fix this test, the delta doesn't have the ID apparently
assert schd.id == delta.id
25 changes: 18 additions & 7 deletions tests/integration/test_resolvers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
# THIS FILE IS PART OF THE CYLC SUITE ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from unittest.mock import Mock

import pytest

from cylc.flow.data_store_mgr import (
DataStoreMgr, ID_DELIM, EDGES, TASK_PROXIES, WORKFLOW
)
from cylc.flow.network.resolvers import node_filter, Resolvers
from cylc.flow.data_store_mgr import ID_DELIM, EDGES, TASK_PROXIES
from cylc.flow.network.resolvers import Resolvers
from cylc.flow.network.schema import parse_node_id


Expand Down Expand Up @@ -107,16 +120,14 @@ async def test_get_nodes_by_ids(flow, node_args):
nodes = await flow.resolvers.get_nodes_by_ids(TASK_PROXIES, node_args)
assert len(nodes) == 0

# assert flow.scheduler.data_store_mgr.data == None

node_args['ghosts'] = True
node_args['native_ids'] = flow.node_ids
nodes = [
n
for n in await flow.resolvers.get_nodes_by_ids(
TASK_PROXIES, node_args
)
# if n in flow.data[TASK_PROXIES].values()
if n in flow.data[TASK_PROXIES].values()
]
assert len(nodes) > 0

Expand Down

0 comments on commit b58c523

Please sign in to comment.