Ejemplo n.º 1
0
class UnitTestToken(MockTest):

    def setUp(self):
        MockTest.setUp(self)

        self.scc_parser, self.sub_parser = parsers()
        self.token = Token(self.sub_parser)
        self.default_scopes = ['public_repo']

    # Default arguments
    def testCreateDefaults(self):
        ns = self.scc_parser.parse_args(["token", "create"])
        self.assertEqual(ns.scope, self.default_scopes)
        self.assertFalse(ns.no_set)

    def testCreateNonDefaultScopes(self):
        ns = self.scc_parser.parse_args(
            ["token", "create", "-srepo", "-spublic_repo"])
        self.assertEqual(ns.scope, ["repo", "public_repo"])

    def testCreateNoSet(self):
        ns = self.scc_parser.parse_args(["token", "create", "--no-set"])
        self.assertTrue(ns.no_set)

    # Authorization scopes
    def testAllowedScopes(self):
        for scope in self.token.get_scopes():
            ns = self.scc_parser.parse_args(
                ["token", "create", "-s%s" % scope])
            self.assertEqual(ns.scope, ["%s" % scope])

    def testNonAllowedScope(self):
        self.assertRaises(SystemExit, self.scc_parser.parse_args,
                          ["token", "create", "-sinvalidscope"])
Ejemplo n.º 2
0
    def setup_method(self, method):
        super(TestToken, self).setup_method(method)

        self.scc_parser, self.sub_parser = parsers()
        self.token = Token(self.sub_parser)
        self.default_scopes = ['public_repo']
Ejemplo n.º 3
0
    def setUp(self):
        MockTest.setUp(self)

        self.scc_parser, self.sub_parser = parsers()
        self.token = Token(self.sub_parser)
        self.default_scopes = ['public_repo']