Esempio n. 1
0
 def test_export_bank13(self):
     """
     Export of bank 13 (non-existing).
     """
     with self.assertRaises(SystemExit) as cm:
         main(["export", "-n", "-b", "13"])
     self.assertNotEqual(cm.exception.code, None)
Esempio n. 2
0
 def test_help(self):
     """
     Show help.
     """
     with self.assertRaises(SystemExit) as cm:
         main(["help"])
     self.assertEqual(cm.exception.code, None)
Esempio n. 3
0
 def test_usage(self):
     """
     Show usage.
     """
     with self.assertRaises(SystemExit) as cm:
         main([])
     self.assertEqual(cm.exception.code, None)
Esempio n. 4
0
 def test_usage(self):
     """
     Show usage.
     """
     with self.assertRaises(SystemExit) as cm:
         main([])
     self.assertEqual(cm.exception.code, None)
Esempio n. 5
0
 def test_import(self):
     """
     Normal import into bank 1.
     """
     with mock.patch("os.path.isfile", return_value=True):
         with mock.patch.object(builtins, 'open', return_value=StringIO(IMPORT)):
             main(["import", "-n", "-b", "1", "-i", "import.csv"])
Esempio n. 6
0
 def test_help(self):
     """
     Show help.
     """
     with self.assertRaises(SystemExit) as cm:
         main(["help"])
     self.assertEqual(cm.exception.code, None)
Esempio n. 7
0
 def test_export_bank13(self):
     """
     Export of bank 13 (non-existing).
     """
     with self.assertRaises(SystemExit) as cm:
         main(["export", "-n", "-b", "13"])
     self.assertNotEqual(cm.exception.code, None)
Esempio n. 8
0
 def test_version(self):
     """
     Show version.
     """
     with self.assertRaises(SystemExit) as cm:
         main(["-V"])
     self.assertStdOut(VERSION)
     self.assertEqual(cm.exception.code, None)
Esempio n. 9
0
 def test_import_nofile(self):
     """
     Non-existing file import.
     """
     with mock.patch("os.path.isfile", return_value=False):
         with self.assertRaises(SystemExit) as cm:
             main(["import", "-n", "-i", "doesnotexist.csv"])
         self.assertNotEqual(cm.exception.code, None)
Esempio n. 10
0
 def test_version(self):
     """
     Show version.
     """
     with self.assertRaises(SystemExit) as cm:
         main(["-V"])
     self.assertStdOut(VERSION)
     self.assertEqual(cm.exception.code, None)
Esempio n. 11
0
 def test_verify_nofile(self):
     """
     Verify csv data from non-existing file.
     """
     with mock.patch("os.path.isfile", return_value=False):
         with self.assertRaises(SystemExit) as cm:
             main(["verify", "-v", "-i", "doesnotexist.csv"])
         self.assertStdErr("")
         self.assertNotEqual(cm.exception.code, None)
Esempio n. 12
0
 def test_import_errors(self):
     """
     Invalid import into bank 2.
     """
     with mock.patch("os.path.isfile", return_value=True):
         with mock.patch.object(builtins, 'open', return_value=StringIO(IMPORT_ERRORS)):
             with self.assertRaises(SystemExit) as cm:
                 main(["import", "-n", "-b", "2", "-i", "import_errors.csv"])
             self.assertNotEqual(cm.exception.code, None)
Esempio n. 13
0
 def test_verify_nofile(self):
     """
     Verify csv data from non-existing file.
     """
     with mock.patch("os.path.isfile", return_value=False):
         with self.assertRaises(SystemExit) as cm:
             main(["verify", "-v", "-i", "doesnotexist.csv"])
         self.assertStdErr("")
         self.assertNotEqual(cm.exception.code, None)
Esempio n. 14
0
 def test_verify_stdin(self):
     """
     Verify csv data from stdin.
     """
     with mock.patch("sys.stdin", StringIO(IMPORT)):
         with self.assertRaises(SystemExit) as cm:
             main(["verify"])
         self.assertStdOut("")
         self.assertStdErr("")
         self.assertEqual(cm.exception.code, None)
Esempio n. 15
0
 def test_verify_stdin(self):
     """
     Verify csv data from stdin.
     """
     with mock.patch("sys.stdin", StringIO(IMPORT)):
         with self.assertRaises(SystemExit) as cm:
             main(["verify"])
         self.assertStdOut("")
         self.assertStdErr("")
         self.assertEqual(cm.exception.code, None)
Esempio n. 16
0
    def test_export_outfile(self):
        """
        Write export to file.
        """
        with mock.patch.object(builtins, "open", mock.mock_open()):
            main(["export", "-n", "-s", "-o", "output.csv"])

        with self.assertRaises(SystemExit) as cm:
            main(["export", "-n", "-s", "-o", "/path/that/does/not/exist/output.csv"])
        self.assertNotEqual(cm.exception.code, None)
