Exemplo n.º 1
0
    def test_descriptor(self):
        app = Addon()
        app.key = "key"
        app.name = "name"
        app.description = "description"
        app.vendor_name = "ACME"
        app.vendor_url = "example.com"
        app.allow_global = True
        app.allow_room = True
        # before saving we have no URLs to call back to
        # so the descriptor is null
        self.assertEqual(app.descriptor(), None)

        app.save()

        expected = {
            "key": "key",
            "name": "name",
            "description": "description",
            "vendor": {
                "name": "ACME",
                "url": "example.com"
            },
            "links": {
                "self": app.descriptor_url(),
            },
            "capabilities": {
                "hipchatApiConsumer": {
                    "scopes": []
                },
                "installable": {
                    "callbackUrl": app.install_url(),
                    "allowGlobal": True,
                    "allowRoom": True
                },
            },
            # "glance": [g.descriptor() for g in self.glances.all()]
        }
        self.assertEqual(app.descriptor(), expected)

        app.scopes.add(Scope.objects.first())
        scopes = app.descriptor()['capabilities']['hipchatApiConsumer']['scopes']
        self.assertEqual(scopes, app.scopes_as_list())

        glance = Glance(app=app, key='key').save()
        app.glances.add(glance)
        capabilities = app.descriptor()['capabilities']
        self.assertEqual(capabilities['glance'], [glance.descriptor()])
Exemplo n.º 2
0
 def test_query_url(self):
     obj = Glance(app=self.app).save()
     self.assertEqual(obj.query_url(), get_full_url(obj.get_absolute_url()))
     obj.data_url = "http://www.example.com"
     self.assertEqual(obj.query_url(), "http://www.example.com")
Exemplo n.º 3
0
 def test_save(self):
     obj = Glance(app=self.app, key='key')
     self.assertEqual(obj.save(), obj)