Exemplo 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)
Exemplo n.º 2
0
 def test_help(self):
     """
     Show help.
     """
     with self.assertRaises(SystemExit) as cm:
         main(["help"])
     self.assertEqual(cm.exception.code, None)
Exemplo n.º 3
0
 def test_usage(self):
     """
     Show usage.
     """
     with self.assertRaises(SystemExit) as cm:
         main([])
     self.assertEqual(cm.exception.code, None)
Exemplo n.º 4
0
 def test_usage(self):
     """
     Show usage.
     """
     with self.assertRaises(SystemExit) as cm:
         main([])
     self.assertEqual(cm.exception.code, None)
Exemplo 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"])
Exemplo n.º 6
0
 def test_help(self):
     """
     Show help.
     """
     with self.assertRaises(SystemExit) as cm:
         main(["help"])
     self.assertEqual(cm.exception.code, None)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo 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)
Exemplo n.º 22
0
 def test_export_sparse_bank2(self):
     """
     Sparse export of bank 2.
     """
     main(["export", "-n", "-s", "-b", "2"])
     self.assertStdOut(EXPORT_BANK2)
Exemplo n.º 23
0
 def test_export_sparse(self):
     """
     Sparse export of all channels.
     """
     main(["export", "-n", "-s"])
     self.assertStdOut(EXPORT_SPARSE)
Exemplo n.º 24
0
 def test_import_stdin(self):
     """
     Import from stdin.
     """
     with mock.patch("sys.stdin", StringIO(IMPORT)):
         main(["import", "-n"])
Exemplo n.º 25
0
 def test_export(self):
     """
     Normal export of all channels.
     """
     main(["export", "-n"])
     self.assertStdOut(EXPORT)
Exemplo n.º 26
0
 def test_export_sparse(self):
     """
     Sparse export of all channels.
     """
     main(["export", "-n", "-s"])
     self.assertStdOut(EXPORT_SPARSE)
Exemplo n.º 27
0
 def test_export(self):
     """
     Normal export of all channels.
     """
     main(["export", "-n"])
     self.assertStdOut(EXPORT)
Exemplo 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)
Exemplo n.º 29
0
 def test_export_sparse_bank2(self):
     """
     Sparse export of bank 2.
     """
     main(["export", "-n", "-s", "-b", "2"])
     self.assertStdOut(EXPORT_BANK2)
Exemplo 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)