def test_load_fixtures_with_given_nodes(self): """ Case: Load fixtures get called with a given list of nodes Expected: resolve_nodes method get called with the list of nodes """ runner = LoadFixtureRunner() runner._graph = self.graph_mock() runner._graph.resolve_nodes.return_value = [ ("app_one", "0001_my_fixture"), ("app_one", "0002_my_other_fixture"), ] runner.loader = self.loader_mock() runner.loader.disk_fixtures = { ("app_one", "0001_my_fixture"): mock.MagicMock(), ("app_one", "0002_my_other_fixture"): mock.MagicMock(), ("app_two", "0001_my_other_fixture"): mock.MagicMock(), } runner.load_fixtures( nodes=[("app_one", "0001_my_fixture"), ("app_one", "0002_my_other_fixture")]) runner.graph.resolve_nodes.assert_called_once_with([ ("app_one", "0001_my_fixture"), ("app_one", "0002_my_other_fixture") ]) runner.loader.disk_fixtures[( "app_one", "0001_my_fixture")].load.assert_called_once_with() runner.loader.disk_fixtures[( "app_one", "0002_my_other_fixture")].load.assert_called_once_with() self.assertFalse( runner.loader.disk_fixtures[("app_two", "0001_my_other_fixture")].load.called)
def test_load_fixtures_with_given_nodes(self): """ Case: Load fixtures get called with a given list of nodes Expected: resolve_nodes method get called with the list of nodes """ runner = LoadFixtureRunner() runner._graph = self.graph_mock() runner._graph.resolve_nodes.return_value = [ ('app_one', '0001_my_fixture'), ('app_one', '0002_my_other_fixture'), ] runner.loader = self.loader_mock() runner.loader.disk_fixtures = { ('app_one', '0001_my_fixture'): mock.MagicMock(), ('app_one', '0002_my_other_fixture'): mock.MagicMock(), ('app_two', '0001_my_other_fixture'): mock.MagicMock() } runner.load_fixtures(nodes=[('app_one', '0001_my_fixture'), ('app_one', '0002_my_other_fixture')]) runner.graph.resolve_nodes.assert_called_once_with([ ('app_one', '0001_my_fixture'), ('app_one', '0002_my_other_fixture') ]) runner.loader.disk_fixtures[ ('app_one', '0001_my_fixture')].load.assert_called_once_with() runner.loader.disk_fixtures[ ('app_one', '0002_my_other_fixture')].load.assert_called_once_with() self.assertFalse(runner.loader.disk_fixtures[ ('app_two', '0001_my_other_fixture')].load.called)
def test_load_fixtures_return_value_no_fixtures(self): """ Case: No fixtures found Expected: 0 as return value """ runner = LoadFixtureRunner() runner._graph = self.graph_mock() runner._graph.resolve_node.return_value = [] runner.loader = self.loader_mock() runner.loader.disk_fixtures = {} self.assertEqual(runner.load_fixtures(), 0)
def test_load_fixtures_return_value_no_fixtures(self): """ Case: No fixtures found Expected: 0 as return value """ runner = LoadFixtureRunner() runner._graph = self.graph_mock() runner._graph.resolve_node.return_value = [] runner.loader = self.loader_mock() runner.loader.disk_fixtures = {} self.assertEqual(runner.load_fixtures(), 0)
def test_get_app_nodes(self): """ Case: Get filtered app nodes Expected: Only app nodes which from given app get returned """ runner = LoadFixtureRunner() graph = self.graph_mock() graph.nodes = [ ("app_one", "foo"), ("app_one", "bar"), ("app_two", "foo"), ] runner._graph = graph app_nodes = runner.get_app_nodes("app_one") self.assertListEqual(app_nodes, [("app_one", "foo"), ("app_one", "bar")])
def test_load_fixtures_return_value_two_fixtures(self): """ Case: Two fictures get loaded Expected: 2 as return value """ runner = LoadFixtureRunner() runner._graph = self.graph_mock() runner._graph.resolve_node.return_value = [ ('app_one', '0001_my_fixture'), ('app_one', '0002_my_other_fixture'), ] runner.loader = self.loader_mock() runner.loader.disk_fixtures = { ('app_one', '0001_my_fixture'): mock.MagicMock(), ('app_one', '0002_my_other_fixture'): mock.MagicMock() } self.assertEqual(runner.load_fixtures(), 2)
def test_load_fixtures_return_value_two_fixtures(self): """ Case: Two fictures get loaded Expected: 2 as return value """ runner = LoadFixtureRunner() runner._graph = self.graph_mock() runner._graph.resolve_node.return_value = [ ("app_one", "0001_my_fixture"), ("app_one", "0002_my_other_fixture"), ] runner.loader = self.loader_mock() runner.loader.disk_fixtures = { ("app_one", "0001_my_fixture"): mock.MagicMock(), ("app_one", "0002_my_other_fixture"): mock.MagicMock(), } self.assertEqual(runner.load_fixtures(), 2)
def test_load_fixtures(self): """ Case: Fixtures get loaded Expected: For every fixture the load method get called """ runner = LoadFixtureRunner() runner._graph = self.graph_mock() runner._graph.resolve_node.return_value = [ ("app_one", "0001_my_fixture"), ("app_one", "0002_my_other_fixture"), ("app_two", "0001_my_other_fixture"), ] runner.loader = self.loader_mock() runner.loader.disk_fixtures = { ("app_one", "0001_my_fixture"): mock.MagicMock(), ("app_one", "0002_my_other_fixture"): mock.MagicMock(), ("app_two", "0001_my_other_fixture"): mock.MagicMock(), } call_back = mock.Mock(return_value=None) runner.load_fixtures(progress_callback=call_back) runner.graph.resolve_node.assert_called_once_with() for fixture_mock in runner.loader.disk_fixtures.values(): fixture_mock.load.assert_called_once_with() call_back.assert_has_calls([ mock.call("load_start", ("app_one", "0001_my_fixture")), mock.call("load_success", ("app_one", "0001_my_fixture"), mock.ANY), mock.call("load_start", ("app_one", "0002_my_other_fixture")), mock.call("load_success", ("app_one", "0002_my_other_fixture"), mock.ANY), mock.call("load_start", ("app_two", "0001_my_other_fixture")), mock.call("load_success", ("app_two", "0001_my_other_fixture"), mock.ANY), ])
def test_get_app_nodes(self): """ Case: Get filtered app nodes Expected: Only app nodes which from given app get returned """ runner = LoadFixtureRunner() graph = self.graph_mock() graph.nodes = [ ('app_one', 'foo'), ('app_one', 'bar'), ('app_two', 'foo'), ] runner._graph = graph app_nodes = runner.get_app_nodes('app_one') self.assertListEqual( app_nodes, [ ('app_one', 'foo'), ('app_one', 'bar'), ] )
def test_load_fixtures(self): """ Case: Fixtures get loaded Expected: For every fixture the load method get called """ runner = LoadFixtureRunner() runner._graph = self.graph_mock() runner._graph.resolve_node.return_value = [ ('app_one', '0001_my_fixture'), ('app_one', '0002_my_other_fixture'), ('app_two', '0001_my_other_fixture'), ] runner.loader = self.loader_mock() runner.loader.disk_fixtures = { ('app_one', '0001_my_fixture'): mock.MagicMock(), ('app_one', '0002_my_other_fixture'): mock.MagicMock(), ('app_two', '0001_my_other_fixture'): mock.MagicMock() } call_back = mock.Mock(return_value=None) runner.load_fixtures(progress_callback=call_back) runner.graph.resolve_node.assert_called_once_with() for fixture_mock in runner.loader.disk_fixtures.values(): fixture_mock.load.assert_called_once_with() call_back.assert_has_calls([ mock.call('load_start', ('app_one', '0001_my_fixture')), mock.call('load_success', ('app_one', '0001_my_fixture'), mock.ANY), mock.call('load_start', ('app_one', '0002_my_other_fixture')), mock.call('load_success', ('app_one', '0002_my_other_fixture'), mock.ANY), mock.call('load_start', ('app_two', '0001_my_other_fixture')), mock.call('load_success', ('app_two', '0001_my_other_fixture'), mock.ANY) ])