|
30 | 30 | User, |
31 | 31 | settings, |
32 | 32 | timezone, |
| 33 | + Parameters, |
| 34 | + Structure, |
| 35 | + Property, |
| 36 | + Ensemble, |
33 | 37 | ) |
34 | 38 |
|
35 | 39 |
|
@@ -146,3 +150,49 @@ def test_student_sub_ended(self): |
146 | 150 | self.sub.end_date = timezone.now() - timezone.timedelta(seconds=5) |
147 | 151 | self.sub.save() |
148 | 152 | self.assertEqual(self.user.user_type, "free") |
| 153 | + |
| 154 | + |
| 155 | +class CalculationModelsTests(TransactionTestCase): |
| 156 | + def tearDown(self): |
| 157 | + close_old_connections() |
| 158 | + |
| 159 | + def setUp(self): |
| 160 | + self.password = "password1234" |
| 161 | + self.user = User.objects.create_user(email="PI@uni.com", password=self.password) |
| 162 | + self.group = ResearchGroup.objects.create(PI=self.user) |
| 163 | + self.student = User.objects.create_user( |
| 164 | + email="student@uni.com", password=self.password, member_of=self.group |
| 165 | + ) |
| 166 | + |
| 167 | + self.sub = Subscription.objects.create( |
| 168 | + subscriber=self.user, |
| 169 | + start_date=timezone.now(), |
| 170 | + end_date=timezone.now() + timezone.timedelta(days=1), |
| 171 | + ) |
| 172 | + |
| 173 | + def test_structure_multiple_properties_for_params(self): |
| 174 | + params = Parameters.objects.create( |
| 175 | + name="params1", |
| 176 | + charge=0, |
| 177 | + multiplicity=2, |
| 178 | + ) |
| 179 | + e = Ensemble.objects.create() |
| 180 | + struct = Structure.objects.create(xyz_structure="H 0 0 0", parent_ensemble=e) |
| 181 | + |
| 182 | + prop1 = Property.objects.create( |
| 183 | + parameters=params, |
| 184 | + parent_structure=struct, |
| 185 | + energy=1.0, |
| 186 | + free_energy=1.0, |
| 187 | + ) |
| 188 | + |
| 189 | + prop2 = Property.objects.create( |
| 190 | + parameters=params, |
| 191 | + parent_structure=struct, |
| 192 | + energy=1.0, |
| 193 | + free_energy=1.0, |
| 194 | + ) |
| 195 | + |
| 196 | + # Normally, this should not happen as the previous property should be updated. |
| 197 | + # However, it seems to happen in some cases, so let's just handle it correctly. |
| 198 | + self.assertFalse(e.has_nmr(params)) |
0 commit comments