-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprocurement_test.go
More file actions
59 lines (53 loc) · 1.93 KB
/
procurement_test.go
File metadata and controls
59 lines (53 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2019 NDP Systèmes. All Rights Reserved.
// See LICENSE file for full licensing details.
package procurement
import (
"testing"
"github.com/hexya-addons/base"
"github.com/hexya-erp/hexya/src/models"
"github.com/hexya-erp/hexya/src/models/security"
"github.com/hexya-erp/hexya/src/tests"
"github.com/hexya-erp/pool/h"
"github.com/hexya-erp/pool/q"
. "github.com/smartystreets/goconvey/convey"
)
func TestMain(m *testing.M) {
tests.RunTests(m, "procurement", nil)
}
func TestBase(t *testing.T) {
Convey("Testing base procurements", t, func() {
So(models.SimulateInNewEnvironment(security.SuperUserID, func(env models.Environment) {
userEmployee := h.User().NewSet(env).
WithContext("no_reset_password", true).
WithContext("mail_create_nosubscribe", true).
Create(h.User().NewData().
SetName("Fabricette Manivelle").
SetLogin("fabricette").
SetEmail("f.f@exmaple.com").
SetGroups(h.Group().Search(env, q.Group().GroupID().Equals(base.GroupUser.ID))))
h.Group().NewSet(env).ReloadGroups()
uomUnit := h.ProductUom().Search(env, q.ProductUom().HexyaExternalID().Equals("product_product_uom_unit"))
uomDunit := h.ProductUom().Create(env, h.ProductUom().NewData().
SetName("DeciUnit").
SetCategory(uomUnit.Category()).
SetFactorInv(0.1).
SetFactor(10).
SetUomType("smaller").
SetRounding(0.001))
product1 := h.ProductProduct().Create(env, h.ProductProduct().NewData().
SetName("Courage").
SetType("consu").
SetUom(uomUnit).
SetUomPo(uomDunit))
Convey("Procurement Order should be in exception as there is no suitable rule", func() {
procurement := h.ProcurementOrder().NewSet(env).Sudo(userEmployee.ID()).Create(
h.ProcurementOrder().NewData().
SetProduct(product1).
SetName("Procurement Test").
SetProductQty(15).
SetProductUom(product1.Uom()))
So(procurement.State(), ShouldEqual, "exception")
})
}), ShouldBeNil)
})
}