Example #1
0
    def test_get_form_ids_having_multimedia_with_user_types(self):
        start = datetime(2013, 7, 1)
        end = datetime(2013, 7, 30)
        xmlns = 'http://a.b.org'
        app_id = '1234'
        user_id = 'abc'

        with patch('corehq.pillows.xform.get_user_type', lambda _: MOBILE_USER_TYPE):
            self._send_form_to_es(
                app_id=app_id,
                xmlns=xmlns,
                received_on=datetime(2013, 7, 2),
                user_id=user_id,
                attachment_dict={
                    'my_image': {'content_type': 'image/jpg'}
                }
            )

        with patch('corehq.pillows.xform.get_user_type', lambda _: WEB_USER_TYPE):
            self._send_form_to_es(
                app_id=app_id,
                xmlns=xmlns,
                received_on=datetime(2013, 7, 2),
                user_id=user_id,
                attachment_dict={
                    'my_image': {'content_type': 'image/jpg'}
                }
            )

        form_ids = get_form_ids_having_multimedia(
            self.domain,
            app_id,
            xmlns,
            start,
            end,
            user_types=[MOBILE_USER_TYPE]
        )
        self.assertEqual(len(form_ids), 1)

        form_ids = get_form_ids_having_multimedia(
            self.domain,
            app_id,
            xmlns,
            start,
            end,
            user_types=[MOBILE_USER_TYPE, WEB_USER_TYPE]
        )
        self.assertEqual(len(form_ids), 2)

        form_ids = get_form_ids_having_multimedia(
            self.domain,
            app_id,
            xmlns,
            start,
            end,
            user_types=[]
        )
        self.assertEqual(len(form_ids), 2)
Example #2
0
    def test_get_form_ids_having_multimedia_with_user_types(self):
        start = datetime(2013, 7, 1)
        end = datetime(2013, 7, 30)
        xmlns = 'http://a.b.org'
        app_id = '1234'
        user_id = 'abc'

        with patch('corehq.pillows.xform.get_user_type', lambda _: MOBILE_USER_TYPE):
            self._send_form_to_es(
                app_id=app_id,
                xmlns=xmlns,
                received_on=datetime(2013, 7, 2),
                user_id=user_id,
                attachment_dict={
                    'my_image': {'content_type': 'image/jpg'}
                }
            )

        with patch('corehq.pillows.xform.get_user_type', lambda _: WEB_USER_TYPE):
            self._send_form_to_es(
                app_id=app_id,
                xmlns=xmlns,
                received_on=datetime(2013, 7, 2),
                user_id=user_id,
                attachment_dict={
                    'my_image': {'content_type': 'image/jpg'}
                }
            )

        form_ids = get_form_ids_having_multimedia(
            self.domain,
            app_id,
            xmlns,
            DateSpan(start, end),
            [MOBILE_USER_TYPE]
        )
        self.assertEqual(len(form_ids), 1)

        form_ids = get_form_ids_having_multimedia(
            self.domain,
            app_id,
            xmlns,
            DateSpan(start, end),
            [MOBILE_USER_TYPE, WEB_USER_TYPE]
        )
        self.assertEqual(len(form_ids), 2)

        form_ids = get_form_ids_having_multimedia(
            self.domain,
            app_id,
            xmlns,
            DateSpan(start, end),
            []
        )
        self.assertEqual(len(form_ids), 2)
    def test_get_form_ids_having_multimedia(self):
        start = datetime(2013, 7, 1)
        end = datetime(2013, 7, 30)
        xmlns = 'http://a.b.org'
        app_id = '1234'
        user_id = 'abc'

        self._send_form_to_es(
            app_id=app_id,
            xmlns=xmlns,
            received_on=datetime(2013, 7, 2),
            user_id=user_id,
            attachment_dict={'my_image': {
                'content_type': 'image/jpg'
            }})

        # Decoy form
        self._send_form_to_es(
            app_id=app_id,
            xmlns=xmlns,
            received_on=datetime(2013, 7, 2),
            user_id=user_id,
        )

        form_ids = get_form_ids_having_multimedia(
            self.domain,
            app_id,
            xmlns,
            DateSpan(start, end),
            [],
        )
        self.assertEqual(len(form_ids), 1)
Example #4
0
    def test_get_form_ids_having_multimedia(self):
        start = datetime(2013, 7, 1)
        end = datetime(2013, 7, 30)
        xmlns = 'http://a.b.org'
        app_id = '1234'
        user_id = 'abc'

        self._send_form_to_es(
            app_id=app_id,
            xmlns=xmlns,
            received_on=datetime(2013, 7, 2),
            user_id=user_id,
            attachment_dict={
                'my_image': {'content_type': 'image/jpg'}
            }
        )

        # Decoy form
        self._send_form_to_es(
            app_id=app_id,
            xmlns=xmlns,
            received_on=datetime(2013, 7, 2),
            user_id=user_id,
        )

        form_ids = get_form_ids_having_multimedia(
            self.domain,
            app_id,
            xmlns,
            start,
            end
        )
        self.assertEqual(len(form_ids), 1)
Example #5
0
    def test_get_form_ids_having_multimedia_with_group(self):
        start = datetime(2013, 7, 1)
        end = datetime(2013, 7, 30)
        xmlns = 'http://a.b.org'
        app_id = '1234'
        user_id = 'escobar'

        self._send_group_to_es(
            _id='medellin',
            users=['escobar'],
        )

        self._send_form_to_es(
            app_id=app_id,
            xmlns=xmlns,
            received_on=datetime(2013, 7, 2),
            user_id=user_id,
            attachment_dict={
                'my_image': {'content_type': 'image/jpg'}
            }
        )
        self._send_form_to_es(
            app_id=app_id,
            xmlns=xmlns,
            received_on=datetime(2013, 7, 2),
            user_id='murphy',
            attachment_dict={
                'my_image': {'content_type': 'image/jpg'}
            }
        )

        form_ids = get_form_ids_having_multimedia(
            self.domain,
            app_id,
            xmlns,
            start,
            end,
            group='medellin',
        )
        self.assertEqual(len(form_ids), 1)
Example #6
0
    def test_get_form_ids_having_multimedia_with_group(self):
        start = datetime(2013, 7, 1)
        end = datetime(2013, 7, 30)
        xmlns = 'http://a.b.org'
        app_id = '1234'
        user_id = 'escobar'

        self._send_group_to_es(
            _id='medellin',
            users=['escobar'],
        )

        self._send_form_to_es(
            app_id=app_id,
            xmlns=xmlns,
            received_on=datetime(2013, 7, 2),
            user_id=user_id,
            attachment_dict={'my_image': {
                'content_type': 'image/jpg'
            }})
        self._send_form_to_es(
            app_id=app_id,
            xmlns=xmlns,
            received_on=datetime(2013, 7, 2),
            user_id='murphy',
            attachment_dict={'my_image': {
                'content_type': 'image/jpg'
            }})

        form_ids = get_form_ids_having_multimedia(
            self.domain,
            app_id,
            xmlns,
            start,
            end,
            group='medellin',
        )
        self.assertEqual(len(form_ids), 1)