Exemple #1
0
    def test_groups(self):
        mock_value = MagicMock(spec=list)

        mgr = manager.AOVManager()
        mgr._groups = mock_value

        self.assertEqual(mgr.groups, mock_value)
Exemple #2
0
    def test_aovs(self):
        mock_value = MagicMock(spec=list)

        mgr = manager.AOVManager()
        mgr._aovs = mock_value

        self.assertEqual(mgr.aovs, mock_value)
Exemple #3
0
    def test_reload(self, mock_clear, mock_init):
        mgr = manager.AOVManager()

        mgr.reload()

        mock_clear.assert_called()
        mock_init.assert_called()
Exemple #4
0
    def test___init__(self, mock_init):
        mgr = manager.AOVManager()

        self.assertEqual(mgr._aovs, {})
        self.assertEqual(mgr._groups, {})
        self.assertIsNone(mgr._interface)
        mock_init.assert_called()
Exemple #5
0
    def test__init_from_files(self, mock_find, mock_file, mock_merge, mock_build):
        mock_path = MagicMock(spec=str)
        mock_find.return_value = [mock_path]

        mgr = manager.AOVManager()
        mgr._init_from_files()

        mock_file.assert_called_with(mock_path)
        mock_merge.assert_called_with([mock_file.return_value])
        mock_build.assert_called()
Exemple #6
0
    def test__merge_readers(self, mock_init_aovs, mock_init_groups):
        mock_reader = MagicMock(spec=manager.AOVFile)

        readers = [mock_reader]

        mgr = manager.AOVManager()
        mgr._merge_readers(readers)

        mock_init_aovs.assert_called_with(mock_reader)
        mock_init_groups.assert_called_with(mock_reader)
Exemple #7
0
    def test_load(self, mock_file, mock_merge):
        mgr = manager.AOVManager()

        mock_path = MagicMock(spec=str)

        mgr.load(mock_path)

        mock_file.assert_called_with(mock_path)

        mock_merge.assert_called_with([mock_file.return_value])
Exemple #8
0
    def test___init__(self, mocker):
        """Test object initialization."""
        mock_init = mocker.patch(
            "ht.sohohooks.aovs.manager.AOVManager._init_from_files")

        mgr = manager.AOVManager()

        assert mgr._aovs == {}
        assert mgr._groups == {}
        assert mgr._interface is None
        mock_init.assert_called()
Exemple #9
0
    def test_get_aovs_from_string__no_matches(self, mock_aovs, mock_groups):
        mock_aovs.return_value = {}
        mock_groups.return_value = {}

        mgr = manager.AOVManager()

        pattern = ""

        result = mgr.get_aovs_from_string(pattern)

        self.assertEqual(result, ())
Exemple #10
0
    def test_add_aov__no_interface(self, mock_aovs, mock_interface):
        aovs = {}

        mock_aovs.return_value = aovs

        mock_aov = MagicMock(spec=manager.AOV)

        mgr = manager.AOVManager()
        mgr.add_aov(mock_aov)

        self.assertEqual(aovs, {mock_aov.variable: mock_aov})
Exemple #11
0
    def test_add_group__no_interface(self, mock_groups, mock_interface):
        groups = {}

        mock_groups.return_value = groups

        mock_group = MagicMock(spec=manager.AOVGroup)

        mgr = manager.AOVManager()
        mgr.add_group(mock_group)

        self.assertEqual(groups, {mock_group.name: mock_group})
Exemple #12
0
    def test_remove_aov__no_match(self, mock_aovs, mock_interface):
        mock_aov1 = MagicMock(spec=manager.AOV)
        mock_aov2 = MagicMock(spec=manager.AOV)

        aovs = {mock_aov2.variable: mock_aov2}
        mock_aovs.return_value = aovs

        mgr = manager.AOVManager()

        mgr.remove_aov(mock_aov1)

        self.assertEqual(aovs, {mock_aov2.variable: mock_aov2})
Exemple #13
0
    def test_clear(self):
        mock_aovs = MagicMock(spec=dict)
        mock_groups = MagicMock(spec=dict)

        mgr = manager.AOVManager()
        mgr._aovs = mock_aovs
        mgr._groups = mock_groups

        mgr.clear()

        mock_aovs.clear.assert_called()
        mock_groups.clear.assert_called()
