Beispiel #1
0
    def test_get_error_message_fake_already_checked(self) -> None:
        """
        Tests of the method which let us get the actual error message for the
        case that we "already know" that it is an error but it was just fake.
        """

        given = {
            "@type": "user",
            "@href": "/user/4549848944894848948949",
            "@representation": "standard",
            "@permissions": {
                "read": True,
                "sync": True
            },
            "id": 4549848944894848948949,
            "login": "******",
            "name": "Foo Bar",
            "github_id": 1148942198798789784897949849484523106,
            "vcs_id": "1148942198798789784897949849484523106",
            "vcs_type": "GithubUser",
            "avatar_url": None,
            "education": False,
            "allow_migration": False,
            "email": "*****@*****.**",
            "is_syncing": False,
            "synced_at": "2020-10-14T14:53:08Z",
            "recently_signed_up": False,
            "secure_user_hash": None,
        }

        self.assertRaises(
            KeyError,
            lambda: Requester.get_error_message(given, already_checked=True))
Beispiel #2
0
    def test_get_error_message_not_error(self) -> None:
        """
        Tests of the method which let us get the actual error message for the
        case that no error is actually given.
        """

        given = {
            "@type": "user",
            "@href": "/user/4549848944894848948949",
            "@representation": "standard",
            "@permissions": {
                "read": True,
                "sync": True
            },
            "id": 4549848944894848948949,
            "login": "******",
            "name": "Foo Bar",
            "github_id": 1148942198798789784897949849484523106,
            "vcs_id": "1148942198798789784897949849484523106",
            "vcs_type": "GithubUser",
            "avatar_url": None,
            "education": False,
            "allow_migration": False,
            "email": "*****@*****.**",
            "is_syncing": False,
            "synced_at": "2020-10-14T14:53:08Z",
            "recently_signed_up": False,
            "secure_user_hash": None,
        }
        expected = None

        actual = Requester.get_error_message(given)

        self.assertEqual(expected, actual)
Beispiel #3
0
    def test_get_error_message(self) -> None:
        """
        Tests of the method which let us get the actual error message.
        """

        given = {
            "@type": "error",
            "error_type": "not_found",
            "error_message": "repository not found (or insufficient access)",
            "resource_type": "repository",
        }
        expected = "repository not found (or insufficient access)"

        actual = Requester.get_error_message(given)

        self.assertEqual(expected, actual)
Beispiel #4
0
    def test_get_error_message_already_checked(self) -> None:
        """
        Tests of the method which let us get the actual error message for the
        case that we already know that it is an error.
        """

        given = {
            "@type": "error",
            "error_type": "not_found",
            "error_message": "repository not found (or insufficient access)",
            "resource_type": "repository",
        }
        expected = "repository not found (or insufficient access)"

        actual = Requester.get_error_message(given, already_checked=True)

        self.assertEqual(expected, actual)