def test_get_form_counts_by_user_xmlns(self): user1, user2 = 'u1', 'u2' app1, app2 = '123', '567' xmlns1, xmlns2 = 'abc', 'efg' start = datetime(2013, 7, 1) end = datetime(2013, 7, 30) received_on = datetime(2013, 7, 15, 0, 0, 0) received_on_out = datetime(2013, 6, 15, 0, 0, 0) self._send_form_to_es(received_on=received_on_out, completion_time=received_on, user_id=user1, app_id=app1, xmlns=xmlns1) self._send_form_to_es(received_on=received_on, user_id=user1, app_id=app1, xmlns=xmlns1) self._send_form_to_es(received_on=received_on, user_id=user1, app_id=app1, xmlns=xmlns1) self._send_form_to_es(received_on=received_on, user_id=user1, app_id=app2, xmlns=xmlns2) self._send_form_to_es(received_on=received_on, user_id=user2, app_id=app2, xmlns=xmlns2) self._send_form_to_es(received_on=received_on, user_id=None, app_id=app2, xmlns=xmlns2) counts = get_form_counts_by_user_xmlns(self.domain, start, end) self.assertEqual(counts, { (user1, app1, xmlns1): 2, (user1, app2, xmlns2): 1, (user2, app2, xmlns2): 1, }) counts_user1 = get_form_counts_by_user_xmlns(self.domain, start, end, user_ids=[user1]) self.assertEqual(counts_user1, { (user1, app1, xmlns1): 2, (user1, app2, xmlns2): 1, }) counts_xmlns2 = get_form_counts_by_user_xmlns(self.domain, start, end, xmlnss=[xmlns2]) self.assertEqual(counts_xmlns2, { (user1, app2, xmlns2): 1, (user2, app2, xmlns2): 1, }) by_completion = get_form_counts_by_user_xmlns(self.domain, start, end, by_submission_time=False) self.assertEqual(by_completion, { (user1, app1, xmlns1): 1 }) counts_missing_user = get_form_counts_by_user_xmlns(self.domain, start, end, user_ids=[None]) self.assertEqual(counts_missing_user, { (None, app2, xmlns2): 1, })
def test_get_form_counts_by_user_xmlns(self): user1, user2 = 'u1', 'u2' app1, app2 = '123', '567' xmlns1, xmlns2 = 'abc', 'efg' start = datetime(2013, 7, 1) end = datetime(2013, 7, 30) received_on = datetime(2013, 7, 15, 0, 0, 0) received_on_out = datetime(2013, 6, 15, 0, 0, 0) self._send_form_to_es(received_on=received_on_out, completion_time=received_on, user_id=user1, app_id=app1, xmlns=xmlns1) self._send_form_to_es(received_on=received_on, user_id=user1, app_id=app1, xmlns=xmlns1) self._send_form_to_es(received_on=received_on, user_id=user1, app_id=app1, xmlns=xmlns1) self._send_form_to_es(received_on=received_on, user_id=user1, app_id=app2, xmlns=xmlns2) self._send_form_to_es(received_on=received_on, user_id=user2, app_id=app2, xmlns=xmlns2) self._send_form_to_es(received_on=received_on, user_id=None, app_id=app2, xmlns=xmlns2) counts = get_form_counts_by_user_xmlns(self.domain, start, end) self.assertEqual(counts, { (user1, app1, xmlns1): 2, (user1, app2, xmlns2): 1, (user2, app2, xmlns2): 1, }) counts_user1 = get_form_counts_by_user_xmlns(self.domain, start, end, user_ids=[user1]) self.assertEqual(counts_user1, { (user1, app1, xmlns1): 2, (user1, app2, xmlns2): 1, }) counts_xmlns2 = get_form_counts_by_user_xmlns(self.domain, start, end, xmlnss=[xmlns2]) self.assertEqual(counts_xmlns2, { (user1, app2, xmlns2): 1, (user2, app2, xmlns2): 1, }) by_completion = get_form_counts_by_user_xmlns(self.domain, start, end, by_submission_time=False) self.assertEqual(by_completion, { (user1, app1, xmlns1): 1 }) counts_missing_user = get_form_counts_by_user_xmlns(self.domain, start, end, user_ids=[None]) self.assertEqual(counts_missing_user, { (None, app2, xmlns2): 1, })
def test_xmlns_case_sensitivity_for_get_form_counts_by_user_xmlns(self): user = '******' app = '123' # the important part of this test is an xmlns identifier with both lower and uppercase characters xmlns = 'LmN' start = datetime(2013, 7, 1) end = datetime(2013, 7, 30) received_on = datetime(2013, 7, 15, 0, 0, 0) self._send_form_to_es(received_on=received_on, user_id=user, app_id=app, xmlns=xmlns) check_case_sensitivity = get_form_counts_by_user_xmlns(self.domain, start, end, user_ids=[user], xmlnss=[xmlns]) self.assertEqual(check_case_sensitivity, { (user, app, xmlns): 1, })