示例#1
0
 def setUp(self):
     schema = create_default_schema()
     self.users = create_sample_users()
     self.client = client_for_testing(schema, self.users[0])
     regions = create_sample_regions(Region)
     self.projects = create_sample_projects(get_project_model(), self.users, regions)
     self.locations = create_local_sample_locations(get_location_schema()['model_class'])
    def setUp(self):
        delete_sample_user_states()
        self.user_state_schema = create_user_state_config(
            default_class_config())
        self.user_states = create_sample_user_states(
            UserState, get_region_model(), get_project_model(),
            get_location_schema()['model_class'],
            get_search_location_schema()['model_class'])
        # Gather all unique sample users
        self.users = list(
            set(R.map(lambda user_state: user_state.user, self.user_states)))
        self.client = client_for_testing(schema(), self.users[0])
        # Gather all unique sample regions
        self.regions = R.compose(
            # Forth Resolve persisted Regions
            R.map(lambda id: get_region_model().objects.get(id=id)),
            # Third make ids unique
            lambda ids: list(set(ids)),
            # Second map each to the region id
            R.map(R.item_str_path('region.id')),
            # First flat map the user regions of all user_states
            R.chain(lambda user_state: R.item_str_path(
                'data.userRegions', user_state.__dict__)))(self.user_states)
        # Gather all unique sample projects
        self.projects = R.compose(
            # Forth Resolve persisted Projects
            R.map(lambda id: get_project_model().objects.get(id=id)),
            # Third make ids unique
            lambda ids: list(set(ids)),
            # Second map each to the project id
            R.map(R.item_str_path('project.id')),
            # First flat map the user regions of all user_states
            R.chain(lambda user_state: R.item_str_path(
                'data.userProjects', user_state.__dict__)))(self.user_states)
        self.locations = create_local_sample_locations(
            get_location_schema()['model_class'])

        def extract_search_location_ids(user_regions):
            return R.map(
                R.item_str_path('searchLocation.id'),
                R.chain(R.item_str_path('userSearch.userSearchLocations'),
                        user_regions))

        # Gather all unique searches locations from userRegions.
        # user searches could also be in userProjects, but we'll ignore that
        self.search_locations = R.compose(
            # Forth Resolve persisted UserSearches
            lambda ids: R.map(
                lambda id: get_search_location_schema()['model_class'].objects.
                get(id=id), ids),
            # Third make ids unique
            lambda ids: list(set(ids)),
            # Chain to a flat list of user search location ids
            lambda user_regions: extract_search_location_ids(user_regions),
            # First flat map the user regions of all user_states
            R.chain(lambda user_state: R.item_str_path(
                'data.userRegions', user_state.__dict__)))(self.user_states)
        # Can be set by inheritors
        self.additional_user_scope_data = {}
示例#3
0
 def setUp(self):
     users = create_sample_users()
     self.client = client_for_testing(schema, users[0])
     self.locations = create_local_sample_locations(get_location_schema()['model_class'])
     self.regions = create_sample_regions(Region)
     self.projects = create_sample_projects(Project, users, self.regions)
     for project in self.projects:
         project.locations.add(*self.locations)
 def setUp(self):
     users = create_sample_users()
     self.client = client_for_testing(schema, users[0])
     delete_sample_resources()
     self.region = R.head(create_sample_regions(Region))
     self.resources = create_sample_resources([self.region])
     # Create a graph for all resources
     # This modifies each node to have a node_index
     self.graph = create_sankey_graph_from_resources(self.resources)
 def setUp(self):
     users = create_sample_users()
     self.client = client_for_testing(schema, users[0])
     self.regions = create_sample_regions(Region)
 def setUp(self):
     users = create_sample_users()
     self.client = client_for_testing(schema, users[0])
     self.settings = create_sample_settings_sets(Settings)