Example #1
0
    def test_find_all_answered_for_phone_limited(self):
        identity = "sip/131313"
        limit = 2
        call_logs = _, call_log_1, call_log_2, _, _ = (
            self._mock_call_log(source_line_identity=identity),
            self._mock_call_log(date=datetime(2015, 1, 1, 13),
                                destination_line_identity=identity,
                                answered=True),
            self._mock_call_log(date=datetime(2014, 1, 1, 13),
                                destination_line_identity=identity,
                                answered=True),
            self._mock_call_log(date=datetime(2013, 1, 1, 13),
                                destination_line_identity=identity,
                                answered=True),
            self._mock_call_log(source_line_identity=identity))

        call_log_dao.create_from_list(call_logs)

        result = call_log_dao.find_all_answered_for_phone(identity, limit)

        assert_that(result, has_length(2))
        assert_that(result[0].date, equal_to(call_log_1.date))
        assert_that(result[0].destination_line_identity,
                    equal_to(call_log_1.destination_line_identity))
        assert_that(result[0].answered, equal_to(call_log_1.answered))
        assert_that(result[1].date, equal_to(call_log_2.date))
        assert_that(result[1].destination_line_identity,
                    equal_to(call_log_2.destination_line_identity))
        assert_that(result[1].answered, equal_to(call_log_2.answered))
Example #2
0
    def test_find_all_found(self):
        call_logs = (self._mock_call_log(), self._mock_call_log())
        call_log_dao.create_from_list(call_logs)

        result = call_log_dao.find_all()

        assert_that(result, has_length(2))
Example #3
0
    def test_find_all_found(self):
        call_logs = (self._mock_call_log(), self._mock_call_log())
        call_log_dao.create_from_list(call_logs)

        result = call_log_dao.find_all()

        assert_that(result, has_length(2))
Example #4
0
    def test_create_from_list(self):
        cel_id_1, cel_id_2 = self.add_cel(), self.add_cel()
        cel_id_3, cel_id_4 = self.add_cel(), self.add_cel()
        call_logs = call_log_1, call_log_2 = (self._mock_call_log(
            (cel_id_1, cel_id_2)), self._mock_call_log((cel_id_3, cel_id_4)))

        call_log_dao.create_from_list(call_logs)

        call_log_rows = self.session.query(CallLogSchema).all()
        assert_that(call_log_rows, has_length(2))

        call_log_id_1, call_log_id_2 = [
            call_log.id for call_log in call_log_rows
        ]

        cel_rows = self.session.query(CELSchema).all()
        assert_that(
            cel_rows,
            contains_inanyorder(
                all_of(has_property('id', cel_id_1),
                       has_property('call_log_id', call_log_id_1)),
                all_of(has_property('id', cel_id_2),
                       has_property('call_log_id', call_log_id_1)),
                all_of(has_property('id', cel_id_3),
                       has_property('call_log_id', call_log_id_2)),
                all_of(has_property('id', cel_id_4),
                       has_property('call_log_id', call_log_id_2))))
Example #5
0
    def test_delete_all(self):
        call_logs = (self._mock_call_log(), self._mock_call_log())
        call_log_dao.create_from_list(call_logs)

        call_log_dao.delete_all()

        call_log_rows = self.session.query(CallLogSchema).all()
        assert_that(call_log_rows, has_length(0))
Example #6
0
    def test_delete_all(self):
        call_logs = (self._mock_call_log(), self._mock_call_log())
        call_log_dao.create_from_list(call_logs)

        call_log_dao.delete_all()

        call_log_rows = self.session.query(CallLogSchema).all()
        assert_that(call_log_rows, has_length(0))
Example #7
0
    def test_delete_from_list(self):
        id_1, id_2, id_3 = [42, 43, 44]
        call_logs = (self._mock_call_log(id=id_1), self._mock_call_log(id=id_2), self._mock_call_log(id=id_3))
        call_log_dao.create_from_list(call_logs)

        call_log_dao.delete_from_list([id_1, id_3])

        call_log_rows = self.session.query(CallLogSchema).all()
        assert_that(call_log_rows, contains(has_property('id', id_2)))
Example #8
0
    def test_delete_from_list(self):
        id_1, id_2, id_3 = [42, 43, 44]
        call_logs = (self._mock_call_log(id=id_1),
                     self._mock_call_log(id=id_2),
                     self._mock_call_log(id=id_3))
        call_log_dao.create_from_list(call_logs)

        call_log_dao.delete_from_list([id_1, id_3])

        call_log_rows = self.session.query(CallLogSchema).all()
        assert_that(call_log_rows, contains(has_property('id', id_2)))
Example #9
0
    def test_find_all_in_period_found(self):
        call_logs = _, call_log_1, call_log_2, _ = (self._mock_call_log(date=datetime(2012, 1, 1, 13)),
                                                    self._mock_call_log(date=datetime(2013, 1, 1, 13)),
                                                    self._mock_call_log(date=datetime(2013, 1, 2, 13)),
                                                    self._mock_call_log(date=datetime(2014, 1, 1, 13)))
        start = datetime(2013, 1, 1, 12)
        end = datetime(2013, 1, 3, 12)
        call_log_dao.create_from_list(call_logs)

        result = call_log_dao.find_all_in_period(start, end)

        assert_that(result, has_length(2))
        assert_that(result, contains_inanyorder(has_property('date', call_log_1.date),
                                                has_property('date', call_log_2.date)))
