def test_registration_id_exists(self):
        with patch.object(Interactions, "query", return_value=True) as query_method:

            self.assertTrue(registration_id_exists("123"))

            query_method.assert_called_with(DEFAULT_REGISTRATIONS_TABLE, filters={"id": "123"})

        with patch.object(Interactions, "query", return_value=False) as query_method:

            self.assertFalse(registration_id_exists("321"))

            query_method.assert_called_with(DEFAULT_REGISTRATIONS_TABLE, filters={"id": "321"})
    def test_registration_id_exists(self):
        with patch.object(Interactions, 'query', return_value=True) as \
                query_method:

            self.assertTrue(registration_id_exists('123'))

            query_method.assert_called_with(
                DEFAULT_REGISTRATIONS_TABLE,
                filters={'id': '123'}
            )

        with patch.object(Interactions, 'query', return_value=False) as \
                query_method:

            self.assertFalse(registration_id_exists('321'))

            query_method.assert_called_with(
                DEFAULT_REGISTRATIONS_TABLE,
                filters={'id': '321'}
            )
Esempio n. 3
0
    def post(self, subscription_id):
        """
        Creates new subscription
        """
        # subscription_id is actually the registration_id
        registration_id = subscription_id

        account_id = lookup_account_id(request.headers['username'])

        if not registration_id_exists(registration_id):
            return make_response(
                jsonify({'Error': 'The registration id does not exist'}),
                client.NOT_FOUND)

        return insert(DEFAULT_SUBSCRIPTIONS_TABLE,
                      **{'account_id': account_id,
                         'registration_id': registration_id})
Esempio n. 4
0
    def post(self, subscription_id):
        """
        Creates new subscription
        """
        # subscription_id is actually the registration_id
        registration_id = subscription_id

        account_id = lookup_account_id(request.headers['username'])

        if not registration_id_exists(registration_id):
            return make_response(
                jsonify({'Error': 'The registration id does not exist'}),
                client.NOT_FOUND)

        return insert(
            DEFAULT_SUBSCRIPTIONS_TABLE, **{
                'account_id': account_id,
                'registration_id': registration_id
            })