Esempio n. 1
0
 def test_can_get_string_from_xyz(self, mock_string, mock_dict):
     xyz = Xyz()
     xyz_dict = Mock()
     mock_string.return_value = "filecontents"
     mock_dict.return_value = xyz_dict
     s = xyz.to_file_string()
     mock_dict.assert_called_with(xyz)
     mock_string.assert_called_with(xyz_dict)
     self.assertEqual(s, "filecontents")
Esempio n. 2
0
 def test_can_create_xyz(self):
     xyz = Xyz()
     self.assertEqual(xyz._model, None)
     self.assertEqual(xyz._title, "")
Esempio n. 3
0
 def test_can_save_xyz_to_file(self, mock_string, mock_save):
     xyz = Xyz()
     mock_string.return_value = "filestring"
     xyz.save("test.xyz")
     mock_save.assert_called_with("filestring", "test.xyz")
Esempio n. 4
0
 def test_xyz_title_must_be_str(self):
     xyz = Xyz("Glucose molecule")
     with self.assertRaises(TypeError):
         xyz.title = 100
Esempio n. 5
0
 def test_model_property(self):
     xyz = Xyz("Glucose molecule")
     xyz._model = "totally a model"
     self.assertIs(xyz._model, xyz.model)
Esempio n. 6
0
 def test_can_change_title(self):
     xyz = Xyz("Glucose molecule")
     xyz.title = "Fructose molecule"
     self.assertEqual(xyz._title, "Fructose molecule")
Esempio n. 7
0
 def test_title_property(self):
     xyz = Xyz("Glucose molecule")
     self.assertIs(xyz._title, xyz.title)
Esempio n. 8
0
 def test_xyz_repr(self):
     xyz = Xyz("Glucose molecule")
     self.assertEqual(str(xyz), "<Xyz (Glucose molecule)>")
Esempio n. 9
0
 def test_xyz_title_must_be_str(self):
     with self.assertRaises(TypeError):
         Xyz(100)
Esempio n. 10
0
 def test_can_create_xyz_with_title(self):
     xyz = Xyz("Glucose molecule")
     self.assertEqual(xyz._model, None)
     self.assertEqual(xyz._title, "Glucose molecule")