diff options
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) |
