Exemplo n.º 1
0
    def test_list_protocols_by_name(self, *args):
        protocol_vos = ProtocolFactory.build_batch(10,
                                                   domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), protocol_vos))

        params = {'name': protocol_vos[0].name, 'domain_id': self.domain_id}

        self.transaction.method = 'list'
        protocol_svc = ProtocolService(transaction=self.transaction)
        protocol_vos, total_count = protocol_svc.list(params)
        ProtocolsInfo(protocol_vos, total_count)

        self.assertEqual(len(protocol_vos), 1)
        self.assertIsInstance(protocol_vos[0], Protocol)
        self.assertEqual(total_count, 1)
Exemplo n.º 2
0
    def test_list_protocols_by_protocol_type(self, *args):
        internal_protocol_vos = ProtocolFactory.build_batch(
            5, protocol_type='INTERNAL', domain_id=self.domain_id)
        external_protocol_vos = ProtocolFactory.build_batch(
            10, protocol_type='EXTERNAL', domain_id=self.domain_id)
        list(map(lambda vo: vo.save(), external_protocol_vos))

        params = {'protocol_type': 'EXTERNAL', 'domain_id': self.domain_id}

        self.transaction.method = 'list'
        protocol_svc = ProtocolService(transaction=self.transaction)
        protocol_vos, total_count = protocol_svc.list(params)
        ProtocolsInfo(protocol_vos, total_count)

        self.assertEqual(len(protocol_vos), 10)
        self.assertIsInstance(protocol_vos[0], Protocol)
        self.assertEqual(total_count, 10)