def test_instance_usage(self):

        from artifice.models import usage, tenants, resources

        start = datetime.datetime.now() - datetime.timedelta(days=30)
        end = datetime.datetime.now()

        r = resources.Resource()
        t = tenants.Tenant()
        r.tenant = t
        u = usage.Usage(r, t, 1, start, end)
        self.assertTrue(isinstance(u, usage.Usage))
示例#2
0
    def test_create_resource_without_tenant_fails(self):

        r = resources.Resource()
        r.id = RESOURCE_ID
        self.session.add(r)

        self.objects.append(r)

        try:
            self.session.commit()
        except IntegrityError:
            self.assertTrue(True)
        except Exception as e:
            self.fail(e)
示例#3
0
    def test_create_resource_with_bad_tenant_fails(self):

        r = resources.Resource()

        t = tenants.Tenant()
        r.tenant = t

        self.objects.extend((r, t))

        self.session.add(r)
        self.session.add(t)
        try:
            self.session.commit()
        except IntegrityError:
            self.assertTrue(True)
        except Exception as e:
            self.fail(e)
示例#4
0
    def test_create_resource(self):
        r = resources.Resource()
        t = tenants.Tenant()
        t.id = TENANT_ID

        r.tenant = t
        r.id = RESOURCE_ID
        self.session.add(r)
        self.session.add(t)
        self.objects.extend((r, t))
        self.session.flush()
        self.session.commit()

        r2 = self.session.query(resources.Resource)\
            .filter(resources.Resource.id == RESOURCE_ID)[0]

        self.assertEqual(r2.id, r.id)
        self.assertEqual(r2.tenant.id, t.id)
    def test_instance_resource(self):

        from artifice.models import resources

        r = resources.Resource()
        self.assertTrue(isinstance(r, resources.Resource))