浏览代码

validate inv. + print resp

marton levente 8 月之前
父节点
当前提交
a27f19b764
共有 2 个文件被更改,包括 12 次插入5 次删除
  1. 2 1
      anafapi/anafoauth.py
  2. 10 4
      tests/test_anafoauth.py

+ 2 - 1
anafapi/anafoauth.py

@@ -120,7 +120,7 @@ class Efactoauth(Anafoauth):
             url = self.VALIDATE.format(type_)
             print(url)
             resp = self.oauth.post(url=url, data=files, headers=headers)
-            # print(resp.status_code, resp.json())
+            print(resp.status_code, resp.text)
             print(resp.status_code, resp.json())
             return resp.json()
 
@@ -156,6 +156,7 @@ class Efactoauth(Anafoauth):
     def get_all_messages(self, vat_id, days=60, env='test', extract=False) -> dict:
         url = self.MESSAGES.format(env, days, vat_id)
         resp = self.oauth.get(url=url)
+        print(resp.text)
         try:
             self.invoices = resp.json()
             path = 'efact'

+ 10 - 4
tests/test_anafoauth.py

@@ -16,8 +16,8 @@ elif platform.system() == 'Windows':
 
 class oauthTest(unittest.TestCase):
     anoauth = Anafoauth(
-        client_id='82e0a1c84f2973ec23cf7f6238bb0023e996dd82b9f3a162',
-        client_secret='c227aa241f3bdf49f9c978a4a152926ee850ba64371f0023e996dd82b9f3a162',
+        client_id='16cbef8754bef0bcf015529353427e8a7e3ee71d56879565',
+        client_secret='c6aa66d89002f36461f93facd990e6bf5bc706e1df897e8a7e3ee71d56879565',
         redirect_uri='https://www.anaf.ro/oauth2callback',
     )
 
@@ -40,8 +40,8 @@ class oauthTest(unittest.TestCase):
 
 class efactTest(unittest.TestCase):
     efactoauth = Efactoauth(
-        client_id='82e0a1c84f2973ec23cf7f6238bb0023e996dd82b9f3a162',
-        client_secret='c227aa241f3bdf49f9c978a4a152926ee850ba64371f0023e996dd82b9f3a162',
+        client_id='16cbef8754bef0bcf015529353427e8a7e3ee71d56879565',
+        client_secret='c6aa66d89002f36461f93facd990e6bf5bc706e1df897e8a7e3ee71d56879565',
         redirect_uri='https://www.anaf.ro/oauth2callback',
     )
     efactoauth.load_token_file(token_file_path.format('efact.json'))
@@ -93,6 +93,12 @@ class efactTest(unittest.TestCase):
         print(latest)
         # os.replace(latest, latest.replace('.xml'.lower(), '_booked.xml'))
 
+    def test_validate_invoice(self):
+        # print(os.listdir('c:/Users/DECEL/FACT1/MZK/2023.01.03/'))
+        # for file in os.listdir('c:/Users/DECEL/FACT1/MZK/2023.01.03/'):
+        #     self.efactoauth.validate_invoice(os.path.join('c:/Users/DECEL/FACT1/MZK/2023.01.03/', file))
+        self.efactoauth.validate_invoice('c:/Users/DECEL/FACT1/MZK/2023.01.03/MZK2415.xml')
+
 
 if __name__ == "__main__":
     # unittest.main()