Skip to content

Commit 99b1b32

Browse files
authored
Py unittests (#28)
* Example rework with unittests * Examples adjusted so they can be unit tested
1 parent 943634e commit 99b1b32

21 files changed

+85
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ out
33
*.code-workspace
44
.vscode-test
55
test-resources/**
6-
*.vsix
6+
*.vsix
7+
__pycache__

assets/launch.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
"program": "${file}" ,
1313
"console": "integratedTerminal"
1414
},
15+
{
16+
"name": "Run Unit Tests",
17+
"type": "python",
18+
"request": "launch",
19+
"program": "${workspaceFolder}/test_plugin.py" ,
20+
"console": "integratedTerminal"
21+
},
1522
{
1623
"name": "Load Data with DIAdem",
1724
"type": "python",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import unittest
2+
import sys
3+
4+
5+
class BasicDataPluginTests(unittest.TestCase):
6+
7+
def test_class_init(self):
8+
p = Plugin()
9+
assert(True)
10+
11+
12+
if __name__ == '__main__':
13+
sys.path.append('.')
14+
from csv_read_with_callback_loading import Plugin
15+
16+
unittest.main()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
import sys
3+
from csv_read_with_callback_loading import Plugin
4+
5+
6+
class BasicDataPluginTests(unittest.TestCase):
7+
8+
def test_class_init(self):
9+
p = Plugin()
10+
self.assertIsInstance(p, Plugin)
11+
12+
13+
if __name__ == '__main__':
14+
unittest.main()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
import sys
3+
from csv_read_with_direct_loading import Plugin
4+
5+
6+
class BasicDataPluginTests(unittest.TestCase):
7+
8+
def test_class_init(self):
9+
p = Plugin()
10+
self.assertIsInstance(p, Plugin)
11+
12+
13+
if __name__ == '__main__':
14+
unittest.main()
File renamed without changes.

examples/hello_world/test_plugin.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
import sys
3+
from hello_world import Plugin
4+
5+
6+
class BasicDataPluginTests(unittest.TestCase):
7+
8+
def test_class_init(self):
9+
p = Plugin()
10+
self.assertIsInstance(p, Plugin)
11+
12+
13+
if __name__ == '__main__':
14+
unittest.main()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
import sys
3+
from npy_read_numpy_array_dump import Plugin
4+
5+
6+
class BasicDataPluginTests(unittest.TestCase):
7+
8+
def test_class_init(self):
9+
p = Plugin()
10+
self.assertIsInstance(p, Plugin)
11+
12+
13+
if __name__ == '__main__':
14+
unittest.main()

src/test/e2e/create-plugin.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Basic UI Tests', () => {
3333
const placeholderText2 = await chooseTemplateDropDown.getPlaceHolder();
3434
assert.strictEqual('Please choose a template to start with', placeholderText2);
3535
await new Promise(res => setTimeout(res, 500));
36-
await chooseTemplateDropDown.setText('hello-world');
36+
await chooseTemplateDropDown.setText('hello_world');
3737
await chooseTemplateDropDown.confirm();
3838

3939
// Project with correct name created in SideBar?

src/test/suite/dataplugin.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ suite('DataPlugin Test Suite', () => {
2121
});
2222

2323
test('should create class and initialize', async () => {
24-
const baseTemplate: string = 'hello-world';
24+
const baseTemplate: string = 'hello_world';
2525
const randomName: string = Guid.create().toString();
2626
const dataPlugin: DataPlugin = new DataPlugin(randomName, baseTemplate, Languages.Python);
2727
await dataPlugin.pluginIsInitialized();
@@ -51,11 +51,11 @@ suite('DataPlugin Test Suite', () => {
5151

5252
test('should throw FileExistsError', async () => {
5353
const randomName: string = Guid.create().toString();
54-
const dataPlugin: DataPlugin = new DataPlugin(randomName, 'hello-world', Languages.Python);
54+
const dataPlugin: DataPlugin = new DataPlugin(randomName, 'hello_world', Languages.Python);
5555
await dataPlugin.pluginIsInitialized();
5656
try {
5757
// tslint:disable-next-line: no-unused-expression
58-
new DataPlugin(randomName, 'hello-world', Languages.Python);
58+
new DataPlugin(randomName, 'hello_world', Languages.Python);
5959
} catch (e) {
6060
assert.strictEqual(e.errorType, ErrorType.FILEEXISTS);
6161
}

0 commit comments

Comments
 (0)