mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Adds more unit tests for the part model
This commit is contained in:
parent
7d1735b1b7
commit
8ee10a3424
@ -27,6 +27,10 @@ void main() {
|
|||||||
|
|
||||||
group("Part Tests:", () {
|
group("Part Tests:", () {
|
||||||
|
|
||||||
|
test("Basics", () async {
|
||||||
|
assert(InvenTreePart().URL == "part/");
|
||||||
|
});
|
||||||
|
|
||||||
test("List Parts", () async {
|
test("List Parts", () async {
|
||||||
List<InvenTreeModel> results;
|
List<InvenTreeModel> results;
|
||||||
|
|
||||||
@ -49,6 +53,64 @@ void main() {
|
|||||||
assert(results.length == 2);
|
assert(results.length == 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Part Detail", () async {
|
||||||
|
final result = await InvenTreePart().get(1);
|
||||||
|
|
||||||
|
assert(result != null);
|
||||||
|
assert(result is InvenTreePart);
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
InvenTreePart part = result as InvenTreePart;
|
||||||
|
|
||||||
|
// Check some basic properties of the part
|
||||||
|
assert(part.name == "M2x4 LPHS");
|
||||||
|
assert(part.fullname == "M2x4 LPHS");
|
||||||
|
assert(part.description == "M2x4 low profile head screw");
|
||||||
|
assert(part.categoryId == 8);
|
||||||
|
assert(part.categoryName == "Fasteners");
|
||||||
|
assert(part.image == part.thumbnail);
|
||||||
|
assert(part.thumbnail == "/static/img/blank_image.thumbnail.png");
|
||||||
|
|
||||||
|
// Stock information
|
||||||
|
assert(part.unallocatedStockString == "9000");
|
||||||
|
assert(part.inStockString == "9000");
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
test("Part Adjust", () async {
|
||||||
|
// Test that we can update part data
|
||||||
|
final result = await InvenTreePart().get(1);
|
||||||
|
|
||||||
|
assert(result != null);
|
||||||
|
assert(result is InvenTreePart);
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
InvenTreePart part = result as InvenTreePart;
|
||||||
|
assert(part.name == "M2x4 LPHS");
|
||||||
|
|
||||||
|
// Change the name to something else
|
||||||
|
assert(await part.update(
|
||||||
|
values: {
|
||||||
|
"name": "Woogle",
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
assert(await part.reload());
|
||||||
|
assert(part.name == "Woogle");
|
||||||
|
|
||||||
|
// And change it back again
|
||||||
|
assert(await part.update(
|
||||||
|
values: {
|
||||||
|
"name": "M2x4 LPHS"
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
assert(await part.reload());
|
||||||
|
assert(part.name == "M2x4 LPHS");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user