Something went wrong. Try again.
Instant MicroVMs/Unikernels for macOS and Linux
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839"""Unit tests for the GraphQL-related error types."""
import osimport sysimport unittest
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
from bsdkrun.errors import AuthError, BsdkrunError, GraphQLError # noqa: E402
class TestGraphQLError(unittest.TestCase): def test_is_a_bsdkrun_error(self): self.assertIsInstance(GraphQLError("boom"), BsdkrunError)
def test_carries_an_optional_code(self): err = GraphQLError("boom", "INVALID_ARGUMENT") self.assertEqual(err.code, "INVALID_ARGUMENT") self.assertEqual(str(err), "boom")
def test_code_defaults_to_none(self): self.assertIsNone(GraphQLError("boom").code)
class TestAuthError(unittest.TestCase): def test_is_a_graphql_error_with_unauthenticated_code(self): err = AuthError() self.assertIsInstance(err, GraphQLError) self.assertEqual(err.code, "UNAUTHENTICATED")
def test_custom_message(self): err = AuthError("nope") self.assertEqual(str(err), "nope") self.assertEqual(err.code, "UNAUTHENTICATED")
if __name__ == "__main__": unittest.main()