def test_filter_on_language(self):
     found = split_entries.Command().find_combined(
         language=self.languages[0])
     assert len(found) == 4
     for f in found:
         values = self._getvalues(f)
         assert values['language'] == self.languages[0].id
 def test_split_and_replace_slash_deletes(self):
     cmd = split_entries.Command()
     # for some reason postgresql isn't setting slash/comman in setupTestData with a pk, this causes
     # problems when we work around it. So, requery the database to get the desired form.
     obj = Lexicon.objects.get(entry__contains="/")
     cmd.split_and_replace(obj, quiet=True)
     with self.assertRaises(Lexicon.DoesNotExist):
         assert Lexicon.objects.get(pk=self.slash.pk)
 def test_fail_on_zero_length_component_trailing_comma(self):
     """Test split_and_replace fails with a zero length component"""
     cmd = split_entries.Command()
     o = Lexicon.objects.create(language=self.lang,
                                word=self.word,
                                source=self.source,
                                editor=self.editor,
                                entry="hello,")
     with self.assertRaises(AssertionError):
         cmd.split_and_replace(o, quiet=True)
 def test_filter_on_language_and_word_and_source(self):
     found = split_entries.Command().find_combined(
         language=self.languages[0],
         word=self.words[0],
         source=self.sources[0])
     assert len(found) == 1
     values = self._getvalues(found[0])
     assert values['language'] == self.languages[0].id
     assert values['word'] == self.words[0].id
     assert values['source'] == self.sources[0].id
    def test_split_and_replace_comma(self):
        cmd = split_entries.Command()
        cmd.split_and_replace(self.comma, quiet=True)
        one = Lexicon.objects.filter(entry="foo")
        two = Lexicon.objects.filter(entry="bar")

        assert len(one) == len(two) == 1
        one, two = one[0], two[0]

        assert one.language == two.language == self.comma.language
        assert one.editor == two.editor == self.comma.editor
        assert one.source == two.source == self.comma.source
        assert one.word == two.word == self.comma.word
    def test_split_and_replace_slash(self):
        cmd = split_entries.Command()
        cmd.split_and_replace(self.slash, quiet=True)
        one = Lexicon.objects.filter(entry="hello")
        two = Lexicon.objects.filter(entry="world")

        assert len(one) == len(two) == 1
        one, two = one[0], two[0]

        assert one.language == two.language == self.slash.language
        assert one.editor == two.editor == self.slash.editor
        assert one.source == two.source == self.slash.source
        assert one.word == two.word == self.slash.word
    def test_correctly_split_protoform(self):
        cmd = split_entries.Command()
        cmd.split_and_replace(self.pform3, quiet=True)
        one = Lexicon.objects.filter(entry="*neri")
        two = Lexicon.objects.filter(entry="*niri")

        assert len(one) == len(two) == 1
        one, two = one[0], two[0]

        assert one.language == two.language == self.pform3.language
        assert one.editor == two.editor == self.pform3.editor
        assert one.source == two.source == self.pform3.source
        assert one.word == two.word == self.pform3.word
    def test_split_and_replace_with_space(self):
        cmd = split_entries.Command()
        o = Lexicon.objects.create(language=self.lang,
                                   word=self.word,
                                   source=self.source,
                                   editor=self.editor,
                                   entry="i have/ a space")
        cmd.split_and_replace(o, quiet=True)
        one = Lexicon.objects.filter(entry="i have")
        two = Lexicon.objects.filter(entry="a space")

        assert len(one) == len(two) == 1
        one, two = one[0], two[0]

        assert one.language == two.language == o.language
        assert one.editor == two.editor == o.editor
        assert one.source == two.source == o.source
        assert one.word == two.word == o.word
 def test_correct(self):
     cmd = split_entries.Command()
     found = cmd.find_combined()
     # pform3 SHOULD be found
     assert self.pform3 in found
 def test_slash(self):
     cmd = split_entries.Command()
     found = cmd.find_combined()
     assert self.pform2 not in found
 def test_filter_on_source(self):
     found = split_entries.Command().find_combined(source=self.sources[0])
     assert len(found) == 4
     for f in found:
         values = self._getvalues(f)
         assert values['source'] == self.sources[0].id
 def test_filter_on_word(self):
     found = split_entries.Command().find_combined(word=self.words[0])
     assert len(found) == 4
     for f in found:
         values = self._getvalues(f)
         assert values['word'] == self.words[0].id
 def test_find_all(self):
     """Tests whether we find all the combined entries."""
     assert len(split_entries.Command().find_combined()) == 8
 def test_find_comma(self):
     cmd = split_entries.Command()
     assert self.comma in cmd.find_combined()
 def test_find_slash(self):
     cmd = split_entries.Command()
     assert self.slash in cmd.find_combined()