예제 #1
0
    def test_len(self) -> None:
        self.assertEqual(len(get_tokens()), 3)

        for _ in range(10):
            add_token("admin", "asdf")

        self.assertEqual(len(get_tokens()), 13)
예제 #2
0
    def test_token(self) -> None:
        first = get_tokens(token=self.first)
        self.assertEqual(len(first), 1)
        self.assertEqual(first[0].id, 1)
        self.assertEqual(first[0].role, "admin")
        self.assertEqual(first[0].description, "desc1")

        second = get_tokens(token=self.second)
        self.assertEqual(len(second), 1)
        self.assertEqual(second[0].id, 2)
        self.assertEqual(second[0].role, "server")
        self.assertEqual(second[0].description, "desc2")

        third = get_tokens(token=self.third)
        self.assertEqual(len(third), 1)
        self.assertEqual(third[0].id, 3)
        self.assertEqual(third[0].role, "none")
        self.assertEqual(third[0].description, "desc3")
예제 #3
0
    def test_success(self) -> None:
        add_token("admin", "desc0")
        add_token("server", "desc1")
        add_token("none", "desc2")

        delete_token(2)

        tokens = get_tokens()
        self.assertEqual(len(tokens), 2)
        self.assertEqual(tokens[0].role, "admin")
        self.assertEqual(tokens[1].role, "none")
예제 #4
0
 def test_excluded_field(self) -> None:
     tokens = get_tokens()
     self.assertEqual(len(tokens), 3)
     self.assertFalse("token" in tokens[0].keys())
     self.assertFalse("token" in tokens[1].keys())
     self.assertFalse("token" in tokens[2].keys())