diff options
| author | Étienne Loks <etienne.loks@peacefrogs.net> | 2011-04-09 00:35:53 +0200 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2011-04-09 00:35:53 +0200 |
| commit | 455ed98ff54131b206b045a8a6950cc3ac2e25f2 (patch) | |
| tree | f9001acc59e9cc546f3dc44879d29d9ab3f04f62 /ishtar/furnitures/tests.py | |
| parent | 7755ab38c3a92ba55ac3eed92a40f19a9cd8ee40 (diff) | |
| download | Ishtar-455ed98ff54131b206b045a8a6950cc3ac2e25f2.tar.bz2 Ishtar-455ed98ff54131b206b045a8a6950cc3ac2e25f2.zip | |
Manage the rollback on historized items (refs #349)
Diffstat (limited to 'ishtar/furnitures/tests.py')
| -rw-r--r-- | ishtar/furnitures/tests.py | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/ishtar/furnitures/tests.py b/ishtar/furnitures/tests.py index 67756cd00..43bbb200a 100644 --- a/ishtar/furnitures/tests.py +++ b/ishtar/furnitures/tests.py @@ -20,13 +20,15 @@ """ Unit tests """ +import json from django.test import TestCase import models class FileTest(TestCase): - fixtures = ['user.json'] + fixtures = ['user.json', 'person_type-fr.json', 'organization_type-fr.json', + 'treatment_type-fr.json'] model = models.File def setUp(self): @@ -63,7 +65,7 @@ class FileTest(TestCase): def testAddAndGetHistorized(self): """ - Tests that 1 + 1 always equals 2. + Test correct new version and correct access to history """ nb_hist = self.item.history.count() self.assertTrue(self.item.history.count() >= 1) @@ -74,5 +76,24 @@ class FileTest(TestCase): self.failUnlessEqual(self.item.history.all()[1].internal_reference, base_label) - + def testRollbackFile(self): + nb_hist = self.item.history.count() + initial_values = self.item.values() + self.item.internal_reference = u"Unité_Test" + backup_date = self.item.history.all()[0].history_date + self.item.save() + self.item.rollback(backup_date) + self.failUnlessEqual(self.item.history.count(), nb_hist) + new_values = self.item.values() + for k in initial_values.keys(): + self.assertTrue(k in new_values) + self.assertEqual(new_values[k], initial_values[k]) + + def testGetFile(self): + response = self.client.post('/get-file/', + {'numeric_reference':1000}) + self.assertEqual(response.status_code, 200) + data = json.loads(response.content) + self.assertTrue('records' in data) + self.assertTrue(data['records'] >= 1) |
