def test_subgroup_updates_context(self, mock_proc_subgroup, mock_proc_master): inp = '@subgroup blah\n@master blah' context = self.context context['subgroup'] = mock_proc_subgroup.return_value kin.process_kinemage(inp) mock_proc_master.assert_called_once_with(['master blah'], context)
def test_kinemage_keyword_updates_context(self, mock_proc_kin, mock_proc_master): inp = '@kinemage blah\n@master blah' context = self.context context['kinemage'] = mock_proc_kin.return_value kin.process_kinemage(inp) mock_proc_master.assert_called_once_with(['master blah'], context)
def test_kinemage_keyword_updates_context(self, mock_proc_kin, mock_proc_master): inp = '@kinemage blah\n@master blah' context = self.context context['kinemage'] = mock_proc_kin.return_value kin.process_kinemage(inp) mock_proc_master.assert_called_once_with(['master blah'], context)
def test_subgroup_updates_context(self, mock_proc_subgroup, mock_proc_master): inp = '@subgroup blah\n@master blah' context = self.context context['subgroup'] = mock_proc_subgroup.return_value kin.process_kinemage(inp) mock_proc_master.assert_called_once_with(['master blah'], context)
def test_animate_group_updates_context(self, mock_proc_group, mock_proc_master): inp = '@group blah\n@master blah' mock_proc_group.return_value = ['reduce', 'animate'] context = self.context context['group'] = mock_proc_group.return_value context['animate'] = 1 kin.process_kinemage(inp) mock_proc_master.assert_called_once_with(['master blah'], context)
def test_animate_group_updates_context(self, mock_proc_group, mock_proc_master): inp = '@group blah\n@master blah' mock_proc_group.return_value = ['reduce', 'animate'] context = self.context context['group'] = mock_proc_group.return_value context['animate'] = 1 kin.process_kinemage(inp) mock_proc_master.assert_called_once_with(['master blah'], context)
def test_non_animate_group_updates_context(self, mock_proc_group, mock_proc_master): inp = '@group blah\n@group blah\n@master blah' # first call sets animate = 1, second should reset it to 0 mock_proc_group.side_effect = [['animate'], ['blah']] context = self.context context['group'] = ['blah'] context['animate'] = 0 kin.process_kinemage(inp) mock_proc_master.assert_called_once_with(['master blah'], context)
def test_non_animate_group_updates_context(self, mock_proc_group, mock_proc_master): inp = '@group blah\n@group blah\n@master blah' # first call sets animate = 1, second should reset it to 0 mock_proc_group.side_effect = [['animate'], ['blah']] context = self.context context['group'] = ['blah'] context['animate'] = 0 kin.process_kinemage(inp) mock_proc_master.assert_called_once_with(['master blah'], context)
def test_calls_process_master_with_master(self, mock_proc_master): inp = '@master blah' mock_proc_master.return_value = 'val' k = kin.process_kinemage(inp) mock_proc_master.assert_called_once_with(['master blah'], self.context) ref = {'keyword': 'master', 'data': 'val'} self.assertEqual(k.keywords[0], ref)
def test_calls_process_kinemage_keyword_with_kinemage(self, mock_proc_kin): inp = '@kinemage blah' mock_proc_kin.return_value = 'val' k = kin.process_kinemage(inp) mock_proc_kin.assert_called_once_with(['kinemage blah'], self.context) ref = {'keyword': 'kinemage', 'data': 'val'} self.assertEqual(k.keywords[0], ref)
def test_calls_process_group_with_group(self, mock_proc): inp = '@group blah' mock_proc.return_value = 'val' k = kin.process_kinemage(inp) mock_proc.assert_called_once_with(['group blah'], self.context) ref = {'keyword': 'group', 'data': 'val'} self.assertEqual(k.keywords[0], ref)
def test_calls_process_viewid_with_viewids(self, mock_proc_viewid): inp = '@viewid blah' mock_proc_viewid.return_value = 'val' k = kin.process_kinemage(inp) mock_proc_viewid.assert_called_once_with(['viewid blah'], self.context) ref = {'keyword': 'viewid', 'data': 'val'} self.assertEqual(k.keywords[0], ref)
def test_calls_process_dotlist_with_dotlists(self, mock_proc_dotlist): inp = '@dotlist blah' mock_proc_dotlist.return_value = 'val' k = kin.process_kinemage(inp) mock_proc_dotlist.assert_called_once_with(['dotlist blah'], self.context) ref = {'keyword': 'dotlist', 'data': 'val'} self.assertEqual(k.keywords[0], ref)
def test_calls_process_pointmaster_with_pointmaster(self, mock_proc_pm): inp = '@pointmaster blah' mock_proc_pm.return_value = 'val' k = kin.process_kinemage(inp) mock_proc_pm.assert_called_once_with( ['pointmaster blah'], self.context) ref = {'keyword': 'pointmaster', 'data': 'val'} self.assertEqual(k.keywords[0], ref)
def test_calls_process_vectorlist_with_vectorlists(self, mock_proc_vectorlist): inp = '@vectorlist blah' mock_proc_vectorlist.return_value = 'val' k = kin.process_kinemage(inp) mock_proc_vectorlist.assert_called_once_with( ['vectorlist blah'], self.context) ref = {'keyword': 'vectorlist', 'data': 'val'} self.assertEqual(k.keywords[0], ref)
def test_calls_process_viewid_with_viewids(self, mock_proc_viewid): inp = '@viewid blah' mock_proc_viewid.return_value = 'val' k = kin.process_kinemage(inp) mock_proc_viewid.assert_called_once_with( ['viewid blah'], self.context) ref = {'keyword': 'viewid', 'data': 'val'} self.assertEqual(k.keywords[0], ref)
def test_calls_process_kinemage_keyword_with_kinemage(self, mock_proc_kin): inp = '@kinemage blah' mock_proc_kin.return_value = 'val' k = kin.process_kinemage(inp) mock_proc_kin.assert_called_once_with( ['kinemage blah'], self.context) ref = {'keyword': 'kinemage', 'data': 'val'} self.assertEqual(k.keywords[0], ref)
def test_calls_process_group_with_group(self, mock_proc): inp = '@group blah' mock_proc.return_value = 'val' k = kin.process_kinemage(inp) mock_proc.assert_called_once_with( ['group blah'], self.context) ref = {'keyword': 'group', 'data': 'val'} self.assertEqual(k.keywords[0], ref)
def test_none_group_updates_context(self, mock_proc_group, mock_proc_master): inp = '@group blah\n@group blah\n@master blah' mock_proc_group.side_effect = ( ['reduce', 'animate'], None ) context1 = copy.deepcopy(self.context) context1['group'] = ['reduce', 'animate'] context1['animate'] = 1 context2 = copy.deepcopy(context1) context2['group'] = None # from 2nd group context2['animate'] = 0 kin.process_kinemage(inp) mock_proc_group.assert_has_calls( [mock.call(['group blah'], self.context), mock.call(['group blah'], context1)]) mock_proc_master.assert_called_once_with(['master blah'], context2)
def test_none_group_updates_context(self, mock_proc_group, mock_proc_master): inp = '@group blah\n@group blah\n@master blah' mock_proc_group.side_effect = (['reduce', 'animate'], None) context1 = copy.deepcopy(self.context) context1['group'] = ['reduce', 'animate'] context1['animate'] = 1 context2 = copy.deepcopy(context1) context2['group'] = None # from 2nd group context2['animate'] = 0 kin.process_kinemage(inp) mock_proc_group.assert_has_calls([ mock.call(['group blah'], self.context), mock.call(['group blah'], context1) ]) mock_proc_master.assert_called_once_with(['master blah'], context2)
def test_with_unknown_keyword(self, mock_logger): inp = '@not_a_keyword blah' k = kin.process_kinemage(inp) mock_logger.warning.assert_called_with( 'Unknown keyword: not_a_keyword')
def test_with_skipped_keyword(self, mock_proc_dotlist, mock_proc_vectorlist): inp = '@text something' kin.process_kinemage(inp) mock_proc_dotlist.assert_not_called() mock_proc_vectorlist.assert_not_called()
def test_with_skipped_keyword(self, mock_proc_dotlist, mock_proc_vectorlist): inp = '@text something' kin.process_kinemage(inp) mock_proc_dotlist.assert_not_called() mock_proc_vectorlist.assert_not_called()
def test_with_unknown_keyword(self, mock_logger): inp = '@not_a_keyword blah' k = kin.process_kinemage(inp) mock_logger.warning.assert_called_with('Unknown keyword: not_a_keyword')