Example #1
0
    def testInvalidFile(self):
        with self.assertRaises(SystemExit) as cm:
            parse_args(["-f", "440044.rq"])

        self.assertEqual(cm.exception.code, 2)
        self.assertEqual(
            sys.stderr.getvalue().split("\n")[1],
            "rqw: error: argument -f/--file: file '440044.rq' is not found",
        )
Example #2
0
    def testInvalidFormat(self):
        with self.assertRaises(SystemExit) as cm:
            parse_args(["-Q", testquery, "-F", "jjssoonn"])

        self.assertEqual(cm.exception.code, 2)
        self.assertEqual(
            sys.stderr.getvalue().split("\n")[1],
            "rqw: error: argument -F/--format: invalid choice: 'jjssoonn' (choose from 'json', 'xml', 'turtle', 'n3', 'rdf', 'rdf+xml', 'csv', 'tsv', 'json-ld')",
        )
Example #3
0
    def testQueryAndFile(self):
        with self.assertRaises(SystemExit) as cm:
            parse_args(["-Q", testquery, "-f", "-"])

        self.assertEqual(cm.exception.code, 2)
        self.assertEqual(
            sys.stderr.getvalue().split("\n")[1],
            "rqw: error: argument -f/--file: not allowed with argument -Q/--query",
        )
Example #4
0
    def testNoarg(self):
        with self.assertRaises(SystemExit) as cm:
            parse_args([])

        self.assertEqual(cm.exception.code, 2)
        self.assertEqual(
            sys.stderr.getvalue().split("\n")[1],
            "rqw: error: one of the arguments -f/--file -Q/--query is required",
        )
Example #5
0
    def testVersion(self):
        with self.assertRaises(SystemExit) as cm:
            parse_args(["-V"])

        self.assertEqual(cm.exception.code, 0)
        self.assertEqual(sys.stdout.getvalue()[:3], "rqw")
Example #6
0
    def testHelp(self):
        with self.assertRaises(SystemExit) as cm:
            parse_args(["-h"])

        self.assertEqual(cm.exception.code, 0)
        self.assertEqual(sys.stdout.getvalue()[:5], "usage")