def test_update(self):
     result, update_result = quiz_model_mutation_update(
         self.client, graphql_update_or_create_resource,
         'createResource.resource', 'updateResource.resource',
         dict(
             key='candy',
             name='Candy',
             region=dict(id=self.region.id),
             data=R.merge(
                 sample_settings,
                 dict(
                     material='Candy',
                     rawData=[
                         'Other Global Imports;Shipments, location generalized;51.309933, 3.055030;Source;22,469,843',
                         'Knauf (Danilith) BE;Waregemseweg 156-142 9790 Wortegem-Petegem, Belgium;50.864762, 3.479308;Conversion;657,245',
                         "MPRO Bruxelles;Avenue du Port 67 1000 Bruxelles, Belgium;50.867486, 4.352543;Distribution;18,632",
                         'Residential Buildings (all typologies);Everywhere in Brussels;NA;Demand;3,882,735',
                         'Duplex House Typology;Everywhere in Brussels;NA;Demand;13,544',
                         'Apartment Building Typology;Everywhere in Brussels;NA;Demand;34,643',
                         'New West Gypsum Recycling;9130 Beveren, Sint-Jansweg 9 Haven 1602, Kallo, Belgium;51.270229, 4.261048;Reconversion;87,565',
                         'Residential Buildings (all typologies);Everywhere in Brussels;NA;Sink;120,000',
                         'RecyPark South;1190 Forest, Belgium;50.810799, 4.314789;Sink;3,130',
                         'RecyPark Nord;Rue du Rupel, 1000 Bruxelles, Belgium;50.880181, 4.377136;Sink;1,162'
                     ]))), dict(key='popcorn', name='Popcorn'))
     versions = Version.objects.get_for_object(
         Resource.objects.get(id=R.item_str_path(
             'data.updateResource.resource.id', update_result)))
     assert len(versions) == 2
 def test_update(self):
     (result, update_result) = quiz_model_mutation_update(
         self.client,
         graphql_update_or_create_foo,
         'createFoo.foo',
         'updateFoo.foo',
         dict(name='Luxembourg',
              key='luxembourg',
              user=R.pick(['id'], self.admin),
              geojson=geojson,
              data=dict(example=1.1, friend=R.pick(['id'], self.user))),
         # Update the coords
         dict(
             geojson={
                 'features': [{
                     "type": "Feature",
                     "geometry": {
                         "type":
                         "Polygon",
                         "coordinates": [[[49.5294835476, 2.51357303225],
                                          [51.4750237087, 2.51357303225],
                                          [51.4750237087, 6.15665815596],
                                          [49.5294835476, 6.15665815596],
                                          [49.5294835476, 2.51357303225]]]
                     }
                 }]
             }))
     versions = Version.objects.get_for_object(
         Foo.objects.get(
             id=R.item_str_path('data.updateFoo.foo.id', update_result)))
     assert len(versions) == 2