Esempio n. 17
0
 def test_verify_file(self):
     """
     Verify csv data from file.
     """
     with mock.patch("os.path.isfile", return_value=True):
         with mock.patch.object(builtins, 'open', return_value=StringIO(IMPORT)):
             with self.assertRaises(SystemExit) as cm:
                 main(["verify", "-v", "-i", "import.csv"])
             self.assertStdOut("")
             self.assertStdErr("No errors found.")
             self.assertEqual(cm.exception.code, None)
Esempio n. 18
0
    def test_shell(self):
        """
        Test interactive shell
        """
        with mock.patch("sys.stdin", StringIO("PRG\n\nBLT,AO\nEPG")):
            with self.assertRaises(SystemExit) as cm:
                main(["shell", "-n"])
            self.assertEqual(cm.exception.code, None)

        with mock.patch("sys.stdin", PseudoTTY(StringIO("PRG\n\nBLT,AO\nEPG"))):
            with self.assertRaises(SystemExit) as cm:
                main(["shell", "-n"])
            self.assertEqual(cm.exception.code, None)
Esempio n. 19
0
    def test_export_outfile(self):
        """
        Write export to file.
        """
        with mock.patch.object(builtins, "open", mock.mock_open()):
            main(["export", "-n", "-s", "-o", "output.csv"])

        with self.assertRaises(SystemExit) as cm:
            main([
                "export", "-n", "-s", "-o",
                "/path/that/does/not/exist/output.csv"
            ])
        self.assertNotEqual(cm.exception.code, None)
Esempio n. 20
0
 def test_verify_file(self):
     """
     Verify csv data from file.
     """
     with mock.patch("os.path.isfile", return_value=True):
         with mock.patch.object(builtins,
                                'open',
                                return_value=StringIO(IMPORT)):
             with self.assertRaises(SystemExit) as cm:
                 main(["verify", "-v", "-i", "import.csv"])
             self.assertStdOut("")
             self.assertStdErr("No errors found.")
             self.assertEqual(cm.exception.code, None)
Esempio n. 21
0
    def test_shell(self):
        """
        Test interactive shell
        """
        with mock.patch("sys.stdin", StringIO("PRG\n\nBLT,AO\nEPG")):
            with self.assertRaises(SystemExit) as cm:
                main(["shell", "-n"])
            self.assertEqual(cm.exception.code, None)

        with mock.patch("sys.stdin",
                        PseudoTTY(StringIO("PRG\n\nBLT,AO\nEPG"))):
            with self.assertRaises(SystemExit) as cm:
                main(["shell", "-n"])
            self.assertEqual(cm.exception.code, None)
Esempio n. 22
0
 def test_export_sparse_bank2(self):
     """
     Sparse export of bank 2.
     """
     main(["export", "-n", "-s", "-b", "2"])
     self.assertStdOut(EXPORT_BANK2)
Esempio n. 23
0
 def test_export_sparse(self):
     """
     Sparse export of all channels.
     """
     main(["export", "-n", "-s"])
     self.assertStdOut(EXPORT_SPARSE)
Esempio n. 24
0
 def test_import_stdin(self):
     """
     Import from stdin.
     """
     with mock.patch("sys.stdin", StringIO(IMPORT)):
         main(["import", "-n"])
Esempio n. 25
0
 def test_export(self):
     """
     Normal export of all channels.
     """
     main(["export", "-n"])
     self.assertStdOut(EXPORT)
Esempio n. 26
0
 def test_export_sparse(self):
     """
     Sparse export of all channels.
     """
     main(["export", "-n", "-s"])
     self.assertStdOut(EXPORT_SPARSE)
Esempio n. 27
0
 def test_export(self):
     """
     Normal export of all channels.
     """
     main(["export", "-n"])
     self.assertStdOut(EXPORT)
Esempio n. 28
0
 def test_export_sparse_bank2_empty(self):
     """
     Sparse export of bank 2 including empty channels.
     """
     main(["export", "-n", "-s", "-b", "2", "-e"])
     self.assertStdOut(EXPORT_BANK2_EMPTY)
Esempio n. 29
0
 def test_export_sparse_bank2(self):
     """
     Sparse export of bank 2.
     """
     main(["export", "-n", "-s", "-b", "2"])
     self.assertStdOut(EXPORT_BANK2)
Esempio n. 30
0
 def test_export_sparse_bank2_empty(self):
     """
     Sparse export of bank 2 including empty channels.
     """
     main(["export", "-n", "-s", "-b", "2", "-e"])
     self.assertStdOut(EXPORT_BANK2_EMPTY)