Example #1
0
 def test_missing_isocode(self):
     lang3 = Language.objects.create(
         language='C',
         slug='langc',
         information='i.1',
         classification='a, b',
         isocode=None,
         editor=self.editor
     )
     Lexicon.objects.create(
         language=lang3,
         source=self.source1,
         word=self.word1,
         entry="X",
         phon_entry="x",
         annotation="",
         loan=False,
         loan_source=None,
         editor=self.editor
     )
     # no isocode but create a spare location just in case.
     Location.objects.create(
         isocode='xxx',
         latitude=-292.4,
         longitude=221.09,
         editor=self.editor
     )
     
     records = Word.objects.get(pk=self.word1.pk).lexicon_set.all()
     records = records.select_related('language')
     result = prepare_map_data(records)
     assert len(result) == 1
     assert result[0]['label'] == self.lexicon1.entry
Example #2
0
 def test_missing_location(self):
     lang3 = Language.objects.create(
         language='C',
         slug='langc',
         information='i.1',
         classification='a, b',
         isocode='X',
         editor=self.editor
     )
     Lexicon.objects.create(
         language=lang3,
         source=self.source1,
         word=self.word1,
         entry="X",
         phon_entry="x",
         annotation="",
         loan=False,
         loan_source=None,
         editor=self.editor
     )
     # NOTE: No extra location this time.
     records = Word.objects.get(pk=self.word1.pk).lexicon_set.all()
     records = records.select_related('language').all()
     result = prepare_map_data(records)
     assert len(result) == 1
     assert result[0]['label'] == self.lexicon1.entry
Example #3
0
 def test_one(self):
     result = prepare_map_data(
         Word.objects.get(slug=self.word1.slug).lexicon_set.select_related('language').all()
     )
     assert len(result) == 1
     self.compare(
         result[0],
         language=self.lang1,
         label=self.lexicon1.entry,
         isocode=self.lang1.isocode,
         latitude=self.loc1.latitude,
         longitude=self.loc1.longitude
     )