コード例 #1
0
ファイル: test_exporter.py プロジェクト: fdev/bc125csv
 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)
コード例 #2
0
ファイル: test_handler.py プロジェクト: fdev/bc125csv
 def test_help(self):
     """
     Show help.
     """
     with self.assertRaises(SystemExit) as cm:
         main(["help"])
     self.assertEqual(cm.exception.code, None)
コード例 #3
0
 def test_usage(self):
     """
     Show usage.
     """
     with self.assertRaises(SystemExit) as cm:
         main([])
     self.assertEqual(cm.exception.code, None)
コード例 #4
0
ファイル: test_handler.py プロジェクト: fdev/bc125csv
 def test_usage(self):
     """
     Show usage.
     """
     with self.assertRaises(SystemExit) as cm:
         main([])
     self.assertEqual(cm.exception.code, None)
コード例 #5
0
ファイル: test_importer.py プロジェクト: yuzawa-san/bc125csv
 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"])
コード例 #6
0
 def test_help(self):
     """
     Show help.
     """
     with self.assertRaises(SystemExit) as cm:
         main(["help"])
     self.assertEqual(cm.exception.code, None)
コード例 #7
0
ファイル: test_exporter.py プロジェクト: yuzawa-san/bc125csv
 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)
コード例 #8
0
ファイル: test_handler.py プロジェクト: fdev/bc125csv
 def test_version(self):
     """
     Show version.
     """
     with self.assertRaises(SystemExit) as cm:
         main(["-V"])
     self.assertStdOut(VERSION)
     self.assertEqual(cm.exception.code, None)
コード例 #9
0
ファイル: test_importer.py プロジェクト: yuzawa-san/bc125csv
 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)
コード例 #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)
コード例 #11
0
ファイル: test_handler.py プロジェクト: fdev/bc125csv
 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)
コード例 #12
0
ファイル: test_importer.py プロジェクト: yuzawa-san/bc125csv
 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)
コード例 #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)
コード例 #14
0
ファイル: test_handler.py プロジェクト: fdev/bc125csv
 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)
コード例 #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)
コード例 #16
0
ファイル: test_exporter.py プロジェクト: fdev/bc125csv
    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)
コード例 #17
0
ファイル: test_handler.py プロジェクト: fdev/bc125csv
 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)
コード例 #18
0
ファイル: test_handler.py プロジェクト: fdev/bc125csv
    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)
コード例 #19
0
ファイル: test_exporter.py プロジェクト: yuzawa-san/bc125csv
    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)
コード例 #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)
コード例 #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)
コード例 #22
0
ファイル: test_exporter.py プロジェクト: yuzawa-san/bc125csv
 def test_export_sparse_bank2(self):
     """
     Sparse export of bank 2.
     """
     main(["export", "-n", "-s", "-b", "2"])
     self.assertStdOut(EXPORT_BANK2)
コード例 #23
0
ファイル: test_exporter.py プロジェクト: yuzawa-san/bc125csv
 def test_export_sparse(self):
     """
     Sparse export of all channels.
     """
     main(["export", "-n", "-s"])
     self.assertStdOut(EXPORT_SPARSE)
コード例 #24
0
ファイル: test_importer.py プロジェクト: yuzawa-san/bc125csv
 def test_import_stdin(self):
     """
     Import from stdin.
     """
     with mock.patch("sys.stdin", StringIO(IMPORT)):
         main(["import", "-n"])
コード例 #25
0
ファイル: test_exporter.py プロジェクト: yuzawa-san/bc125csv
 def test_export(self):
     """
     Normal export of all channels.
     """
     main(["export", "-n"])
     self.assertStdOut(EXPORT)
コード例 #26
0
ファイル: test_exporter.py プロジェクト: fdev/bc125csv
 def test_export_sparse(self):
     """
     Sparse export of all channels.
     """
     main(["export", "-n", "-s"])
     self.assertStdOut(EXPORT_SPARSE)
コード例 #27
0
ファイル: test_exporter.py プロジェクト: fdev/bc125csv
 def test_export(self):
     """
     Normal export of all channels.
     """
     main(["export", "-n"])
     self.assertStdOut(EXPORT)
コード例 #28
0
ファイル: test_exporter.py プロジェクト: yuzawa-san/bc125csv
 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)
コード例 #29
0
ファイル: test_exporter.py プロジェクト: fdev/bc125csv
 def test_export_sparse_bank2(self):
     """
     Sparse export of bank 2.
     """
     main(["export", "-n", "-s", "-b", "2"])
     self.assertStdOut(EXPORT_BANK2)
コード例 #30
0
ファイル: test_exporter.py プロジェクト: fdev/bc125csv
 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)