예제 #1
0
 def test_match_mock_by_parameters(self):
     #         test("находит наиболее подходящий по количеству параметров запрос", () => {
     configs = [{
         "service": "mobileapi",
         "command": "foo/bar",
         "params": {
             "a": 1,
             "b": "2"
         },
         "response": "baz",
         "method": "GET",
         "status": 200
     }, {
         "service": "mobileapi",
         "command": "foo/bar",
         "params": {
             "a": 1,
             "b": "2",
             "c": False
         },
         "response": "bar",
         "method": "GET",
         "status": 200
     }]
     #
     self.assertEqual(
         get_matched_config("mobileapi", "GET", "foo/bar", {
             "a": 1,
             "b": "2",
             "c": False,
             "d": "tttt"
         }, configs), {
             "response": "bar",
             "status": 200
         })
예제 #2
0
    def test_format_url_by_standard(self):
        configs = [{
            "service": "mobileapi",
            "command": "foo/bar/",
            "params": {
                "a": 1,
                "b": "2",
                "c": False
            },
            "response": "bar",
            "method": "GET",
            "status": 200
        }, {
            "service": "mobileapi",
            "command": "foo/baz",
            "params": {
                "a": 1,
                "b": "2",
                "c": False
            },
            "response": "baz",
            "method": "GET",
            "status": 200
        }]

        self.assertEqual(
            get_matched_config("mobileapi", "GET", "foo/bar", {
                "a": 1,
                "b": "2",
                "c": False
            }, configs), {
                "response": "bar",
                "status": 200
            })
예제 #3
0
    def test_mock_without_url_params(self):
        configs = [{
            "service": "mobileapi",
            "command": "foo/bar",
            "params": {
                "a": 1,
                "b": "2",
                "c": False
            },
            "response": "bar",
            "method": "GET",
            "status": 200
        }, {
            "service": "mobileapi",
            "command": "foo/baz",
            "params": {
                "a": 1,
                "b": "2",
                "c": False
            },
            "response": "baz",
            "method": "GET",
            "status": 200
        }]

        self.assertIsNone(
            get_matched_config("mobileapi", "GET", "foo/bar", {}, configs))
예제 #4
0
    def test_mock_with_params(self):
        #         test("ищет совпадения по url при совпадении параметров", () => {
        configs = [{
            "service": "mobileapi",
            "command": "foo/bar",
            "params": {
                "a": 1,
                "b": "2",
                "c": False
            },
            "response": "bar",
            "method": "GET",
            "status": 200
        }, {
            "service": "mobileapi",
            "command": "foo/baz",
            "params": {
                "a": 1,
                "b": "2",
                "c": False
            },
            "response": "baz",
            "method": "GET",
            "status": 200
        }]

        self.assertEqual(
            get_matched_config("mobileapi", "GET", "foo/bar", {
                "a": 1,
                "b": "2",
                "c": False
            }, configs), {
                "response": "bar",
                "status": 200
            })
예제 #5
0
    def test_mock_without_url_params_and_matched_config_3(self):
        configs = [{
            "service": "mobileapi",
            "command": "foo/bar",
            "params": {},
            "response": "win",
            "method": "GET",
            "status": 200
        }, {
            "service": "mobileapi",
            "command": "foo/bar",
            "params": {
                "a": 1,
                "b": "2",
                "c": False
            },
            "response": "lose",
            "method": "GET",
            "status": 200
        }, {
            "service": "mobileapi",
            "command": "foo/baz",
            "params": {
                "a": 1,
                "b": "2",
                "c": False
            },
            "response": "baz",
            "method": "GET",
            "status": 200
        }]

        self.assertEqual(
            get_matched_config("mobileapi", "GET", "foo/bar", {"a": 4},
                               configs), {
                                   "response": "lose",
                                   "status": 200
                               })