Example #10
0
    def test_find_all_in_period_found(self):
        call_logs = _, call_log_1, call_log_2, _ = (
            self._mock_call_log(date=datetime(2012, 1, 1, 13)),
            self._mock_call_log(date=datetime(2013, 1, 1, 13)),
            self._mock_call_log(date=datetime(2013, 1, 2, 13)),
            self._mock_call_log(date=datetime(2014, 1, 1, 13)))
        start = datetime(2013, 1, 1, 12)
        end = datetime(2013, 1, 3, 12)
        call_log_dao.create_from_list(call_logs)

        result = call_log_dao.find_all_in_period(start, end)

        assert_that(result, has_length(2))
        assert_that(
            result,
            contains_inanyorder(has_property('date', call_log_1.date),
                                has_property('date', call_log_2.date)))
Example #11
0
    def test_find_all_outgoing_for_phone_limited(self):
        identity = "sip/131313"
        limit = 2
        call_logs = _, call_log_1, call_log_2, call_log_3, _ = (self._mock_call_log(),
                                                                self._mock_call_log(date=datetime(2015, 1, 1, 13), source_line_identity=identity),
                                                                self._mock_call_log(date=datetime(2011, 1, 1, 13), source_line_identity=identity),
                                                                self._mock_call_log(date=datetime(2015, 2, 1, 13), source_line_identity=identity),
                                                                self._mock_call_log())

        call_log_dao.create_from_list(call_logs)

        result = call_log_dao.find_all_outgoing_for_phone(identity, limit)

        assert_that(result, has_length(2))
        assert_that(result[0].date, equal_to(call_log_3.date))
        assert_that(result[1].date, equal_to(call_log_1.date))
        assert_that(result[0].source_line_identity, equal_to(call_log_3.source_line_identity))
        assert_that(result[1].source_line_identity, equal_to(call_log_1.source_line_identity))
Example #12
0
    def test_create_from_list(self):
        cel_id_1, cel_id_2 = self.add_cel(), self.add_cel()
        cel_id_3, cel_id_4 = self.add_cel(), self.add_cel()
        call_logs = call_log_1, call_log_2 = (self._mock_call_log((cel_id_1, cel_id_2)),
                                              self._mock_call_log((cel_id_3, cel_id_4)))

        call_log_dao.create_from_list(call_logs)

        call_log_rows = self.session.query(CallLogSchema).all()
        assert_that(call_log_rows, has_length(2))

        call_log_id_1, call_log_id_2 = [call_log.id for call_log in call_log_rows]

        cel_rows = self.session.query(CELSchema).all()
        assert_that(cel_rows, contains_inanyorder(
            all_of(has_property('id', cel_id_1), has_property('call_log_id', call_log_id_1)),
            all_of(has_property('id', cel_id_2), has_property('call_log_id', call_log_id_1)),
            all_of(has_property('id', cel_id_3), has_property('call_log_id', call_log_id_2)),
            all_of(has_property('id', cel_id_4), has_property('call_log_id', call_log_id_2))))
Example #13
0
    def test_find_all_answered_for_phone_limited(self):
        identity = "sip/131313"
        limit = 2
        call_logs = _, call_log_1, call_log_2, _, _ = (self._mock_call_log(source_line_identity=identity),
                                                       self._mock_call_log(date=datetime(2015, 1, 1, 13), destination_line_identity=identity, answered=True),
                                                       self._mock_call_log(date=datetime(2014, 1, 1, 13), destination_line_identity=identity, answered=True),
                                                       self._mock_call_log(date=datetime(2013, 1, 1, 13), destination_line_identity=identity, answered=True),
                                                       self._mock_call_log(source_line_identity=identity))

        call_log_dao.create_from_list(call_logs)

        result = call_log_dao.find_all_answered_for_phone(identity, limit)

        assert_that(result, has_length(2))
        assert_that(result[0].date, equal_to(call_log_1.date))
        assert_that(result[0].destination_line_identity, equal_to(call_log_1.destination_line_identity))
        assert_that(result[0].answered, equal_to(call_log_1.answered))
        assert_that(result[1].date, equal_to(call_log_2.date))
        assert_that(result[1].destination_line_identity, equal_to(call_log_2.destination_line_identity))
        assert_that(result[1].answered, equal_to(call_log_2.answered))
Example #14
0
    def test_find_all_outgoing_for_phone_limited(self):
        identity = "sip/131313"
        limit = 2
        call_logs = _, call_log_1, call_log_2, call_log_3, _ = (
            self._mock_call_log(),
            self._mock_call_log(date=datetime(2015, 1, 1, 13),
                                source_line_identity=identity),
            self._mock_call_log(date=datetime(2011, 1, 1, 13),
                                source_line_identity=identity),
            self._mock_call_log(date=datetime(2015, 2, 1, 13),
                                source_line_identity=identity),
            self._mock_call_log())

        call_log_dao.create_from_list(call_logs)

        result = call_log_dao.find_all_outgoing_for_phone(identity, limit)

        assert_that(result, has_length(2))
        assert_that(result[0].date, equal_to(call_log_3.date))
        assert_that(result[1].date, equal_to(call_log_1.date))
        assert_that(result[0].source_line_identity,
                    equal_to(call_log_3.source_line_identity))
        assert_that(result[1].source_line_identity,
                    equal_to(call_log_1.source_line_identity))
def create_call_logs(entries):
    call_logs = [CallLog(**entry) for entry in entries]
    dao.create_from_list(call_logs)
Example #16
0
def create_call_logs(entries):
    call_logs = [CallLog(**entry) for entry in entries]
    dao.create_from_list(call_logs)