Exemple #14
0
    def test_init_interface(self):
        mock_utils = MagicMock()

        modules = {"ht.ui.aovs.utils": mock_utils}

        mgr = manager.AOVManager()

        with patch.dict("sys.modules", modules):
            mgr.init_interface()

        self.assertEqual(mgr._interface,
                         mock_utils.AOVViewerInterface.return_value)
Exemple #15
0
    def test__init_reader_aovs__new_aov(self, mock_aovs, mock_add):
        mock_aov = MagicMock(spec=manager.AOV)

        mock_reader = MagicMock(spec=manager.AOVFile)
        mock_reader.aovs = [mock_aov]

        mock_aovs.return_value = {}

        mgr = manager.AOVManager()
        mgr._init_reader_aovs(mock_reader)

        mock_add.assert_called_with(mock_aov)
Exemple #16
0
    def test_remove_group__no_match(self, mock_groups, mock_interface):
        mock_group1 = MagicMock(spec=manager.AOVGroup)
        mock_group2 = MagicMock(spec=manager.AOVGroup)

        groups = {mock_group2.name: mock_group2}
        mock_groups.return_value = groups

        mgr = manager.AOVManager()

        mgr.remove_group(mock_group1)

        self.assertEqual(groups, {mock_group2.name: mock_group2})
Exemple #17
0
    def test_remove_group__match_no_interface(self, mock_groups, mock_interface):
        mock_interface.return_value = None

        mock_group = MagicMock(spec=manager.AOVGroup)

        groups = {mock_group.name: mock_group}
        mock_groups.return_value = groups

        mgr = manager.AOVManager()

        mgr.remove_group(mock_group)

        self.assertEqual(groups, {})
Exemple #18
0
    def test_remove_aov__match_no_interface(self, mock_aovs, mock_interface):
        mock_interface.return_value = None

        mock_aov = MagicMock(spec=manager.AOV)

        aovs = {mock_aov.variable: mock_aov}
        mock_aovs.return_value = aovs

        mgr = manager.AOVManager()

        mgr.remove_aov(mock_aov)

        self.assertEqual(aovs, {})
Exemple #19
0
    def test_add_aov__interface(self, mock_aovs, mock_interface):
        interface = MagicMock()
        mock_interface.return_value = interface

        aovs = {}
        mock_aovs.return_value = aovs

        mock_aov = MagicMock(spec=manager.AOV)

        mgr = manager.AOVManager()
        mgr.add_aov(mock_aov)

        self.assertEqual(aovs, {mock_aov.variable: mock_aov})
        interface.aovAddedSignal.emit.assert_called_with(mock_aov)
Exemple #20
0
    def test_get_aovs_from_string__groups_match_commas(self, mock_aovs, mock_groups):
        mock_group1 = MagicMock(spec=manager.AOVGroup)
        mock_group2 = MagicMock(spec=manager.AOVGroup)

        mock_aovs.return_value = {}
        mock_groups.return_value = {"group1": mock_group1, "group2": mock_group2}

        mgr = manager.AOVManager()

        pattern = "@group1,@group3, @group2"

        result = mgr.get_aovs_from_string(pattern)

        self.assertEqual(result, (mock_group1, mock_group2))
Exemple #21
0
    def test_get_aovs_from_string__aovs_match_commas(self, mock_aovs, mock_groups):
        mock_aov_n = MagicMock(spec=manager.AOV)
        mock_aov_p = MagicMock(spec=manager.AOV)

        mock_aovs.return_value = {"N": mock_aov_n, "P": mock_aov_p}
        mock_groups.return_value = {}

        mgr = manager.AOVManager()

        pattern = "N,P,R"

        result = mgr.get_aovs_from_string(pattern)

        self.assertEqual(result, (mock_aov_n, mock_aov_p))
Exemple #22
0
    def test__init_reader_groups__new_group(self, mock_init, mock_groups, mock_add):
        mock_group = MagicMock(spec=manager.AOVGroup)

        mock_reader = MagicMock(spec=manager.AOVFile)
        mock_reader.groups = [mock_group]

        mock_groups.return_value = {}

        mgr = manager.AOVManager()
        mgr._init_reader_groups(mock_reader)

        mock_init.assert_called_with(mock_group)

        mock_add.assert_called_with(mock_group)
Exemple #23
0
    def test__build_intrinsic_groups__existing_group(self, mock_aovs, mock_groups, mock_add):
        mock_aov = MagicMock(spec=manager.AOV)
        mock_aov.intrinsics = ["int1"]

        mock_group = MagicMock(spec=aov.IntrinsicAOVGroup)

        mock_groups.return_value = {"i:int1": mock_group}

        mock_aovs.return_value = {MagicMock(spec=str): mock_aov}

        mgr = manager.AOVManager()
        mgr._build_intrinsic_groups()

        mock_group.aovs.append.assert_called_with(mock_aov)
