test_ca_webscraper.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import unittest
  2. import pytasks
  3. from pytasks import ca_webscraper
  4. from xml.dom import minidom
  5. class test_ca_webscraper(unittest.TestCase):
  6. def test_token(self):
  7. caws = ca_webscraper.ca_webscraper()
  8. token = caws.generate_token("AggAAABU5N5eAAAAAAoAAAD4TgT4GNq+GcN0FAAAAMSNhZfyUDWeIjCieNC6kfRhRLGSBwAAAFNIQS0yNTYgAAAATp4IDQBouepXMLDT+LyJsPuiXICYQxpZlfz8r4/W3aU=")
  9. self.assertEqual(token, "VjFOnggNAGi56lcwsNP4vImw+6JcgJhDGlmV/Pyvj9bdpQ==")
  10. token2 = caws.generate_token("AggAAAD8495eAAAAAAoAAADTxk26GoI5V7SSFAAAAMSNhZfyUDWeIjCieNC6kfRhRLGSBwAAAFNIQS0yNTYgAAAANRtS2ys6VqGk8EaJc88bLLBkSklun/rADunE7kEjFC4=")
  11. self.assertEqual(token2, "VjE1G1LbKzpWoaTwRolzzxsssGRKSW6f+sAO6cTuQSMULg==")
  12. def test_login(self):
  13. caws = ca_webscraper.ca_webscraper()
  14. self.assertEqual(caws.login(), 200)
  15. self.assertEqual(caws.caf[:3], "CAF")
  16. self.assertEqual(caws.cam[:2], "Vj")
  17. def test_report_list(self):
  18. caws = ca_webscraper.ca_webscraper()
  19. caws.login()
  20. result = caws.report_list()
  21. self.assertGreater(result.shape[0], 0)
  22. self.assertEqual(result['id'][0], "iA314AC05125D44F39261E2FD01782C51")
  23. #self.assertEqual(result['report'][0], "Teaminhalt + Service + S.01 Service-Geschäftsmetrik")
  24. def test_export(self):
  25. caws = ca_webscraper.ca_webscraper()
  26. report = { 'report': "Teaminhalt_Finanzbuchhaltung_F.01+Entwicklung+Zeitreihe+mit+EA",
  27. 'id': "i5DCC1FE29E784A78B3A58B41AB97FD89",
  28. 'short': "F.01",
  29. 'params': {
  30. 'p_Auswahl_Zeitraum': [ { 'display': "Einzelne Monate", 'use': "Einzelne Monate" } ],
  31. 'p_Zeitraum': [ { 'display': "Einzelner Monat", 'use': "[gewählter Monat]" } ],
  32. 'p_Von': [ { 'display': "01.01.2019", 'use': "2019-01-01" } ],
  33. 'p_Bis': [ { 'display': "31.12.2020", 'use': "2020-12-31" } ],
  34. 'p_AH': [ { 'display': "AH 2", 'use': "[CARLO_F_Belege].[AH-Gruppe].[AH-Gruppe].[Betrieb]->:[PC].[@MEMBER].[12]" } ]
  35. }
  36. }
  37. rep = minidom.parseString(caws.export(report))
  38. mydoc = minidom.parse("tests/soap/F-01.request.xml")
  39. self.maxDiff = None
  40. self.assertEqual(rep.toxml(), mydoc.toxml())
  41. if __name__ == '__main__':
  42. unittest.main()