2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-16 12:15:31 +00:00

Format code

This commit is contained in:
Asterix\Oliver
2025-06-14 10:59:13 +10:00
parent 0349ebb0b3
commit 387dc1eb39
96 changed files with 5478 additions and 7340 deletions

View File

@ -1,4 +1,3 @@
import "package:flutter/services.dart";
import "package:flutter_test/flutter_test.dart";
import "package:inventree/api.dart";
@ -16,7 +15,8 @@ void setupTestEnv() {
CustomBinding();
// Mock the path provider
const MethodChannel channel = MethodChannel("plugins.flutter.io/path_provider");
const MethodChannel channel =
MethodChannel("plugins.flutter.io/path_provider");
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (MethodCall methodCall) async {
return ".";
@ -29,41 +29,36 @@ const String testServerName = "Test Server";
const String testUsername = "testuser";
const String testPassword = "testpassword";
/*
* Request an API token for the given profile
*/
Future<bool> fetchProfileToken({
UserProfile? profile,
String username = testUsername,
String password = testPassword
}) async {
Future<bool> fetchProfileToken(
{UserProfile? profile,
String username = testUsername,
String password = testPassword}) async {
profile ??= await UserProfileDBManager().getProfileByName(testServerName);
assert(profile != null);
final response = await InvenTreeAPI().fetchToken(profile!, username, password);
final response =
await InvenTreeAPI().fetchToken(profile!, username, password);
return response.successful();
}
/*
* Setup a valid profile, and return it
*/
Future<UserProfile> setupServerProfile({bool select = true, bool fetchToken = false}) async {
Future<UserProfile> setupServerProfile(
{bool select = true, bool fetchToken = false}) async {
// Setup a valid server profile
UserProfile? profile = await UserProfileDBManager().getProfileByName(testServerName);
UserProfile? profile =
await UserProfileDBManager().getProfileByName(testServerName);
if (profile == null) {
// Profile does not already exist - create it!
bool result = await UserProfileDBManager().addProfile(
UserProfile(
server: testServerAddress,
name: testServerName
)
);
UserProfile(server: testServerAddress, name: testServerName));
assert(result);
}
@ -84,15 +79,13 @@ Future<UserProfile> setupServerProfile({bool select = true, bool fetchToken = fa
return profile!;
}
/*
* Complete all steps necessary to login to the server
*/
Future<void> connectToTestServer() async {
// Setup profile, and fetch user token as necessary
final profile = await setupServerProfile(fetchToken: true);
// Connect to the server
assert(await InvenTreeAPI().connectToServer(profile));
}
}