add filepath handling and integrated setup method, closes #3
This commit is contained in:
parent
11c313087f
commit
2a66b8582d
@ -47,14 +47,19 @@ namespace dopt.DeltaBarth.Tests
|
||||
{
|
||||
return base.GetBaseApiUrl();
|
||||
}
|
||||
new public void SetzeBasisApiUrl(string basisApiUrl)
|
||||
public new string GetDataPath()
|
||||
{
|
||||
base.SetzeBasisApiUrl(basisApiUrl);
|
||||
return base.GetDataPath();
|
||||
}
|
||||
public new void Setup(string datenPfad, string basisApiUrl)
|
||||
{
|
||||
base.Setup(datenPfad, basisApiUrl);
|
||||
}
|
||||
}
|
||||
[TestClass]
|
||||
public sealed class PluginTest
|
||||
{
|
||||
private const string baseDataPath = @"A:\Arbeitsaufgaben\Delta-Barth\cs-wrapper\dopt.DeltaBarth\test_data_path";
|
||||
internal Config config = new Config();
|
||||
static void PrettyPrint(object toSerialise)
|
||||
{
|
||||
@ -85,13 +90,19 @@ namespace dopt.DeltaBarth.Tests
|
||||
test.Dispose();
|
||||
}
|
||||
[TestMethod]
|
||||
public void Set_and_Obtain_BaseApiUrl_Test()
|
||||
public void SetupSession_Test()
|
||||
{
|
||||
var test = new TPlugin();
|
||||
string apiUrlSet = "http://10.2.22.21:8080/api/";
|
||||
test.SetzeBasisApiUrl(apiUrlSet);
|
||||
test.Setup(baseDataPath, apiUrlSet);
|
||||
// data path
|
||||
var dataPathGet = test.GetDataPath();
|
||||
Console.WriteLine($"Result for data path from Python session was: {dataPathGet}");
|
||||
bool pathElementsContained = dataPathGet.Contains("test_data_path");
|
||||
Assert.IsTrue(pathElementsContained);
|
||||
// API URL
|
||||
var apiUrlGet = test.GetBaseApiUrl();
|
||||
Console.WriteLine($"Result from Python session was: {apiUrlGet}");
|
||||
Console.WriteLine($"Result for API URL from Python session was: {apiUrlGet}");
|
||||
Assert.AreEqual(apiUrlSet, apiUrlGet);
|
||||
test.Dispose();
|
||||
}
|
||||
@ -100,7 +111,7 @@ namespace dopt.DeltaBarth.Tests
|
||||
{
|
||||
var test = new TPlugin();
|
||||
string apiUrlSet = "http://10.2.22.21:8080/api/", user = "user", password = "password", database = "DB1", mandant = "mandant1";
|
||||
test.Startup(apiUrlSet, user, password, database, mandant);
|
||||
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
|
||||
var apiUrlGet = test.GetBaseApiUrl();
|
||||
var creds = test.GetCredentials();
|
||||
Console.WriteLine($"Result from Python session was: API-URL={apiUrlGet}, creds={creds}");
|
||||
@ -117,7 +128,7 @@ namespace dopt.DeltaBarth.Tests
|
||||
{
|
||||
var test = new TPlugin();
|
||||
string apiUrlSet = "http://10.2.22.21:8080/api/", user = "user", password = "password", database = "DB1", mandant = "mandant1";
|
||||
test.Startup(apiUrlSet, user, password, database, mandant);
|
||||
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
|
||||
var res = test.UmsatzprognoseDummy(null, null);
|
||||
PrettyPrint(res);
|
||||
test.Dispose();
|
||||
@ -127,7 +138,7 @@ namespace dopt.DeltaBarth.Tests
|
||||
{
|
||||
var test = new TPlugin();
|
||||
string apiUrlSet = "http://10.2.22.21:8080/api/", user = "user", password = "password", database = "DB1", mandant = "mandant1";
|
||||
test.Startup(apiUrlSet, user, password, database, mandant);
|
||||
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
|
||||
var comp_id = 1000;
|
||||
var res = test.UmsatzprognoseDummy(comp_id, null);
|
||||
PrettyPrint(res);
|
||||
@ -138,7 +149,7 @@ namespace dopt.DeltaBarth.Tests
|
||||
{
|
||||
var test = new TPlugin();
|
||||
string apiUrlSet = "http://10.2.22.21:8080/api/", user = "user", password = "password", database = "DB1", mandant = "mandant1";
|
||||
test.Startup(apiUrlSet, user, password, database, mandant);
|
||||
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
|
||||
var date = new DateTime(2023, 1, 1, 12, 45, 30);
|
||||
var res = test.UmsatzprognoseDummy(null, date);
|
||||
PrettyPrint(res);
|
||||
@ -151,7 +162,7 @@ namespace dopt.DeltaBarth.Tests
|
||||
{
|
||||
var test = new TPlugin();
|
||||
string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant;
|
||||
test.Startup(apiUrlSet, user, password, database, mandant);
|
||||
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
|
||||
var comp_id = 1024;
|
||||
var res = test.Umsatzprognose(comp_id, null);
|
||||
PrettyPrint(res);
|
||||
@ -163,7 +174,7 @@ namespace dopt.DeltaBarth.Tests
|
||||
{
|
||||
var test = new TPlugin();
|
||||
string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant;
|
||||
test.Startup(apiUrlSet, user, password, database, mandant);
|
||||
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
|
||||
var date = new DateTime(2030, 1, 1, 12, 45, 30);
|
||||
var res = test.Umsatzprognose(null, date);
|
||||
PrettyPrint(res);
|
||||
@ -175,7 +186,7 @@ namespace dopt.DeltaBarth.Tests
|
||||
{
|
||||
var test = new TPlugin();
|
||||
string apiUrlSet = config.apiUrl, user = config.username, password = config.password, database = config.database, mandant = config.mandant;
|
||||
test.Startup(apiUrlSet, user, password, database, mandant);
|
||||
test.Startup(baseDataPath, apiUrlSet, user, password, database, mandant);
|
||||
var date = new DateTime(2015, 1, 1, 12, 45, 30);
|
||||
var res = test.Umsatzprognose(null, date);
|
||||
PrettyPrint(res);
|
||||
|
||||
@ -16,17 +16,12 @@ namespace dopt.DeltaBarth
|
||||
pyModPipeline = Py.Import("delta_barth.pipelines");
|
||||
}
|
||||
}
|
||||
public void Startup(string basisApiUrl, string nutzername, string passwort, string datenbank, string mandant)
|
||||
public void Startup(string datenPfad, string basisApiUrl, string nutzername, string passwort, string datenbank, string mandant)
|
||||
{
|
||||
AssertNotDisposed();
|
||||
SetzeBasisApiUrl(basisApiUrl);
|
||||
Setup(datenPfad, basisApiUrl);
|
||||
SetzeNutzerdaten(nutzername, passwort, datenbank, mandant);
|
||||
}
|
||||
protected void SetzeBasisApiUrl(string basisApiUrl)
|
||||
{
|
||||
AssertNotDisposed();
|
||||
pyModManagement.set_base_url(basisApiUrl);
|
||||
}
|
||||
public void SetzeNutzerdaten(string nutzername, string passwort, string datenbank, string mandant)
|
||||
{
|
||||
AssertNotDisposed();
|
||||
@ -58,6 +53,14 @@ namespace dopt.DeltaBarth
|
||||
|
||||
return parsed;
|
||||
}
|
||||
protected void Setup(string datenPfad, string basisApiUrl)
|
||||
{
|
||||
AssertNotDisposed();
|
||||
using (Py.GIL())
|
||||
{
|
||||
pyModManagement.setup(datenPfad, basisApiUrl);
|
||||
}
|
||||
}
|
||||
protected string GetBaseApiUrl()
|
||||
{
|
||||
AssertNotDisposed();
|
||||
@ -68,6 +71,16 @@ namespace dopt.DeltaBarth
|
||||
}
|
||||
return pyJson;
|
||||
}
|
||||
protected string GetDataPath()
|
||||
{
|
||||
AssertNotDisposed();
|
||||
string pyJson;
|
||||
using (Py.GIL())
|
||||
{
|
||||
pyJson = (string)pyModManagement.get_data_path();
|
||||
}
|
||||
return pyJson;
|
||||
}
|
||||
protected DataObjects.Credentials GetCredentials()
|
||||
{
|
||||
AssertNotDisposed();
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Platforms>x64</Platforms>
|
||||
<Version>0.2.0</Version>
|
||||
<Version>0.3.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user