Skip to content

Commit b5a9396

Browse files
authored
Merge pull request #46 from patricoos/master
Release 1.0.19
2 parents 8c58593 + 9a8108c commit b5a9396

10 files changed

Lines changed: 1556 additions & 439 deletions

File tree

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ master, release ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ master ]
20+
schedule:
21+
- cron: '40 18 * * 2'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'csharp' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v2
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v1
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
52+
53+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54+
# If this step fails, then you should remove it and run the build manually (see below)
55+
- name: Autobuild
56+
uses: github/codeql-action/autobuild@v1
57+
58+
# ℹ️ Command-line programs to run using the OS shell.
59+
# 📚 https://git.io/JvXDl
60+
61+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62+
# and modify them (or add more) to build your code if your project
63+
# uses a compiled language
64+
65+
#- run: |
66+
# make bootstrap
67+
# make release
68+
69+
- name: Perform CodeQL Analysis
70+
uses: github/codeql-action/analyze@v1

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021-present Patryk Bujalla and Contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

PortaCapena.OdooJsonRpcClient.Example/OdooClientTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task Can_get_odoo_version()
3434
public async Task Get_DotNet_model_should_return_string()
3535
{
3636
var odooClient = new OdooClient(TestConfig);
37-
var tableName = "product.product";
37+
var tableName = "product.template";
3838
var modelResult = await odooClient.GetModelAsync(tableName);
3939

4040
modelResult.Succeed.Should().BeTrue();

PortaCapena.OdooJsonRpcClient.Example/OdooRepositoryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class OdooRepositoryTests : RequestTestBase
2525
[InlineData(typeof(CompanyOdooDto))]
2626
[InlineData(typeof(CouponProgramOdooDto))]
2727
[InlineData(typeof(ProductPriceListOdooDto))]
28-
[InlineData(typeof(ProductTemplateOdooDto))]
28+
[InlineData(typeof(ProductTemplateOdooModel))]
2929
[InlineData(typeof(PurchaseOrderLineOdooModel))]
3030
[InlineData(typeof(PurchaseOrderOdooModel))]
3131
[InlineData(typeof(ResCompanyOdooModel))]
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using FluentAssertions;
4+
using PortaCapena.OdooJsonRpcClient.Consts;
5+
using PortaCapena.OdooJsonRpcClient.Extensions;
6+
using PortaCapena.OdooJsonRpcClient.Models;
7+
using PortaCapena.OdooJsonRpcClient.Request;
8+
using PortaCapena.OdooJsonRpcClient.Shared;
9+
using PortaCapena.OdooJsonRpcClient.Shared.Models;
10+
using Xunit;
11+
12+
namespace PortaCapena.OdooJsonRpcClient.Example
13+
{
14+
public class ProductTemplateOdooModelRepositoryTests : RequestTestBase
15+
{
16+
private class ProductTemplateRepository : OdooRepository<ProductTemplateOdooModel>
17+
{
18+
public ProductTemplateRepository() : base(TestConfig) { }
19+
}
20+
21+
[Fact]
22+
public async Task Get_All()
23+
{
24+
var repo = new ProductTemplateRepository();
25+
26+
var result = await repo.Query().ToListAsync();
27+
28+
result.Error.Should().BeNull();
29+
result.Succeed.Should().BeTrue();
30+
result.Value.Should().NotBeNull().And.NotBeEmpty();
31+
}
32+
33+
[Fact]
34+
public async Task Get_By_Id()
35+
{
36+
var repo = new ProductTemplateRepository();
37+
38+
var result = await repo.Query().ById(1).FirstOrDefaultAsync();
39+
40+
result.Error.Should().BeNull();
41+
result.Succeed.Should().BeTrue();
42+
result.Value.Should().NotBeNull();
43+
}
44+
45+
[Fact]
46+
public async Task Get_By_Ids()
47+
{
48+
var repo = new ProductTemplateRepository();
49+
50+
var result = await repo.Query().ByIds(1, 2).ToListAsync();
51+
52+
result.Error.Should().BeNull();
53+
result.Succeed.Should().BeTrue();
54+
result.Value.Should().NotBeNull().And.NotBeEmpty();
55+
result.Value.Length.Should().Be(2);
56+
}
57+
58+
59+
60+
[Fact]
61+
public async Task Get_name_in_nl()
62+
{
63+
var repo = new ProductTemplateRepository();
64+
65+
var result = await repo.Query().ById(23).FirstOrDefaultAsync();
66+
67+
result.Error.Should().BeNull();
68+
result.Succeed.Should().BeTrue();
69+
result.Value.Should().NotBeNull();
70+
result.Value.Name.Should().Be("Acoustic Bloc Screens");
71+
result.Value.Name.Should().NotBe("Akoestische blokschermen");
72+
73+
74+
repo.Config.Context.Language = "nl_NL";
75+
76+
var resultInNL = await repo.Query().ById(result.Value.Id).Select(x => new { x.Name}).FirstOrDefaultAsync();
77+
78+
resultInNL.Error.Should().BeNull();
79+
resultInNL.Succeed.Should().BeTrue();
80+
resultInNL.Value.Should().NotBeNull();
81+
82+
resultInNL.Value.Name.Should().NotBe("Acoustic Bloc Screens");
83+
resultInNL.Value.Name.Should().Be("Akoestische blokschermen");
84+
85+
repo.Config.Context.Language = "en_US";
86+
87+
var resultInEn = await repo.Query().ById(result.Value.Id).FirstOrDefaultAsync();
88+
89+
resultInEn.Error.Should().BeNull();
90+
resultInEn.Succeed.Should().BeTrue();
91+
resultInEn.Value.Should().NotBeNull();
92+
93+
resultInEn.Value.Name.Should().Be("Acoustic Bloc Screens");
94+
resultInEn.Value.Name.Should().NotBe("Akoestische blokschermen");
95+
}
96+
97+
//[Fact]
98+
[Fact(Skip = "Test for working on Odoo")]
99+
public async Task Update_name_in_nl()
100+
{
101+
var repo = new ProductTemplateRepository();
102+
103+
var result = await repo.Query().ById(15).FirstOrDefaultAsync();
104+
105+
result.Error.Should().BeNull();
106+
result.Succeed.Should().BeTrue();
107+
result.Value.Should().NotBeNull();
108+
result.Value.Name.Should().Be("Acoustic Bloc Screens");
109+
result.Value.Name.Should().NotBe("Akoestische blokschermen");
110+
111+
var model = OdooDictionaryModel.Create<ProductProductOdooModel>().Add(x => x.Name, "Product new name NL");
112+
113+
repo.Config.Context.Language = "nl_BE";
114+
115+
var updateResult = await repo.UpdateAsync(model, result.Value.Id);
116+
117+
updateResult.Error.Should().BeNull();
118+
updateResult.Succeed.Should().BeTrue();
119+
updateResult.Value.Should().BeTrue();
120+
121+
var resultInNL = await repo.Query().ById(result.Value.Id).FirstOrDefaultAsync();
122+
123+
resultInNL.Error.Should().BeNull();
124+
resultInNL.Succeed.Should().BeTrue();
125+
resultInNL.Value.Should().NotBeNull();
126+
127+
result.Value.Name.Should().NotBe("Acoustic Bloc Screens");
128+
result.Value.Name.Should().Be("Akoestische blokschermen");
129+
130+
131+
repo.Config.Context.Language = "en_US";
132+
133+
var resultInEn = await repo.Query().ById(result.Value.Id).FirstOrDefaultAsync();
134+
135+
resultInEn.Error.Should().BeNull();
136+
resultInEn.Succeed.Should().BeTrue();
137+
resultInEn.Value.Should().NotBeNull();
138+
139+
resultInEn.Value.Name.Should().Be("Acoustic Bloc Screens");
140+
resultInEn.Value.Name.Should().NotBe("Akoestische blokschermen");
141+
}
142+
}
143+
}

0 commit comments

Comments
 (0)