예제 #1
0
    def test_sanitize_contract_empty_values(self):
        test_case = ContractSanitizer.sanitize_contract(
            Contract(supplier_ico="",
                     supplier_name="",
                     ministry_ico="",
                     ministry_name=""))
        res = Contract(supplier_ico=None,
                       supplier_name=None,
                       ministry_ico=None,
                       ministry_name=None)
        self.assertEqual(res.supplier_name, test_case.supplier_name)
        self.assertEqual(res.supplier_ico, test_case.supplier_ico)
        self.assertEqual(res.ministry_name, test_case.ministry_name)
        self.assertEqual(res.ministry_ico, test_case.ministry_ico)

        test_case = ContractSanitizer.sanitize_contract(
            Contract(supplier_ico="",
                     supplier_name=None,
                     ministry_ico=None,
                     ministry_name=""))
        res = Contract(supplier_ico=None,
                       supplier_name=None,
                       ministry_ico=None,
                       ministry_name=None)
        self.assertEqual(res.supplier_name, test_case.supplier_name)
        self.assertEqual(res.supplier_ico, test_case.supplier_ico)
        self.assertEqual(res.ministry_name, test_case.ministry_name)
        self.assertEqual(res.ministry_ico, test_case.ministry_ico)
예제 #2
0
    def test_sanitize_contract_icos(self):
        test_case = ContractSanitizer.sanitize_contract(Contract(supplier_ico="1234", ministry_ico="1234"))
        res = Contract(supplier_ico="00001234", ministry_ico="00001234")
        self.assertEqual(res.supplier_ico, test_case.supplier_ico)
        self.assertEqual(res.ministry_ico, test_case.ministry_ico)

        test_case = ContractSanitizer.sanitize_contract(
            Contract(supplier_ico="    as da sd 12 34    ", ministry_ico="   ?>><>\/==\'':123   "))
        res = Contract(supplier_ico="00001234", ministry_ico="00000123")
        self.assertEqual(res.supplier_ico, test_case.supplier_ico)
        self.assertEqual(res.ministry_ico, test_case.ministry_ico)
예제 #3
0
 def test_sanitize_contract_names(self):
     test_case = ContractSanitizer.sanitize_contract(
         Contract(supplier_name="      Ministerstvo    kultury    ",
                  ministry_name="      Ministerstvo    vnitra     "))
     res = Contract(supplier_name="Ministerstvo kultury",
                    ministry_name="Ministerstvo vnitra")
     self.assertEqual(res.supplier_name, test_case.supplier_name)
     self.assertEqual(res.ministry_name, test_case.ministry_name)
예제 #4
0
    def get_generator(self) -> Generator[Contract, None, None]:
        """
        Funkce pro extrahování smluv z registru smluv.
        :return: Generátor, který vrací smlouvy z registru smluv.
        """
        links = self._get_available_files()

        for link in links[2:]:
            contracts = ContractProviderRegistr._get_contracts_with_link(
                link, ministry_filter)
            if not contracts:
                raise Exception(
                    f"No contracts downloaded. Check the url {link} if data are available."
                )
            for contract in contracts:
                ContractSanitizer.sanitize_contract(contract)
                yield contract

        return