示例#1
0
    def test_get_error_type_fake_already_checked(self) -> None:
        """
        Tests of the method which let us get the actual error type 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_type(given, already_checked=True))
示例#2
0
    def test_get_error_type_not_error(self) -> None:
        """
        Tests of the method which let us get the actual error type 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_type(given)

        self.assertEqual(expected, actual)
示例#3
0
    def test_get_error_type(self) -> None:
        """
        Tests of the method which let us get the actual error type.
        """

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

        actual = Requester.get_error_type(given)

        self.assertEqual(expected, actual)
示例#4
0
    def test_get_error_type_already_checked(self) -> None:
        """
        Tests of the method which let us get the actual error type 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 = "not_found"

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

        self.assertEqual(expected, actual)