Esempio n. 3
0
 def test_update(self):
     result, update_result = quiz_model_mutation_update(
         self.client,
         graphql_update_or_create_project,
         'createProject.project',
         'updateProject.project',
         dict(
             name='Carre',
             key='carre',
             geojson={
                 'type': 'FeatureCollection',
                 'features': [{
                     "type": "Feature",
                     "geometry": {
                         "type": "Polygon",
                         "coordinates": [
                             [[49.4426671413, 5.67405195478], [50.1280516628, 5.67405195478],
                              [50.1280516628, 6.24275109216],
                              [49.4426671413, 6.24275109216], [49.4426671413, 5.67405195478]]]
                     }
                 }]
             },
             data=dict(),
             locations=R.map(R.compose(R.pick(['id']), lambda l: l.__dict__), self.locations),
             user=R.pick(['id'], R.head(self.users).__dict__),
         ),
         # Update the coords and limit to one location
         dict(
             geojson={
                 'features': [{
                     "type": "Feature",
                     "geometry": {
                         "type": "Polygon",
                         "coordinates": [
                             [[49.5294835476, 2.51357303225], [51.4750237087, 2.51357303225],
                              [51.4750237087, 6.15665815596],
                              [49.5294835476, 6.15665815596], [49.5294835476, 2.51357303225]]]
                     }
                 }]
             },
             locations=R.map(R.compose(R.pick(['id']), lambda l: l.__dict__), [R.head(self.locations)])
         )
     )
     versions = Version.objects.get_for_object(get_project_model().objects.get(
         id=R.item_str_path('data.updateProject.project.id', update_result)
     ))
     assert len(versions) == 2
    def test_update(self):
        # First add a new User
        margay = dict(username="******",
                      first_name='Upa',
                      last_name='Tree',
                      password=make_password("merowgir", salt='not_random'))
        user = create_sample_user(margay)

        # Now assign regions and persist the UserState
        sample_user_state_data = dict(
            user=dict(id=user.id),
            data=form_sample_user_state_data(
                self.regions,
                self.projects,
                dict(
                    userRegions=[
                        dict(
                            # Assign the first region
                            region=dict(
                                key=R.prop('key', R.head(self.regions))),
                            mapbox=dict(viewport=dict(
                                latitude=50.5915, longitude=2.0165, zoom=7)))
                    ],
                    userProjects=[
                        dict(
                            # Assign the first prjoect
                            project=dict(
                                key=R.prop('key', R.head(self.projects))),
                            mapbox=dict(viewport=dict(
                                latitude=50.5915, longitude=2.0165, zoom=7)))
                    ])))

        # Update the zoom of the first userRegion
        update_data = deepcopy(R.pick(['data'], sample_user_state_data))
        R.item_str_path(
            'mapbox.viewport',
            R.head(R.item_str_path('data.userRegions',
                                   (update_data))))['zoom'] = 15

        result, update_result = quiz_model_mutation_update(
            self.client, R.prop('graphql_mutation', self.user_state_schema),
            'createUserState.userState', 'updateUserState.userState',
            sample_user_state_data, update_data)
        versions = Version.objects.get_for_object(
            UserState.objects.get(id=R.item_str_path(
                'data.updateUserState.userState.id', update_result)))
        assert len(versions) == 2
Esempio n. 5
0
 def test_update(self):
     result, update_result = quiz_model_mutation_update(
         self.client,
         graphql_update_or_create_location,
         'createLocation.location',
         'updateLocation.location',
         dict(
             name='Grote Markt',
             key='groteMarkt',
             geojson={
                 'type': 'FeatureCollection',
                 'features': [{
                     "type": "Feature",
                     "geometry": {
                         "type": "Polygon",
                         "coordinates": [
                             [[49.4426671413, 5.67405195478], [50.1280516628, 5.67405195478],
                              [50.1280516628, 6.24275109216],
                              [49.4426671413, 6.24275109216], [49.4426671413, 5.67405195478]]]
                     }
                 }]
             },
             data=dict()
         ),
         # Update the coords
         dict(
             geojson={
                 'features': [{
                     "type": "Feature",
                     "geometry": {
                         "type": "Polygon",
                         "coordinates": [
                             [[49.5294835476, 2.51357303225], [51.4750237087, 2.51357303225],
                              [51.4750237087, 6.15665815596],
                              [49.5294835476, 6.15665815596], [49.5294835476, 2.51357303225]]]
                     }
                 }]
             }
         )
     )
     versions = Version.objects.get_for_object(Location.objects.get(
         id=R.item_str_path('data.updateLocation.location.id', update_result)
     ))
     assert len(versions) == 2
 def test_update(self):
     result, update_result = quiz_model_mutation_update(
         self.client,
         graphql_update_or_create_settings,
         'createSettings.settings',
         'updateSettings.settings',
         dict(key='mars',
              data=dict(domain='localhost',
                        api=dict(protocol='http',
                                 host='localhost',
                                 port='8008',
                                 path='/graphql/'),
                        overpass=dict(cellSize=100, sleepBetweenCalls=1000),
                        mapbox=dict(viewport={}, ))),
         # Update the coords
         dict(data=dict(domain='alienhost', api=dict(host='alienhost', ))))
     versions = Version.objects.get_for_object(
         Settings.objects.get(id=R.item_str_path(
             'data.updateSettings.settings.id', update_result)))
     assert len(versions) == 2