mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Add genhtml step
This commit is contained in:
parent
237a7da54a
commit
6ef95499b7
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
@ -40,6 +40,8 @@ jobs:
|
|||||||
- run: flutter analyze
|
- run: flutter analyze
|
||||||
- name: Run Unit Tests
|
- name: Run Unit Tests
|
||||||
run: |
|
run: |
|
||||||
|
apt-get install lcov
|
||||||
pip install -Ur requirements.txt
|
pip install -Ur requirements.txt
|
||||||
flutter test --coverage
|
flutter test --coverage
|
||||||
|
genhtml coverage/lcov.info -o coverage/html
|
||||||
coveralls
|
coveralls
|
@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Class for managing app-level configuration options
|
|
||||||
*/
|
|
||||||
|
|
||||||
import "package:sembast/sembast.dart";
|
|
||||||
import "package:inventree/preferences.dart";
|
|
||||||
|
|
||||||
// Settings key values
|
|
||||||
const String INV_HOME_SHOW_SUBSCRIBED = "homeShowSubscribed";
|
|
||||||
const String INV_HOME_SHOW_PO = "homeShowPo";
|
|
||||||
const String INV_HOME_SHOW_MANUFACTURERS = "homeShowManufacturers";
|
|
||||||
const String INV_HOME_SHOW_CUSTOMERS = "homeShowCustomers";
|
|
||||||
const String INV_HOME_SHOW_SUPPLIERS = "homeShowSuppliers";
|
|
||||||
|
|
||||||
const String INV_SOUNDS_BARCODE = "barcodeSounds";
|
|
||||||
const String INV_SOUNDS_SERVER = "serverSounds";
|
|
||||||
|
|
||||||
const String INV_PART_SUBCATEGORY = "partSubcategory";
|
|
||||||
|
|
||||||
const String INV_STOCK_SUBLOCATION = "stockSublocation";
|
|
||||||
const String INV_STOCK_SHOW_HISTORY = "stockShowHistory";
|
|
||||||
|
|
||||||
const String INV_REPORT_ERRORS = "reportErrors";
|
|
||||||
|
|
||||||
const String INV_STRICT_HTTPS = "strictHttps";
|
|
||||||
|
|
||||||
class InvenTreeSettingsManager {
|
|
||||||
|
|
||||||
factory InvenTreeSettingsManager() {
|
|
||||||
return _manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
InvenTreeSettingsManager._internal();
|
|
||||||
|
|
||||||
final store = StoreRef("settings");
|
|
||||||
|
|
||||||
Future<Database> get _db async => InvenTreePreferencesDB.instance.database;
|
|
||||||
|
|
||||||
Future<dynamic> getValue(String key, dynamic backup) async {
|
|
||||||
|
|
||||||
final value = await store.record(key).get(await _db);
|
|
||||||
|
|
||||||
if (value == null) {
|
|
||||||
return backup;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load a boolean setting
|
|
||||||
Future<bool> getBool(String key, bool backup) async {
|
|
||||||
final dynamic value = await getValue(key, backup);
|
|
||||||
|
|
||||||
if (value is bool) {
|
|
||||||
return value;
|
|
||||||
} else {
|
|
||||||
return backup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> setValue(String key, dynamic value) async {
|
|
||||||
|
|
||||||
await store.record(key).put(await _db, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure we only ever create a single instance of this class
|
|
||||||
static final InvenTreeSettingsManager _manager = InvenTreeSettingsManager._internal();
|
|
||||||
}
|
|
@ -6,6 +6,26 @@ import "package:sembast/sembast_io.dart";
|
|||||||
import "package:path/path.dart";
|
import "package:path/path.dart";
|
||||||
|
|
||||||
|
|
||||||
|
// Settings key values
|
||||||
|
const String INV_HOME_SHOW_SUBSCRIBED = "homeShowSubscribed";
|
||||||
|
const String INV_HOME_SHOW_PO = "homeShowPo";
|
||||||
|
const String INV_HOME_SHOW_MANUFACTURERS = "homeShowManufacturers";
|
||||||
|
const String INV_HOME_SHOW_CUSTOMERS = "homeShowCustomers";
|
||||||
|
const String INV_HOME_SHOW_SUPPLIERS = "homeShowSuppliers";
|
||||||
|
|
||||||
|
const String INV_SOUNDS_BARCODE = "barcodeSounds";
|
||||||
|
const String INV_SOUNDS_SERVER = "serverSounds";
|
||||||
|
|
||||||
|
const String INV_PART_SUBCATEGORY = "partSubcategory";
|
||||||
|
|
||||||
|
const String INV_STOCK_SUBLOCATION = "stockSublocation";
|
||||||
|
const String INV_STOCK_SHOW_HISTORY = "stockShowHistory";
|
||||||
|
|
||||||
|
const String INV_REPORT_ERRORS = "reportErrors";
|
||||||
|
|
||||||
|
const String INV_STRICT_HTTPS = "strictHttps";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class for storing InvenTree preferences in a NoSql DB
|
* Class for storing InvenTree preferences in a NoSql DB
|
||||||
*/
|
*/
|
||||||
@ -54,32 +74,50 @@ class InvenTreePreferencesDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class InvenTreePreferences {
|
|
||||||
|
|
||||||
factory InvenTreePreferences() {
|
/*
|
||||||
return _api;
|
* InvenTree setings manager class.
|
||||||
|
* Provides functions for loading and saving settings, with provision for default values
|
||||||
|
*/
|
||||||
|
class InvenTreeSettingsManager {
|
||||||
|
|
||||||
|
factory InvenTreeSettingsManager() {
|
||||||
|
return _manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
InvenTreePreferences._internal();
|
InvenTreeSettingsManager._internal();
|
||||||
|
|
||||||
/* The following settings are not stored to persistent storage,
|
final store = StoreRef("settings");
|
||||||
* instead they are only used as "session preferences".
|
|
||||||
* They are kept here as a convenience only.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Expand subcategory list in PartCategory view
|
Future<Database> get _db async => InvenTreePreferencesDB.instance.database;
|
||||||
bool expandCategoryList = false;
|
|
||||||
|
|
||||||
// Expand part list in PartCategory view
|
Future<dynamic> getValue(String key, dynamic backup) async {
|
||||||
bool expandPartList = true;
|
|
||||||
|
|
||||||
// Expand sublocation list in StockLocation view
|
final value = await store.record(key).get(await _db);
|
||||||
bool expandLocationList = false;
|
|
||||||
|
|
||||||
// Expand item list in StockLocation view
|
if (value == null) {
|
||||||
bool expandStockList = true;
|
return backup;
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure we only ever create a single instance of the preferences class
|
return value;
|
||||||
static final InvenTreePreferences _api = InvenTreePreferences._internal();
|
}
|
||||||
|
|
||||||
|
// Load a boolean setting
|
||||||
|
Future<bool> getBool(String key, bool backup) async {
|
||||||
|
final dynamic value = await getValue(key, backup);
|
||||||
|
|
||||||
|
if (value is bool) {
|
||||||
|
return value;
|
||||||
|
} else {
|
||||||
|
return backup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setValue(String key, dynamic value) async {
|
||||||
|
|
||||||
|
await store.record(key).put(await _db, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure we only ever create a single instance of this class
|
||||||
|
static final InvenTreeSettingsManager _manager = InvenTreeSettingsManager._internal();
|
||||||
}
|
}
|
21
test/preferences_test.dart
Normal file
21
test/preferences_test.dart
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Unit tests for the preferences manager
|
||||||
|
*/
|
||||||
|
|
||||||
|
import "package:test/test.dart";
|
||||||
|
import "package:inventree/preferences.dart";
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
|
||||||
|
setUp(() async {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
group("Settings Tests:", () {
|
||||||
|
test("Default Values", () async {
|
||||||
|
// Boolean values
|
||||||
|
expect(await InvenTreeSettingsManager().getBool("test", false), equals(false));
|
||||||
|
expect(await InvenTreeSettingsManager().getBool("test", true), equals(true));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user