test_importer.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # ============================================================================
  2. # This file is part of Pwman3.
  3. #
  4. # Pwman3 is free software; you can redistribute iut and/or modify
  5. # it under the terms of the GNU General Public License, version 2
  6. # as published by the Free Software Foundation;
  7. #
  8. # Pwman3 is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with Pwman3; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. # ============================================================================
  17. # Copyright (C) 2012, 2013, 2014 Oz Nahum Tiram <nahumoz@gmail.com>
  18. # ============================================================================
  19. import os
  20. import unittest
  21. from pwman.util.crypto_engine import CryptoEngine
  22. from collections import namedtuple
  23. from .test_crypto_engine import give_key, DummyCallback
  24. from pwman.exchange.importer import CSVImporter
  25. import_example = """
  26. Username;URL;Password;Notes;Tags
  27. alice;wonderland.com;secert;scratch;foo,bar
  28. hatman;behindthemirror.com;pa33w0rd;scratch;foo,bar
  29. """
  30. with open('import_file.csv', 'w') as f:
  31. f.write(import_example)
  32. class TestImporter(unittest.TestCase):
  33. def setUp(self):
  34. config = {}
  35. Args = namedtuple('args', 'import_file')
  36. self.importer = CSVImporter(Args(import_file='foo'), config)
  37. def test_fail(self):
  38. self.assertTrue(True)
  39. if __name__ == '__main__':
  40. ce = CryptoEngine.get()
  41. ce.callback = DummyCallback()
  42. ce.changepassword(reader=give_key)
  43. try:
  44. unittest.main(verbosity=2, failfast=True)
  45. except SystemExit:
  46. os.remove('import_file.csv')