Example #1
0
    def test_find_all_one_line(self):
        name = 'Pascal'
        line_sip = self.add_usersip(name=name)
        line = self.add_line(protocolid=line_sip.id,
                             name=name)

        lines = line_dao.find_all()

        assert_that(lines, has_length(1))
        line_found = lines[0]
        assert_that(line_found, has_property('id', line.id))
        assert_that(line_found, has_property('name', name))
Example #2
0
    def test_find_all_order_by_context(self):
        line_sip = self.add_usersip()
        line_last = self.add_line(protocolid=line_sip.id,
                                  name='Albert',
                                  context='Breton')
        line_sip = self.add_usersip()
        line_first = self.add_line(protocolid=line_sip.id,
                                   name='Bob',
                                   context='Alzard')

        lines = line_dao.find_all(order=[LineOrdering.context])

        assert_that(lines[0].id, equal_to(line_first.id))
        assert_that(lines[1].id, equal_to(line_last.id))
Example #3
0
    def test_find_all_default_order_by_name_context(self):
        line_sip = self.add_usersip(name='xxx')
        line1 = self.add_line(protocolid=line_sip.id,
                              name='xxx', context='f')
        line_sip = self.add_usersip(name='vvv')
        line2 = self.add_line(protocolid=line_sip.id,
                              name='vvv', context='a')
        line_sip = self.add_usersip(name='aaa')
        line3 = self.add_line(protocolid=line_sip.id,
                              name='aaa', context='a')

        lines = line_dao.find_all()

        assert_that(lines, has_length(3))
        assert_that(lines[0].id, equal_to(line3.id))
        assert_that(lines[1].id, equal_to(line2.id))
        assert_that(lines[2].id, equal_to(line1.id))
Example #4
0
    def test_find_all_two_lines(self):
        name1 = 'Pascal'
        name2 = 'George'

        line_sip1 = self.add_usersip(name=name1)
        line1 = self.add_line(protocolid=line_sip1.id,
                              name=name1)
        line_sip1 = self.add_usersip(name=name2)
        line2 = self.add_line(protocolid=line_sip1.id,
                              name=name2)

        lines = line_dao.find_all()

        assert_that(lines, has_length(2))
        assert_that(lines, has_items(
            all_of(
                has_property('id', line1.id),
                has_property('name', name1)),
            all_of(
                has_property('id', line2.id),
                has_property('name', name2))
        ))
Example #5
0
    def test_find_all_no_lines(self):
        expected = []
        lines = line_dao.find_all()

        assert_that(lines, equal_to(expected))