def setUp(self): TestBase.setUp(self) self._publish_transportation_form_and_submit_instance() self.url = reverse(charts, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form() s = 'transport_2011-07-25_19-05-49' self._make_submission(os.path.join( self.this_directory, 'fixtures', 'transportation', 'instances', s, s + '.xml')) self.submission = self.xform.instances.reverse()[0] self.url = reverse(map_view, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string}) self.perm_url = reverse(set_perm, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string}) self.edit_url = reverse(edit, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.show_url = reverse(show, kwargs={'uuid': self.xform.uuid}) self.show_normal_url = reverse(show, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.api_url = reverse(api, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def setUp(self): self.attachment_count = 0 TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form() self._submit_transport_instance_w_attachment() self.url = reverse(attachment_url, kwargs={"size": "original"})
def setUp(self): self.attachment_count = 0 TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form() self._submit_transport_instance_w_attachment() self.url = reverse('attachment_url', kwargs={'size': 'original'})
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form() s = 'transport_2011-07-25_19-05-49' self._make_submission( os.path.join(self.this_directory, 'fixtures', 'transportation', 'instances', s, s + '.xml')) self.submission = self.xform.instances.reverse()[0] self.url = reverse(map_view, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.perm_url = reverse(set_perm, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.edit_url = reverse(edit, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.show_url = reverse(show, kwargs={'uuid': self.xform.uuid}) self.show_normal_url = reverse(show, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.api_url = reverse(api, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def setUp(self): TestBase.setUp(self) xls_file_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), "../fixtures/tutorial/tutorial.xls" ) self._publish_xls_file_and_set_xform(xls_file_path)
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form_and_submit_instance() self.public_api_url = reverse(public_api, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form_and_submit_instance() self.edit_url = reverse(edit, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form() self.url = reverse(show, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def setUp(self): TestBase.setUp(self) self._create_user_and_login(username='******', password='******') self._publish_transportation_form() self.api_url = reverse(views.api, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self._logout()
def _publish_transportation_id_string_starts_with_number_form(self): xls_path = os.path.join(self.this_directory, "fixtures", "transportation", "transportation.id_starts_with_num.xls") count = XForm.objects.count() TestBase._publish_xls_file(self, xls_path) self.assertEqual(XForm.objects.count(), count + 1) self.xform = XForm.objects.all().reverse()[0]
def setUp(self): TestBase.setUp(self) self._create_user_and_login(username='******', password='******') self._publish_transportation_form() self.api_url = reverse('data-list', kwargs={ 'pk': self.xform.pk, 'format': 'json' }) self._logout()
def test_uuid_injection_in_cascading_select(self): """ Uuid is injected in the right instance for forms with cascading select """ pre_count = XForm.objects.count() xls_path = os.path.join(self.this_directory, "fixtures", "cascading_selects", "new_cascading_select.xls") file_name, file_ext = os.path.splitext(os.path.split(xls_path)[1]) TestBase._publish_xls_file(self, xls_path) post_count = XForm.objects.count() self.assertEqual(post_count, pre_count + 1) xform = XForm.objects.latest('date_created') # check that the uuid is within the main instance/ # the one without an id attribute xml = clean_and_parse_xml(xform.xml) # check for instance nodes that are direct children of the model node model_node = xml.getElementsByTagName("model")[0] instance_nodes = [ node for node in model_node.childNodes if node.nodeType == Node.ELEMENT_NODE and node.tagName.lower() == "instance" and not node.hasAttribute("id") ] self.assertEqual(len(instance_nodes), 1) instance_node = instance_nodes[0] # get the first element whose id attribute is equal to our form's # id_string form_nodes = [ node for node in instance_node.childNodes if node.nodeType == Node.ELEMENT_NODE and node.getAttribute("id") == xform.id_string ] form_node = form_nodes[0] # find the formhub node that has a uuid child node formhub_nodes = form_node.getElementsByTagName("formhub") self.assertEqual(len(formhub_nodes), 1) uuid_nodes = formhub_nodes[0].getElementsByTagName("uuid") self.assertEqual(len(uuid_nodes), 1) # check for the calculate bind calculate_bind_nodes = [ node for node in model_node.childNodes if node.nodeType == Node.ELEMENT_NODE and node.tagName == "bind" and node.getAttribute("nodeset") == "/%s/formhub/uuid" % file_name ] self.assertEqual(len(calculate_bind_nodes), 1) calculate_bind_node = calculate_bind_nodes[0] self.assertEqual(calculate_bind_node.getAttribute("calculate"), "'%s'" % xform.uuid)
def setUp(self): TestBase.setUp(self) self._publish_transportation_form() # self.csv_filepath = os.path.join( os.path.dirname(os.path.abspath(__file__)), "fixtures", "test_update_xform_uuids.csv") # get the last defined uuid with open(self.csv_filepath, "r") as f: lines = csv.reader(f) for line in lines: self.new_uuid = line[2]
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form_and_submit_instance() self.delete_url = reverse(delete_data, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.data_args = { 'xform': self.xform, 'query': "{}", 'limit': 1, 'sort': '-pk', 'fields': '["_id","_uuid"]'}
def setUp(self): TestBase.setUp(self) self._publish_transportation_form() # self.csv_filepath = os.path.join( os.path.dirname(os.path.abspath(__file__)), "fixtures", "test_update_xform_uuids.csv" ) # get the last defined uuid with open(self.csv_filepath, "r") as f: lines = csv.reader(f) for line in lines: self.new_uuid = line[2]
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form_and_submit_instance() self.perm_url = reverse(set_perm, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string }) self.show_url = reverse(show, kwargs={'uuid': self.xform.uuid}) self.url = reverse(enter_data, kwargs={ 'username': self.user.username, 'id_string': self.xform.id_string })
def _publish_file(self, xls_path, strict=True): """ Return False if not strict and publish fails """ pre_count = XForm.objects.count() TestBase._publish_xls_file(self, xls_path) # make sure publishing the survey worked if XForm.objects.count() != pre_count + 1: print('\nPublish Failure for file: %s' % xls_path) if strict: self.assertEqual(XForm.objects.count(), pre_count + 1) else: return False self.xform = list(XForm.objects.all())[-1] return True
def setUp(self): TestBase.setUp(self) self.instances = settings.MONGO_DB.instances self.instances.delete_many({}) self.assertEqual(self.instances.count_documents({}), 0) xls_path = os.path.join(self.this_directory, 'fixtures', 'transportation', 'mongo', 'transportation_with_dirty_mongo_ids.xls') count = XForm.objects.count() self._publish_xls_file(xls_path) self.assertEqual(XForm.objects.count(), count + 1) self.xform = XForm.objects.all().reverse()[0] self._make_submission( os.path.join(self.this_directory, 'fixtures', 'transportation', 'mongo', 'transport_2011-07-25_19-05-36' + '.xml')) self.pi = self.xform.instances.all()[0].parsed_instance
def setUp(self): TestBase.setUp(self) self.instances = settings.MONGO_DB.instances self.instances.remove() self.assertEquals(list(self.instances.find()), []) xls_path = os.path.join(self.this_directory, 'fixtures', 'transportation', 'mongo', 'transportation_with_dirty_mongo_ids.xls') count = XForm.objects.count() self._publish_xls_file(xls_path) self.assertEqual(XForm.objects.count(), count + 1) self.xform = XForm.objects.all().reverse()[0] self._make_submission(os.path.join( self.this_directory, 'fixtures', 'transportation', 'mongo', 'transport_2011-07-25_19-05-36' + '.xml')) self.pi = self.xform.instances.all()[0].parsed_instance
def setUp(self): TestBase.setUp(self) self._publish_transportation_form() self._submit_transport_instance_w_attachment() src = os.path.join(self.this_directory, "fixtures", "transportation", "screenshot.png") uf = UploadedFile(file=open(src, 'rb'), content_type='image/png') count = MetaData.objects.count() MetaData.media_upload(self.xform, uf) self.assertEqual(MetaData.objects.count(), count + 1) url = urljoin( self.base_url, reverse(profile, kwargs={'username': self.user.username})) self._logout() self._create_user_and_login('deno', 'deno') self.bc = BriefcaseClient(username='******', password='******', url=url, user=self.user)
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form_and_submit_instance() self.perm_url = reverse( set_perm, kwargs={ "username": self.user.username, "id_string": self.xform.id_string, }, ) self.show_url = reverse(show, kwargs={"uuid": self.xform.uuid}) self.url = reverse( enter_data, kwargs={ "username": self.user.username, "id_string": self.xform.id_string, }, )
def setUp(self): TestBase.setUp(self) self._publish_transportation_form() self._submit_transport_instance_w_attachment() src = os.path.join(self.this_directory, "fixtures", "transportation", "screenshot.png") uf = UploadedFile(file=open(src), content_type='image/png') count = MetaData.objects.count() MetaData.media_upload(self.xform, uf) self.assertEqual(MetaData.objects.count(), count + 1) url = urljoin( self.base_url, reverse(profile, kwargs={'username': self.user.username}) ) self._logout() self._create_user_and_login('deno', 'deno') self.bc = BriefcaseClient( username='******', password='******', url=url, user=self.user )
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self.extra = {'HTTP_AUTHORIZATION': 'Token %s' % self.user.auth_token} self.xls_file_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), "../fixtures/tutorial/tutorial.xls") self._publish_transportation_form_and_submit_instance() self.project = Project.objects.create(name="Test Project", organization=self.user, created_by=self.user) self.xform.project = self.project self.xform.save() self.instance = self.xform.instances.first() self._add_external_export_metadata(self.instance) self.view = MetaDataViewSet.as_view({'get': 'list'}) ContentType.objects.get_or_create(app_label="logger", model="instance")
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self.extra = {'HTTP_AUTHORIZATION': 'Token %s' % self.user.auth_token} self.xls_file_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), "../fixtures/tutorial/tutorial.xls" ) self._publish_transportation_form_and_submit_instance() self.project = Project.objects.create(name="Test Project", organization=self.user, created_by=self.user) self.xform.project = self.project self.xform.save() self.instance = self.xform.instances.first() self._add_external_export_metadata(self.instance) self.view = MetaDataViewSet.as_view({'get': 'list'}) ContentType.objects.get_or_create(app_label="logger", model="instance")
def setUp(self): TestBase.setUp(self) self._publish_xls_file( os.path.join( settings.PROJECT_ROOT, "apps", "logger", "fixtures", "test_forms", "tutorial.xls"))
def _publish_survey(self): self.this_directory = os.path.dirname(__file__) xls_path = self._fixture_path("gps", "gps.xls") TestBase._publish_xls_file(self, xls_path)
def setUp(self): TestBase.setUp(self)
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form() self.url = reverse(clone_xlsform, kwargs={'username': self.user.username})
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self.factory = RequestFactory() self.extra = { 'HTTP_AUTHORIZATION': 'Token %s' % self.user.auth_token}
def setUp(self): TestBase.setUp(self) self._publish_xls_file( os.path.join(settings.PROJECT_ROOT, "apps", "logger", "fixtures", "test_forms", "tutorial.xls"))
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form_and_submit_instance()
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self._publish_transportation_form()
def setUp(self): TestBase.setUp(self) self._create_user_and_login() self.factory = RequestFactory() self.extra = {'HTTP_AUTHORIZATION': 'Token %s' % self.user.auth_token}
def setUp(self): TestBase.setUp(self) self.settings_url = reverse( profile_settings, kwargs={'username': self.user.username})