コード例 #1
0
    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_tenant(self):

        t = tenants.Tenant()
        self.objects.append(t)
        t.id = TENANT_ID
        self.session.add(t)
        self.session.flush()
        self.session.commit()


        t2 = self.session.query(tenants.Tenant)\
            .filter(tenants.Tenant.id == TENANT_ID)[0]

        self.assertTrue(t2 is not None)
        self.assertEqual(t2.id, TENANT_ID)
コード例 #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)
コード例 #5
0
    def test_instance_tenant(self):

        from artifice.models import tenants

        t = tenants.Tenant()
        self.assertTrue(isinstance(t, tenants.Tenant))