From 1f057a549d4cef162a10af3b440d836505c029e9 Mon Sep 17 00:00:00 2001 From: Delena Malan Date: Mon, 20 Jul 2020 10:28:22 +0200 Subject: [PATCH 1/2] Add test to reproduce NavigableString error --- tests/test_questions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_questions.py b/tests/test_questions.py index 50be1de..50dc2e9 100644 --- a/tests/test_questions.py +++ b/tests/test_questions.py @@ -45,6 +45,12 @@ def test_extract_answer_from_html(self): assert_equal('
  1. Total discontinued ammunition still in circulation in the SA Police Service:

PROVINCE

PREVIOUS QUANTITY

CURRENT QUANTITY

Western Cape

68,542

74,627

Eastern Cape

538,937

594,806

Northern Cape

104,459

38,326

Free State

410,981

135,065

KwaZulu-Natal

523,978

228,164

North West

233,850

24,120

Mpumalanga

296,479

92,676

Limpopo

35,080

10,446

Gauteng

71,764

63,209

Head Office Divisions

2,061,456

1,704,286

TOTAL:

4,345,526

2,965,725

This ammunition may only be used for training purposes. However, this ammunition is still in use by Specialized Units within the SAPS for training, ballistic testing of firearms and IBIS test firing purposes.

  1. An instruction to withdraw all such ammunition was issued from the Divisional Commissioner, Supply Chain Management on 12 September 2006, which also instructed that such ammunition may not be issued any longer as from this date.

Recently another instruction in regard was issued by the Divisional Commissioner, Supply Chain Management to all Provisional Commissioners and Divisional Commissioners to immediately withdraw all non-standard, obsolete and unserviceable ammunition not in use, from their respective provinces and divisions.

All non-standard, obsolete and unserviceable ammunition is being sent on a continuous basis to the Ammunition Store at the Division Supply Chain Management for disposal and this is being monitored to ensure compliance.

', out) + def test_extract_answer_from_html_with_different_format(self): + html = '

NATIONAL ASSEMBLY

QUESTION FOR WRITTEN REPLY

QUESTION NO: 1153

DATE OF PUBLICATION: 12 JUNE 2020

INTERNAL QUESTION PAPER: 20 OF 2020

Ms T Breedt (FF Plus) to ask the Minister in The Presidency for Women, Youth and Persons with Disabilities:

(1)\tWhether, with reference to her reply to question 937 on 4 June 2020, her Office purchased any goods and/or services below the amount of R500\xa0000 connected to the Covid-19 pandemic; if not, what is the position in this regard; if so, what (a) is the name of each company from which the specified goods and/or services were purchased, (b) is the amount of each transaction and (c) was the service and/or product that each company rendered;

(2)\twhether there was any deviation from the standard supply chain management procedures in the specified transactions; if so, (a) why and (b) what are the relevant details in each case;

(3)\twhat were the reasons that the goods and/or services were purchased from the specified companies;

(4)\twhether she will make a statement on the matter?\tNW1453E

REPLY

  1. Name of Company
  1. Amount transaction
  1. Service/Product Rendered

Rearabilwe Devoted Creations

R25\xa0000.00

10 x 25L surface sanitizer

Ndamu General Supplier CC

R21\xa0000.00

Sanitization of Building

Manapyane Holdings (Pty) Ltd

R11\xa0500.00

Infrared Thermometers

  1. There were no deviations from the standard supply chain management procedures in the specified transactions.

(3)\tThe Department utilised the list of service providers as provided by National Treasury.

  1. No.
' + out = QuestionAnswerScraper().extract_answer_from_html(html) + + assert_equal('
  1. Name of Company
  1. Amount transaction
  1. Service/Product Rendered

Rearabilwe Devoted Creations

R25\xa0000.00

10 x 25L surface sanitizer

Ndamu General Supplier CC

R21\xa0000.00

Sanitization of Building

Manapyane Holdings (Pty) Ltd

R11\xa0500.00

Infrared Thermometers

  1. There were no deviations from the standard supply chain management procedures in the specified transactions.

(3)\tThe Department utilised the list of service providers as provided by National Treasury.

  1. No.
', out) + def test_extract_answer_from_text(self): out = self.scraper.extract_answer_from_html('\n36/1/4/1/201500013\nNATIONAL ASSEMBLY\nFOR WRITTEN REPLY\nQUESTION 161\nDATE OF PUBLICATION IN INTERNAL QUESTION PAPER: 12 FEBRUARY 2015 \n(INTERNAL QUESTION PAPER NO 1-2015)\n161. Ms D Kohler (DA) to ask the Minister of Police:\n(a) How many SA Police Service officers in each province currently do not have firearm (i) licenses or (ii) competency certificates and (b) of these, how many still carry firearms?\nNW168E\nREPLY:\n(a) Members of the SAPS, for the purposes of reporting, are categorized under Operational, Support and Management where operational members were first prioritized to obtain their firearm competency. The statistics on 9 February 2015 as per the Training Administration System (TAS) of the SAPS per Province who have not completed the prescribed training are as follows:\n\n\n\n\nPROVINCE\n\n\nTOTAL OPERATIONAL MEMBERS PER PROVINCE\n\n\nNOT COMPLETED\n\n\n% NOT COMPLETED\n\n\n\n\xa0\n\xa0\n\xa0\n\xa0\n\n\n\nWESTERN CAPE\n\n\n15 096\n\n\n872\n\n\n5.78%\n\n\n\n\nEASTERN CAPE\n\n\n15 186\n\n\n988\n\n\n6.51%\n\n\n\n\nNORTHERN CAPE\n\n\n5 215\n\n\n481\n\n\n9.22%\n\n\n\n\nFREE STATE\n\n\n9 404\n\n\n968\n\n\n10.29%\n\n\n\n\nKWAZULU-NATAL\n\n\n18 646\n\n\n406\n\n\n2.18%\n\n\n\n\nNORTH WEST\n\n\n7 522\n\n\n1 040\n\n\n13.83%\n\n\n\n\nMPUMALANGA\n\n\n7 510\n\n\n1 250\n\n\n16.64%\n\n\n\n\nLIMPOPO\n\n\n9 643\n\n\n971\n\n\n10.07%\n\n\n\n\nGAUTENG\n\n\n25 764\n\n\n2 352\n\n\n9.13%\n\n\n\n\nTOTAL\n\n\n113 986\n\n\n9 328\n\n\n8.18%\n\n\n\n\nFrom the 9 328 members, 2 609 are competent in the use of a handgun, 3 182 in the use of a rifle, 4 197 in the use of a shotgun and 4 191 in legal principles.\n(b) 5 728 Members of the 9 328 members who have not completed the prescribed training, according to the TAS system, have been issued with a firearm on their personal inventory.\n') assert_equal('\n(a) Members of the SAPS, for the purposes of reporting, are categorized under Operational, Support and Management where operational members were first prioritized to obtain their firearm competency. The statistics on 9 February 2015 as per the Training Administration System (TAS) of the SAPS per Province who have not completed the prescribed training are as follows:\n\n\n\n\nPROVINCE\n\n\nTOTAL OPERATIONAL MEMBERS PER PROVINCE\n\n\nNOT COMPLETED\n\n\n% NOT COMPLETED\n\n\n\n\xa0\n\xa0\n\xa0\n\xa0\n\n\n\nWESTERN CAPE\n\n\n15 096\n\n\n872\n\n\n5.78%\n\n\n\n\nEASTERN CAPE\n\n\n15 186\n\n\n988\n\n\n6.51%\n\n\n\n\nNORTHERN CAPE\n\n\n5 215\n\n\n481\n\n\n9.22%\n\n\n\n\nFREE STATE\n\n\n9 404\n\n\n968\n\n\n10.29%\n\n\n\n\nKWAZULU-NATAL\n\n\n18 646\n\n\n406\n\n\n2.18%\n\n\n\n\nNORTH WEST\n\n\n7 522\n\n\n1 040\n\n\n13.83%\n\n\n\n\nMPUMALANGA\n\n\n7 510\n\n\n1 250\n\n\n16.64%\n\n\n\n\nLIMPOPO\n\n\n9 643\n\n\n971\n\n\n10.07%\n\n\n\n\nGAUTENG\n\n\n25 764\n\n\n2 352\n\n\n9.13%\n\n\n\n\nTOTAL\n\n\n113 986\n\n\n9 328\n\n\n8.18%\n\n\n\n\nFrom the 9 328 members, 2 609 are competent in the use of a handgun, 3 182 in the use of a rifle, 4 197 in the use of a shotgun and 4 191 in legal principles.\n(b) 5 728 Members of the 9 328 members who have not completed the prescribed training, according to the TAS system, have been issued with a firearm on their personal inventory.\n', out) From 97c507a1c0299e4254a8789dadf9b0c1333ffa0c Mon Sep 17 00:00:00 2001 From: Delena Malan Date: Mon, 20 Jul 2020 10:29:31 +0200 Subject: [PATCH 2/2] Update beautifulsoup requirement --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f9586ce..b05ec23 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,7 @@ # https://packaging.python.org/en/latest/requirements.html install_requires=[ 'mammoth >= 0.3.19, < 0.3.31', - 'beautifulsoup4 >= 4.4.0', + 'beautifulsoup4 >= 4.8.2', ], # List additional groups of dependencies here (e.g. development