summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_context_records/tests.py19
-rw-r--r--archaeological_operations/tests.py6
-rw-r--r--ishtar_common/models.py2
3 files changed, 19 insertions, 8 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py
index 72144b528..2900b8786 100644
--- a/archaeological_context_records/tests.py
+++ b/archaeological_context_records/tests.py
@@ -48,7 +48,8 @@ class ImportContextRecordTest(ImportOperationTest):
old_nb = models.ContextRecord.objects.count()
MCC = ImporterType.objects.get(name=u"MCC - UE")
mcc_file = open(settings.ROOT_PATH + \
- '../archaeological_context_records/tests/MCC-context-records-example.csv', 'rb')
+ '../archaeological_context_records/tests/'\
+ 'MCC-context-records-example.csv', 'rb')
file_dict = {'imported_file': SimpleUploadedFile(mcc_file.name,
mcc_file.read())}
post_dict = {'importer_type':MCC.pk, 'skip_lines':1,
@@ -61,14 +62,12 @@ class ImportContextRecordTest(ImportOperationTest):
impt = form.save(self.ishtar_user)
impt.initialize()
- # doing manualy connections
+ # doing manual connections
hc = models.Unit.objects.get(txt_idx='not_in_context').pk
- #for tg in TargetKey.objects.all():
- # print(tg.target, tg.key)
- tg = TargetKey.objects.get(target__target='unit', key='Hors contexte')
- tg.value = hc
- tg.is_set = True
- tg.save()
+ self.setTargetKey('unit', 'hc', hc)
+ self.setTargetKey('unit', 'hors-contexte', hc)
+ layer = models.Unit.objects.get(txt_idx='layer').pk
+ self.setTargetKey('unit', 'couche', layer)
impt.importation()
if not test:
@@ -77,6 +76,10 @@ class ImportContextRecordTest(ImportOperationTest):
# new ues has now been imported
current_nb = models.ContextRecord.objects.count()
self.assertTrue(current_nb == (old_nb + 4))
+ self.assertEqual(
+ models.ContextRecord.objects.filter(unit__pk=hc).count(), 3)
+ self.assertEqual(
+ models.ContextRecord.objects.filter(unit__pk=layer).count(), 1)
class ContextRecordInit(OperationInitTest):
diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py
index 527e10295..396f850af 100644
--- a/archaeological_operations/tests.py
+++ b/archaeological_operations/tests.py
@@ -51,6 +51,12 @@ class ImportOperationTest(TestCase):
'../archaeological_operations/fixtures/initial_data-fr.json']
test_operations = True
+ def setTargetKey(self, target, key, value):
+ tg = TargetKey.objects.get(target__target=target, key=key)
+ tg.value = value
+ tg.is_set = True
+ tg.save()
+
def setUp(self):
self.username, self.password, self.user = create_superuser()
self.ishtar_user = IshtarUser.objects.get(pk=self.user.pk)
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index a82638396..a57e814f0 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1258,6 +1258,7 @@ TARGET_MODELS = [
('Format', _(u"Format")),
('archaeological_operations.models.OperationType', _(u"Operation type")),
('archaeological_operations.models.Period', _(u"Period")),
+ ('archaeological_context_records.models.Unit', _(u"Unit")),
]
TARGET_MODELS_KEYS = [tm[0] for tm in TARGET_MODELS]
@@ -1322,6 +1323,7 @@ class FormaterType(models.Model):
kwargs['many_split'] = self.many_split
if self.formater_type == 'TypeFormater':
if self.options not in TARGET_MODELS_KEYS:
+ print('%s not in TARGET_MODELS_KEYS' % self.options)
return
model = None
if self.options in dir():