diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-08-23 11:55:39 +0200 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-08-23 11:55:39 +0200 |
| commit | bfd0d7e3e576c700968c1eb8571f32649274b18e (patch) | |
| tree | 823b43e3689dc2a66a28cc2c9271d5b17d039dd2 /archaeological_finds/tests.py | |
| parent | 29e6b089568281bfa5a3dcff80f9fca8b42852af (diff) | |
| parent | d4f335cc6990eb86e011b5f58f01cf92a89ddd87 (diff) | |
| download | Ishtar-bfd0d7e3e576c700968c1eb8571f32649274b18e.tar.bz2 Ishtar-bfd0d7e3e576c700968c1eb8571f32649274b18e.zip | |
Merge branch 'v0.9' into wheezy
Diffstat (limited to 'archaeological_finds/tests.py')
| -rw-r--r-- | archaeological_finds/tests.py | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index c17e440b1..1b61d49ca 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -106,7 +106,8 @@ class FindInit(ContextRecordInit): default = {'label': "Base find"} if not data_base.get('history_modifier'): data_base['history_modifier'] = self.get_default_user() - if not data_base.get('context_record'): + if not data_base.get('context_record') \ + or not data_base['context_record'].pk: data_base['context_record'] = self.get_default_context_record() default.update(data_base) @@ -122,8 +123,57 @@ class FindInit(ContextRecordInit): def get_default_find(self): return self.create_finds()[0] + def tearDown(self): + super(FindInit, self).tearDown() + if hasattr(self, 'finds'): + for f in self.finds: + try: + f.delete() + except: + pass + self.finds = [] + if hasattr(self, 'base_finds'): + for f in self.base_finds: + try: + f.delete() + except: + pass + self.base_find = [] + + +class FindTest(FindInit, TestCase): + fixtures = [settings.ROOT_PATH + + '../fixtures/initial_data.json', + settings.ROOT_PATH + + '../ishtar_common/fixtures/initial_data.json', + settings.ROOT_PATH + + '../archaeological_files/fixtures/initial_data.json', + settings.ROOT_PATH + + '../archaeological_operations/fixtures/initial_data-fr.json', + settings.ROOT_PATH + + '../archaeological_finds/fixtures/initial_data-fr.json', + ] + model = models.Find + + def setUp(self): + self.create_finds() + + def testExternalID(self): + find = self.finds[0] + base_find = find.base_finds.all()[0] + self.assertEqual( + find.external_id, + u"{}-{}".format( + find.get_first_base_find().context_record.external_id, + find.label)) + self.assertEqual( + base_find.external_id, + u"{}-{}".format( + base_find.context_record.external_id, + base_find.label)) + -class PackagingTest(TestCase, FindInit): +class PackagingTest(FindInit, TestCase): fixtures = [settings.ROOT_PATH + '../fixtures/initial_data.json', settings.ROOT_PATH + |
