Exemple #1
0
 def test_workflow(self, mock_parse_header, mock_parse_body):
     mock_parse_header.return_value = ('name', 'color', 'master')
     mock_parse_body.return_value = [pt.Dot(), pt.Dot(), pt.Dot()]
     inp = ['dotlist blah', 'line 1', 'line 2', 'line 3']
     res = pt.process_dotlist(inp, self.base_context)
     mock_parse_header.assert_called_once_with(inp[0])
     mock_parse_body.assert_called_once_with(inp[1:])
     for dot in res:
         self.assertEqual(dot.dotlist_name, 'name')
         self.assertEqual(dot.dotlist_color, 'color')
         self.assertEqual(dot.master, 'master')
         self.assertEqual(dot.kinemage, self.base_context['kinemage'])
         self.assertEqual(dot.group, self.base_context['group'])
         self.assertEqual(dot.subgroup, self.base_context['subgroup'])
         self.assertEqual(dot.animate, self.base_context['animate'])
Exemple #2
0
 def test_init(self, mock_get_color):
     mock_get_color.return_value = 'somecolor'
     d = pt.Dot()
     self.assertEqual(d.atom, None)
     self.assertEqual(d.color, 'somecolor')
     self.assertEqual(d.pm, None)
     self.assertEqual(d.coords, None)
     self.assertEqual(d.draw, 1)
     self.assertEqual(d.dotlist_name, None)
     self.assertEqual(d.dotlist_color, None)
     self.assertEqual(d.master, None)
Exemple #3
0
    def test_get_cgo_workflow_with_defaults(self, mock_color, mock_sphere):
        mock_color.return_value = ['color']
        mock_sphere.return_value = ['sphere']
        d = pt.Dot()
        d.color = 'white'
        d.coords = (0.0, 1.0, 2.0)

        res = d.get_cgo()
        ref = ['color', 'sphere']
        self.assertEqual(res, ref)

        mock_color.assert_called_once_with('white')
        mock_sphere.assert_called_once_with((0, 1, 2), 0.03)
Exemple #4
0
    def test_get_cgo_with_dot_mode_1(self, mock_color, mock_quad, mock_cpv):
        mock_color.return_value = ['color']
        mock_quad.return_value = ['quad']
        mock_cpv.normalize.return_value = (1, 0, 0)
        d = pt.Dot()
        d.color = 'white'
        d.coords = (0.0, 1.0, 2.0)
        d.atom = {'coords': (3.0, 4.0, 5.0)}

        res = d.get_cgo(dot_mode=1)

        ref = ['color', 'quad']
        self.assertEqual(res, ref)

        mock_color.assert_called_once_with('white')
        mock_quad.assert_called_once_with((0.0, 1.0, 2.0), (1, 0, 0),
                                          0.03 * 1.5)
        mock_cpv.sub.assert_called_once_with((0.0, 1.0, 2.0), (3.0, 4.0, 5.0))