Beispiel #1
0
    def test_wrapper_init(self):
        new_moco = moco.Moco(auth={"api_key": "api_key", "domain": "domain"})
        new_moco.authenticate()

        assert new_moco.api_key == "api_key"
        assert new_moco.domain == "domain"

        assert isinstance(new_moco._requestor, util.requestor.DefaultRequestor)
 def setup_moco(self):
     self._moco = moco.Moco(
         auth={
             "api_key": pytest.placeholders.mocotest_apikey,
             "domain": pytest.placeholders.mocotest_domain
         },
         requestor=NoRetryRequestor(),
         objector=DefaultObjector(),
     )
Beispiel #3
0
    def test_wrapper_clear_impersonation(self):
        impersonate_user_id = 123
        new_moco = moco.Moco()
        new_moco.impersonate(impersonate_user_id)

        assert new_moco._impersonation_user_id == impersonate_user_id

        new_moco.clear_impersonation()

        assert new_moco._impersonation_user_id is None
Beispiel #4
0
    def test_wrapper_init_requestor_overwrite(self):
        new_moco = moco.Moco(auth={
            "api_key": "api_key",
            "domain": "domain"
        },
                             requestor=util.requestor.RawRequestor())

        new_moco.authenticate()

        assert new_moco.api_key == "api_key"
        assert new_moco.domain == "domain"

        assert isinstance(new_moco._requestor, util.requestor.RawRequestor)
Beispiel #5
0
    def test_header_overwrite(self):
        my_content_type = "my content type"
        new_headers = {"Content-Type": my_content_type}

        new_moco = moco.Moco(objector=util.objector.RawObjector(),
                             requestor=util.requestor.RawRequestor())
        response = new_moco.request("GET",
                                    "path",
                                    bypass_auth=True,
                                    headers=new_headers)

        requestor_args = response["args"]
        for key, value in requestor_args:
            if key == "headers":
                headers = value
                assert headers["Content-Type"] == my_content_type
Beispiel #6
0
    def test_header_append(self):
        additional_header = "this header is new"
        additional_header_key = "not-needed-header"

        new_moco = moco.Moco(objector=util.objector.RawObjector(),
                             requestor=util.requestor.RawRequestor())
        response = new_moco.request(
            "GET",
            "path",
            bypass_auth=True,
            headers={additional_header_key: additional_header})

        requestor_args = response["args"]
        for key, value in requestor_args:
            if key == "headers":
                headers = value
                assert additional_header_key in headers.keys()
                assert headers[additional_header_key] == additional_header
Beispiel #7
0
 def setup_moco(self):
     """create a moco instance where no requests will be fired against the api"""
     self._moco = moco.Moco(api_key="[HERE IS THE API KEY]",
                            domain="[DOMAIN]",
                            http=RawRequestor(),
                            objector=RawObjector())
Beispiel #8
0
    def test_wrapper_impersonate(self):
        impersonate_user_id = 123
        new_moco = moco.Moco()
        new_moco.impersonate(impersonate_user_id)

        assert new_moco._impersonation_user_id == impersonate_user_id
Beispiel #9
0
    def test_wrapper_init_requestor_overwrite(self):
        new_moco = moco.Moco(api_key="api_key", domain="domain", http=util.requestor.RawRequestor())
        assert new_moco.api_key == "api_key"
        assert new_moco.domain == "domain"

        assert isinstance(new_moco._requestor, util.requestor.RawRequestor)
Beispiel #10
0
    def test_wrapper_init(self):
        new_moco = moco.Moco(api_key="api_key", domain="domain")
        assert new_moco.api_key == "api_key"
        assert new_moco.domain == "domain"

        assert isinstance(new_moco._requestor, util.requestor.DefaultRequestor)
Beispiel #11
0
 def setup_moco(self):
     self._moco = moco.Moco(pytest.placeholders.mocotest_apikey,
                            pytest.placeholders.mocotest_domain,
                            http=NoRetryRequestor())