[damned-lies] Mock network access in testing http pot file



commit e54e49c3367a7e51fd5751db6015b27949b29f55
Author: Claude Paroz <claude 2xlibre net>
Date:   Thu Oct 8 22:38:18 2020 +0200

    Mock network access in testing http pot file

 stats/tests/tests.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index 88202629..09e40125 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -603,7 +603,10 @@ class DomainTests(TestModuleBase):
             pot_method='url',
             pot_params='https://l10n.gnome.org/POT/damned-lies.master/damned-lies.master.pot'
         )
-        potfile, errs = dom.generate_pot_file(self.branch)
+        with patch('stats.models.request.urlopen') as mock_urlopen:
+            with open(Path(__file__).parent / 'empty.pot', mode='rb') as fh:
+                mock_urlopen.return_value = fh
+                potfile, errs = dom.generate_pot_file(self.branch)
         self.addCleanup(os.remove, str(potfile))
         self.assertTrue(potfile.exists())
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]