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)
Exemplo n.º 2
0
    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)
Exemplo n.º 4
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_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)
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
    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_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)
        ])