예제 #1
0
    def test_apply_provisional_edit(self):
        """
        Tests that provisional edit data is properly created

        """

        json = {
            "resourceinstance_id": "40000000-0000-0000-0000-000000000000",
            "parenttile_id": '',
            "nodegroup_id": "72048cb3-adbc-11e6-9ccf-14109fd34195",
            "tileid": "",
            "data": {
              "72048cb3-adbc-11e6-9ccf-14109fd34195": "TEST 1"
            }
        }

        user = User.objects.create_user(username='******', password='******')
        provisional_tile = Tile(json)
        request = HttpRequest()
        request.user = user
        provisional_tile.save(index=False, request=request)
        provisional_tile.apply_provisional_edit(user, {"test":"test"}, 'update')
        provisionaledits = JSONDeserializer().deserialize(provisional_tile.provisionaledits)
        userid = str(user.id)
        self.assertEqual(provisionaledits[userid]['action'], 'update')
        self.assertEqual(provisionaledits[userid]['reviewer'], None)
        self.assertEqual(provisionaledits[userid]['value'], {"test":"test"})
        self.assertEqual(provisionaledits[userid]['status'], "review")
        self.assertEqual(provisionaledits[userid]['reviewtimestamp'], None)
예제 #2
0
    def test_apply_provisional_edit(self):
        """
        Tests that provisional edit data is properly created

        """

        json = {
            "resourceinstance_id": "40000000-0000-0000-0000-000000000000",
            "parenttile_id": '',
            "nodegroup_id": "72048cb3-adbc-11e6-9ccf-14109fd34195",
            "tileid": "",
            "data": {
                "72048cb3-adbc-11e6-9ccf-14109fd34195": "TEST 1"
            }
        }

        user = User.objects.create_user(username='******',
                                        password='******')
        provisional_tile = Tile(json)
        request = HttpRequest()
        request.user = user
        provisional_tile.save(index=False, request=request)
        provisional_tile.apply_provisional_edit(user, {"test": "test"},
                                                'update')
        provisionaledits = JSONDeserializer().deserialize(
            provisional_tile.provisionaledits)
        userid = str(user.id)
        self.assertEqual(provisionaledits[userid]['action'], 'update')
        self.assertEqual(provisionaledits[userid]['reviewer'], None)
        self.assertEqual(provisionaledits[userid]['value'], {"test": "test"})
        self.assertEqual(provisionaledits[userid]['status'], "review")
        self.assertEqual(provisionaledits[userid]['reviewtimestamp'], None)
예제 #3
0
    def test_apply_provisional_edit(self):
        """
        Tests that provisional edit data is properly created

        """

        json = {
            "resourceinstance_id": "40000000-0000-0000-0000-000000000000",
            "parenttile_id": "",
            "nodegroup_id": "72048cb3-adbc-11e6-9ccf-14109fd34195",
            "tileid": "",
            "data": {
                "72048cb3-adbc-11e6-9ccf-14109fd34195": "TEST 1"
            },
        }

        user = User.objects.create_user(username="******",
                                        password="******")
        provisional_tile = Tile(json)
        request = HttpRequest()
        request.user = user
        provisional_tile.save(index=False, request=request)
        provisional_tile.apply_provisional_edit(user, {"test": "test"},
                                                "update")
        provisionaledits = provisional_tile.provisionaledits
        userid = str(user.id)
        self.assertEqual(provisionaledits[userid]["action"], "update")
        self.assertEqual(provisionaledits[userid]["reviewer"], None)
        self.assertEqual(provisionaledits[userid]["value"], {"test": "test"})
        self.assertEqual(provisionaledits[userid]["status"], "review")
        self.assertEqual(provisionaledits[userid]["reviewtimestamp"], None)