def test_fixture_setup(self): data = FixturesData() data.delete_test_users() data.delete_test_organizations() data.delete_test_projects() data.add_test_organizations() PolicyFactory.load_policies() # Just for test coverage... PolicyFactory.load_policies(update=True) create_attribute_types() load_tenure_relationship_types() data.add_test_users_and_roles() data.add_test_projects() data.add_test_spatial_units() assert User.objects.count() == 20 assert Policy.objects.count() == 7 assert Organization.objects.count() == 2 assert Project.objects.count() == 9 assert SpatialUnit.objects.count() == 7 assert SpatialRelationship.objects.count() == 2 data.delete_test_users() data.delete_test_organizations() data.delete_test_projects() assert User.objects.count() == 0 assert Organization.objects.count() == 0 assert Project.objects.count() == 0 assert SpatialUnit.objects.count() == 0 assert SpatialRelationship.objects.count() == 0
def setUp(self): super().setUp() PolicyFactory.load_policies() # Define 1 superuser and 9 other users users = [] users.append({"username": "******", "password": "******", "_is_superuser": True}) for uid in range(1, 10): users.append({"username": "******" + str(uid), "password": "******"}) self.test_data = {"users": users} self.superuser = users[0] # Define 2 orgs and their members self.test_data["orgs"] = [ { "name": "UNESCO", "description": ("United Nations Educational, Scientific, " + "and Cultural Organization"), "_members": (1, 2, 5, 6), "_admins": (1,), }, { "name": "UNICEF", "description": "United Nations Children's Emergency Fund", "_members": (3, 4, 5, 6), "_admins": (3,), }, ] load_test_data(self.test_data)
def setUp(self): super().setUp() PolicyFactory.load_policies() load_test_data(get_test_data()) UserFactory.create( username='******', password='******')
def setUp(self): super().setUp() PolicyFactory.load_policies() self.test_data = { 'users': [ { 'username': '******', 'password': '******', 'is_active': False, }, { 'username': '******', 'password': '******', 'is_active': True, }, { 'username': '******', 'password': '******', 'is_active': True, '_is_superuser': True, } ] } (self.inactive_user, self.active_user, self.superuser) = self.test_data['users'] load_test_data(self.test_data)
def test_fixture_setup(self): data = FixturesData() data.delete_test_users() data.delete_test_organizations() data.delete_test_projects() data.add_test_organizations() PolicyFactory.load_policies() # Just for test coverage... PolicyFactory.load_policies(force=True) create_attribute_types() load_tenure_relationship_types() data.add_test_users_and_roles() data.add_test_projects() data.add_test_spatial_units() data.add_huge_project() assert User.objects.count() == 20 assert Policy.objects.count() == 7 assert Organization.objects.count() == 2 assert Project.objects.count() == 9 assert SpatialUnit.objects.count() == 4007 assert SpatialRelationship.objects.count() == 2 data.delete_test_users() data.delete_test_organizations() data.delete_test_projects() assert User.objects.count() == 0 assert Organization.objects.count() == 0 assert Project.objects.count() == 0 assert SpatialUnit.objects.count() == 0 assert SpatialRelationship.objects.count() == 0
def test_load_force(self): PolicyFactory.load_policies() existing_pols = {p: Policy.objects.get(name=p) for p in policies} load.run(force=True) for pol in policies: assert Policy.objects.get(name=pol) != existing_pols[pol]
def setUp(self): super().setUp() PolicyFactory.load_policies() test_objs = load_test_data(get_test_data()) OrganizationRole.objects.create( organization=test_objs['organizations'][0], user=UserFactory.create(username='******', password='******'), admin=True)
def setUp(self): super().setUp() PolicyFactory.load_policies() test_objs = load_test_data(get_test_data()) OrganizationRole.objects.create( organization=test_objs['organizations'][0], user=UserFactory.create( username='******', password='******'), admin=True)
def setUp(self): super().setUp() PolicyFactory.load_policies() self.test_data = { 'users': [{ 'username': '******', 'password': '******', }] } load_test_data(self.test_data)
def setUp(self): super().setUp() PolicyFactory.load_policies() create_attribute_types() loadattrtypes.Command().handle(force=True) load_tenure_relationship_types(force=True) self.user = UserFactory.create() self.project = ProjectFactory.create(current_questionnaire='a1') self.questionnaire = QuestionnaireFactory.create(id_string='a1', version=0, project=self.project, id='a1') QuestionFactory.create(name='location_geometry', label='Location of Parcel', type='GS', questionnaire=self.questionnaire) content_type_party = ContentType.objects.get(app_label='party', model='party') content_type_spatial = ContentType.objects.get(app_label='spatial', model='spatialunit') content_type_tenure = ContentType.objects.get( app_label='party', model='tenurerelationship') for content_type in [ content_type_party, content_type_tenure, content_type_spatial ]: schema = Schema.objects.create( content_type=content_type, selectors=(self.project.organization.id, self.project.id, 'a1')) attr_type = AttributeType.objects.get(name='boolean') Attribute.objects.create(schema=schema, name='fname', long_name='True or False', attr_type=attr_type, index=0, required=False, omit=False) attr_type = AttributeType.objects.get(name='text') Attribute.objects.create(schema=schema, name='fname_two', long_name='Notes', attr_type=attr_type, index=1, required=False, omit=False) OrganizationRole.objects.create(user=self.user, organization=self.project.organization)
def setUp(self): super().setUp() PolicyFactory.load_policies() test_objs = load_test_data(get_test_data()) OrganizationRole.objects.create( organization=test_objs['organizations'][0], user=UserFactory.create(username='******', password='******'), admin=True) UserFactory.create(username='******', email='*****@*****.**', full_name="Han Solo", password='******')
def setUp(self): super().setUp() PolicyFactory.load_policies() create_attribute_types() loadattrtypes.Command().handle(force=True) load_tenure_relationship_types(force=True) self.user = UserFactory.create() self.project = ProjectFactory.create( current_questionnaire='a1') self.questionnaire = QuestionnaireFactory.create( id_string='a1', version=0, project=self.project, id='a1') QuestionFactory.create( name='location_geometry', label='Location of Parcel', type='GS', questionnaire=self.questionnaire) content_type_party = ContentType.objects.get( app_label='party', model='party') content_type_spatial = ContentType.objects.get( app_label='spatial', model='spatialunit') content_type_tenure = ContentType.objects.get( app_label='party', model='tenurerelationship') for content_type in [content_type_party, content_type_tenure, content_type_spatial]: schema = Schema.objects.create( content_type=content_type, selectors=(self.project.organization.id, self.project.id, 'a1') ) attr_type = AttributeType.objects.get(name='boolean') Attribute.objects.create( schema=schema, name='fname', long_name='True or False', attr_type=attr_type, index=0, required=False, omit=False ) attr_type = AttributeType.objects.get(name='text') Attribute.objects.create( schema=schema, name='fname_two', long_name='Notes', attr_type=attr_type, index=1, required=False, omit=False ) OrganizationRole.objects.create( user=self.user, organization=self.project.organization)
def setUp(self): super().setUp() PolicyFactory.load_policies() self.test_data = { 'users': [{ 'username': '******', 'password': '******', }, { 'username': '******', 'password': '******', '_is_superuser': True, }] } (self.user1, self.superuser) = self.test_data['users'] load_test_data(self.test_data)
def setUp(self): super().setUp() PolicyFactory.load_policies() test_objs = load_test_data(get_test_data()) OrganizationRole.objects.create( organization=test_objs['organizations'][0], user=UserFactory.create( username='******', password='******'), admin=True) UserFactory.create( username='******', email='*****@*****.**', full_name="Han Solo", password='******')
def setUp(self): super().setUp() PolicyFactory.load_policies() # Define 1 superuser and 9 other users users = [] users.append({ 'username': '******', 'password': '******', 'full_name': 'Super User', 'email': "*****@*****.**", 'is_active': True, '_is_superuser': True, }) for uid in range(1, 10): if uid < 5: last_login_val = ( datetime.now(tz=timezone.utc) - timedelta(days=uid) ) else: last_login_val = None users.append({ 'username': '******' + str(uid), 'password': '******', 'email': "default" + str(uid) + "@example.com", 'last_login': last_login_val, 'is_active': (uid % 2 == 1), }) self.test_data = { 'users': users, } self.superuser = users[0] # Define 2 orgs and their members self.test_data['orgs'] = [ { 'name': "Organization One", '_members': (1, 2, 3, 4), }, { 'name': "Organization Two", '_members': (3, 4, 5, 6), }, ] load_test_data(self.test_data)
def setUp(self): super().setUp() PolicyFactory.load_policies() # Define 1 superuser and 9 other users users = [] users.append({ 'username': '******', 'password': '******', 'email': "*****@*****.**", 'is_active': True, '_is_superuser': True, }) for uid in range(1, 10): if uid < 5: last_login_val = (datetime.now(tz=timezone.utc) - timedelta(days=uid)) else: last_login_val = None users.append({ 'username': '******' + str(uid), 'password': '******', 'email': "default" + str(uid) + "@example.com", 'last_login': last_login_val, 'is_active': (uid % 2 == 1), }) self.test_data = { 'users': users, } self.superuser = users[0] # Define 2 orgs and their members self.test_data['orgs'] = [ { 'name': "Organization One", '_members': (1, 2, 3, 4), }, { 'name': "Organization Two", '_members': (3, 4, 5, 6), }, ] load_test_data(self.test_data)
def setUp(self): super().setUp() PolicyFactory.load_policies() test_objs = load_test_data(get_test_data()) self.org = test_objs['organizations'][0] self.prj = test_objs['projects'][1] OrganizationRole.objects.create(organization=self.org, user=UserFactory.create( username='******', password='******'), admin=True) ResourceFactory.create_batch(2, content_object=self.prj, project=self.prj) su = SpatialUnitFactory(geometry=GEOSGeometry( '{"type": "Polygon",' '"coordinates": [[' '[-5.1031494140625000,' ' 8.1299292850467957], ' '[-5.0482177734375000, ' '7.6837733211111425], ' '[-4.6746826171875000, ' '7.8252894725496338], ' '[-4.8641967773437491, ' '8.2278005261522775], ' '[-5.1031494140625000, ' '8.1299292850467957]]]}'), project=self.prj, type='MI', attributes={}) ResourceFactory.create(content_object=su, project=self.prj) party = PartyFactory.create(project=test_objs['projects'][1]) tenure = TenureRelationshipFactory.create( project=self.prj, party=party, spatial_unit=su, tenure_type=TenureRelationshipType.objects.create( id='CR', label='Customary Rights')) ResourceFactory.create(content_object=su, project=self.prj) ResourceFactory.create(content_object=party, project=self.prj) ResourceFactory.create(content_object=tenure, project=self.prj)
def setUp(self): super().setUp() PolicyFactory.load_policies() # Define 1 superuser and 9 other users users = [] users.append({ 'username': '******', 'password': '******', '_is_superuser': True, }) for uid in range(1, 10): users.append({ 'username': '******' + str(uid), 'password': '******', }) self.test_data = {'users': users} self.superuser = users[0] # Define 2 orgs and their members self.test_data['orgs'] = [ { 'name': "UNESCO", 'description': ("United Nations Educational, Scientific, " + "and Cultural Organization"), '_members': (1, 2, 5, 6), '_admins': (1, ), }, { 'name': "UNICEF", 'description': "United Nations Children's Emergency Fund", '_members': (3, 4, 5, 6), '_admins': (3, ), }, ] load_test_data(self.test_data)
def setUp(self): super().setUp() PolicyFactory.load_policies() test_objs = load_test_data(get_test_data()) self.org = test_objs['organizations'][0] self.prj = test_objs['projects'][0]
def setUp(self): super().setUp() PolicyFactory.load_policies() # Load world boundary data geography.load.run(verbose=False) # Define 1 SU, 1 OA, 1 org member, and 1 unaffiliated user self.test_data = { 'superuser': { 'username': '******', 'password': '******', '_is_superuser': True, }, 'orgadmin': { 'username': '******', 'password': '******', }, 'orgmember': { 'username': '******', 'password': '******', }, 'unaffuser': { 'username': '******', 'password': '******', }, } self.test_data['users'] = [{ 'username': '******', 'password': '******', '_is_superuser': True, }, { 'username': '******', 'password': '******', }, { 'username': '******', 'password': '******', }, { 'username': '******', 'password': '******', }] (self.superuser, self.orgadmin, self.orgmember, self.unaffuser) = self.test_data['users'] # Define 2 orgs the OA is an admin of and 1 other org self.test_data['orgs'] = [ { 'name': "UNESCO", 'slug': 'unesco', 'description': ("United Nations Educational, Scientific, " + "and Cultural Organization"), 'logo': ('https://upload.wikimedia.org/wikipedia/commons/' + 'thumb/b/bc/UNESCO_logo.svg/320px-UNESCO_logo.svg.png'), '_members': (1, 2), '_admins': (1, ), }, { 'name': "UNICEF", 'slug': 'unicef', 'description': "United Nations Children's Emergency Fund", '_members': (1, ), '_admins': (1, ), }, { 'name': "UNOCHA", 'slug': 'unocha', 'description': ("United Nations " + "Office for the Coordination of Humanitarian Affairs"), '_members': [], '_admins': [], }, ] # Search terms to specify a country self.test_data['countries'] = { 'FR': "Paris, France", 'RU': "Moscow, Russia", 'AU': "Canberra, Australia", 'DE': "Berlin, Germany", } self.test_data['project_slug'] = 'post-sokovia-land-tenure-project' self.test_data['project_name'] = "Post-Sokovia Land Tenure Project" self.test_data['project_description'] = ( "This project aims to document land tenure in what is left of " + "Sokovia, which was destroyed during a conflict involving the " + "Avengers, a rogue vigilante group.") self.test_data['project_url'] = 'http://sokovia-accords.un.org/' load_test_data(self.test_data)
def setUp(self): super().setUp() PolicyFactory.load_policies() create_attribute_types()
def setUp(self): super().setUp() PolicyFactory.load_policies() self.test_data = get_test_data() load_test_data(self.test_data)
def setUp(self): super().setUp() PolicyFactory.load_policies() # Define 1 OA self.test_data = { 'users': [ { 'username': '******', 'password': '******', } ] } self.orgadmin = self.test_data['users'][0] # Define 2 orgs the OA is an admin of self.test_data['orgs'] = [ { 'name': "UNESCO", 'slug': 'unesco', 'description': ( "United Nations Educational, Scientific, " + "and Cultural Organization" ), 'logo': ( 'https://upload.wikimedia.org/wikipedia/commons/' + 'thumb/b/bc/UNESCO_logo.svg/320px-UNESCO_logo.svg.png' ), '_members': (0,), '_admins': (0,), }, { 'name': "UNICEF", 'slug': 'unicef', 'description': ( "United Nations Children's Emergency Fund" ), '_members': (), '_admins': (), }, ] # Define 2 projects that will be duplicated in separate orgs self.test_data['projects'] = [ { 'name': "Project Gutenberg", 'slug': 'project-gutenberg', 'description': "Public project of UNESCO.", 'country': 'PH', 'access': 'public', '_org': 0, '_managers': (0,), }, { 'name': "Wikipedia", 'slug': 'wikipedia', 'description': "Public project of UNICEF.", 'country': 'AU', 'access': 'public', '_org': 1, '_managers': (), }, ] load_test_data(self.test_data)
def setUp(self): super().setUp() PolicyFactory.load_policies() create_attribute_types() load_tenure_relationship_types(force=True)
def setUp(self): super().setUp() PolicyFactory.load_policies() # Load world boundary data geography.load.run(verbose=False) # Define 1 SU, 1 OA, 1 org member, and 1 unaffiliated user self.test_data = { "superuser": {"username": "******", "password": "******", "_is_superuser": True}, "orgadmin": {"username": "******", "password": "******"}, "orgmember": {"username": "******", "password": "******"}, "unaffuser": {"username": "******", "password": "******"}, } self.test_data["users"] = [ {"username": "******", "password": "******", "_is_superuser": True}, {"username": "******", "password": "******"}, {"username": "******", "password": "******"}, {"username": "******", "password": "******"}, ] (self.superuser, self.orgadmin, self.orgmember, self.unaffuser) = self.test_data["users"] # Define 2 orgs the OA is an admin of and 1 other org self.test_data["orgs"] = [ { "name": "UNESCO", "slug": "unesco", "description": ("United Nations Educational, Scientific, " + "and Cultural Organization"), "logo": ( "https://upload.wikimedia.org/wikipedia/commons/" + "thumb/b/bc/UNESCO_logo.svg/320px-UNESCO_logo.svg.png" ), "_members": (1, 2), "_admins": (1,), }, { "name": "UNICEF", "slug": "unicef", "description": "United Nations Children's Emergency Fund", "_members": (1,), "_admins": (1,), }, { "name": "UNOCHA", "slug": "unocha", "description": ("United Nations " + "Office for the Coordination of Humanitarian Affairs"), "_members": [], "_admins": [], }, ] # Search terms to specify a country self.test_data["countries"] = { "FR": "Paris, France", "RU": "Moscow, Russia", "AU": "Canberra, Australia", "DE": "Berlin, Germany", } self.test_data["project_slug"] = "post-sokovia-land-tenure-project" self.test_data["project_name"] = "Post-Sokovia Land Tenure Project" self.test_data["project_description"] = ( "This project aims to document land tenure in what is left of " + "Sokovia, which was destroyed during a conflict involving the " + "Avengers, a rogue vigilante group." ) self.test_data["project_url"] = "http://sokovia-accords.un.org/" load_test_data(self.test_data)