Exemple #24
0
    def test_add_group__interface(self, mock_groups, mock_interface):
        interface = MagicMock()
        mock_interface.return_value = interface

        groups = {}
        mock_groups.return_value = groups

        mock_group = MagicMock(spec=manager.AOVGroup)

        mgr = manager.AOVManager()
        mgr.add_group(mock_group)

        self.assertEqual(groups, {mock_group.name: mock_group})
        interface.groupAddedSignal.emit.assert_called_with(mock_group)
Exemple #25
0
    def test__build_intrinsic_groups__new_group(self, mock_aovs, mock_groups, mock_add, mock_int_group):
        mock_aov = MagicMock(spec=manager.AOV)
        mock_aov.intrinsics = ["int1"]

        mock_groups.return_value = {}

        mock_aovs.return_value = {MagicMock(spec=str): mock_aov}

        mgr = manager.AOVManager()
        mgr._build_intrinsic_groups()

        mock_int_group.assert_called_with("i:int1")
        mock_add.assert_called_with(mock_int_group.return_value)

        mock_int_group.return_value.aovs.append.assert_called_with(mock_aov)
Exemple #26
0
    def test_remove_group__match_interface(self, mock_groups, mock_interface):
        interface = MagicMock()
        mock_interface.return_value = interface

        mock_group = MagicMock(spec=manager.AOVGroup)

        groups = {mock_group.name: mock_group}
        mock_groups.return_value = groups

        mgr = manager.AOVManager()

        mgr.remove_group(mock_group)

        self.assertEqual(groups, {})

        interface.groupRemovedSignal.emit.assert_called_with(mock_group)
Exemple #27
0
    def test_remove_aov__match_interface(self, mock_aovs, mock_interface):
        interface = MagicMock()
        mock_interface.return_value = interface

        mock_aov = MagicMock(spec=manager.AOV)

        aovs = {mock_aov.variable: mock_aov}
        mock_aovs.return_value = aovs

        mgr = manager.AOVManager()

        mgr.remove_aov(mock_aov)

        self.assertEqual(aovs, {})

        interface.aovRemovedSignal.emit.assert_called_with(mock_aov)
Exemple #28
0
    def test__init_group_members(self, mock_aovs):
        mock_varname1 = MagicMock(spec=str)
        mock_varname2 = MagicMock(spec=str)

        mock_group = MagicMock(spec=manager.AOVGroup)
        mock_group.includes = [mock_varname1, mock_varname2]

        mock_aov = MagicMock(spec=manager.AOV)

        mock_aovs.return_value = {
            mock_varname1: mock_aov,
        }

        mgr = manager.AOVManager()
        mgr._init_group_members(mock_group)

        mock_group.aovs.append.assert_called_with(mock_aov)
Exemple #29
0
    def test_add_aovs_to_ifd__no_parms(self):
        mock_wrangler = MagicMock()

        mock_cam = MagicMock()
        mock_cam.wrangle.return_value = {}

        mock_now = MagicMock(spec=float)

        mgr = manager.AOVManager()

        calls = [
            call("enable_auto_aovs", "int", [1], skipdefault=False),
            call("auto_aovs", "str", [""], skipdefault=False)
        ]

        mgr.add_aovs_to_ifd(mock_wrangler, mock_cam, mock_now)

        self.mock_soho.SohoParm.assert_has_calls(calls)
Exemple #30
0
    def test__init_reader_aovs__matches_existing_priority_lower(self, mock_aovs, mock_add):
        mock_varname = MagicMock(spec=str)

        mock_new_aov = MagicMock(spec=manager.AOV)
        mock_new_aov.variable = mock_varname
        mock_new_aov.priority = 3

        mock_existing_aov = MagicMock(spec=manager.AOV)
        mock_existing_aov.variable = mock_varname
        mock_existing_aov.priority = 2

        mock_reader = MagicMock(spec=manager.AOVFile)
        mock_reader.aovs = [mock_new_aov]

        mock_aovs.return_value = {mock_varname: mock_existing_aov}

        mgr = manager.AOVManager()
        mgr._init_reader_aovs(mock_reader)

        mock_add.assert_called_with(mock_new_aov)