<commit_before># -*- coding: utf8 -*-

import mock
import nose
import requests

import aliyunauth


class TestCms(object):
    CORRECT_URL = (
        "http://cms.example.com/"
        "?AccessKeyId=access-key"
        "&Action=Test"
        "&Foo=bar"
        "&Format=json"
        "&Signature=4SDI5sAk3SXCP5Vp3dkzBuT1xtQ%3D"
        "&SignatureMethod=HMAC-SHA1"
        "&SignatureNonce=mock-nonce"
        "&SignatureVersion=1.0"
        "&Timestamp=mock-date"
        "&Version=2015-04-20"
    )

    def setup(self):
        req_obj = requests.Request(
            "GET",
            "http://cms.example.com/",
            params={"Action": "Test", "Foo": "bar"},
            auth=aliyunauth.CmsAuth("access-key", "secret-key", "xml")
        )
        self.req = req_obj

    def test_attrs(self):
        nose.tools.eq_(aliyunauth.CmsAuth.VERSION, "2015-04-20")
        nose.tools.eq_(aliyunauth.CmsAuth.SERVICE, "smb")

    @mock.patch("time.strftime")
    @mock.patch("uuid.uuid4")
    def test_auth(self, mock_uuid, mock_time):
        fake_uuid = mock.MagicMock()
        fake_uuid.hex = "mock-nonce"
        mock_uuid.return_value = fake_uuid
        mock_time.return_value = "mock-date"
<commit_msg>fix test case<commit_after># -*- coding: utf8 -*-

import mock
import nose
import requests

import aliyunauth


class TestCms(object):
    CORRECT_URL = (
        "http://cms.example.com/"
        "?AccessKeyId=access-key"
        "&Action=Test"
        "&Foo=bar"
        "&Format=json"
        "&Signature=4SDI5sAk3SXCP5Vp3dkzBuT1xtQ%3D"
        "&SignatureMethod=HMAC-SHA1"
        "&SignatureNonce=mock-nonce"
        "&SignatureVersion=1.0"
        "&Timestamp=mock-date"
        "&Version=2015-04-20"
    )

    def setup(self):
        req_obj = requests.Request(
            "GET",
            "http://cms.example.com/",
            params={"Action": "Test", "Foo": "bar"},
            auth=aliyunauth.CmsAuth("access-key", "secret-key", "xml")
        )
        self.req = req_obj

    def test_attrs(self):
        nose.tools.eq_(aliyunauth.CmsAuth.VERSION, "2015-04-20")
        nose.tools.eq_(aliyunauth.CmsAuth.SERVICE, "cms")

    @mock.patch("time.strftime")
    @mock.patch("uuid.uuid4")
    def test_auth(self, mock_uuid, mock_time):
        fake_uuid = mock.MagicMock()
        fake_uuid.hex = "mock-nonce"
        mock_uuid.return_value = fake_uuid
        mock_time.return_value = "mock-date"

{'fraction_non_alphanumeric': 0.14921681780708987, 'fraction_numerical': 0.023083264633140973, 'mean_word_length': 2.3475862068965516, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3052419', 'n_tokens_mistral': 905, 'n_tokens_neox': 859, 'n_words': 122}