Exemple #1
0
    def test_secret_errors_nosettingssecret(self):
        with app.test_request_context(testing_route):
            response = self.app.post(testing_route,
                                     query_string=dict(secret='any secret'))
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response.data, 'OK called')

            response = self.app.post(testing_route)
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response.data, 'OK called')
Exemple #2
0
    def test_common_view_decorator(self):
        d = {'data': 'data'}

        def create_func(data, settings):
            return d, 123

        with app.test_request_context(data='{}'), patch(
                'python.ynab_client.init') as ynab_client_patch:
            body, code = common_view(create_func)
            self.assertEqual(code, 123)
            self.assertEqual(json.loads(body.data), d)
            self.assertTrue(ynab_client_patch.called)
            self.assertEqual(1, ynab_client_patch.call_count)
Exemple #3
0
 def test_secret_calls_ifvalidsecret(self):
     with app.test_request_context(testing_route):
         response = self.app.post(testing_route,
                                  query_string=dict(secret='dummy secret'))
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.data, 'OK called')
Exemple #4
0
 def test_secret_errors_ifwrongsecret(self):
     with app.test_request_context(testing_route):
         response = self.app.post(testing_route,
                                  query_string=dict(secret='wrong secret'))
         self.assertEqual(response.status_code, 403)