Browse Source

Update Tests and add in Jenkins things

development
Sapein 7 months ago
parent
commit
220cddbbb4
3 changed files with 50 additions and 21 deletions
  1. 27
    0
      Jenkinsfile
  2. 11
    14
      Makefile
  3. 12
    7
      tests/test_managers.py

+ 27
- 0
Jenkinsfile View File

@@ -0,0 +1,27 @@
1
+pipeline {
2
+    agent any
3
+
4
+    environment {
5
+        DISCORD_BOT_TOKEN = credentials('Potatobot-discord-token')
6
+    }
7
+
8
+
9
+    stages {
10
+        stage('Linting'){
11
+            steps {
12
+                sh 'echo "Linting"'
13
+            }
14
+        }
15
+        stage('Testing'){
16
+            steps {
17
+                sh 'TEST_ARGS=--junitxml='.' make create_dev test'
18
+                junit '.'
19
+            }
20
+        }
21
+        post {
22
+            always {
23
+                sh 'echo Test'
24
+            }
25
+        }
26
+    }
27
+}

+ 11
- 14
Makefile View File

@@ -3,24 +3,21 @@
3 3
 PIP=pip3
4 4
 venv_dir=venv
5 5
 
6
-create_dev: create_venv venv_install_dev test
7
-
8
-create_venv:
9
-	venv -p python3 $(venv_dir)
10
-
11 6
 test:
12
-	cd almaren_bot; python3 -m pytest ../
7
+	cd almaren_bot; python3 -m pytest $(TEST_ARGS) ../
13 8
 
14
-venv_install_dev: create_venv venv_install_requirements
9
+create_dev:
10
+	venv -p python3 $(venv_dir)
15 11
 	source $(venv_dir)/bin/activate
16
-	$(PIP) install `cat dev_requirements.txt`
12
+	$(PIP) install `cat *.txt`
17 13
 
18
-venv_install_requirements: create_venv
14
+create_prod:
15
+	venv -p python3 $(venv_dir)
19 16
 	source $(venv_dir)/bin/activate
20 17
 	$(PIP) install `cat requirements.txt`
21 18
 
22
-install_dev: install_requirements
23
-	$(PIP) install `cat dev_requirements.txt`
24
-
25
-install_requirements:
26
-	$(PIP) install `cat requirements.txt`
19
+cleanup_env:
20
+	source $(venv_dir)/bin/activate
21
+	$(PIP) uninstall `cat *.txt`
22
+	deactivate
23
+	rm -rf $(venv_dir)

+ 12
- 7
tests/test_managers.py View File

@@ -30,6 +30,8 @@ class TestManagerBase:
30 30
     def load_module(self, create_module, create_manager):
31 31
         mod = create_manager.load_module(create_module[0], '.')
32 32
         yield (create_manager, mod, create_module[0])
33
+        create_manager.module_data = []
34
+        create_manager.module_data_dict = {}
33 35
 
34 36
     @pytest.fixture
35 37
     def store_module(self, create_module):
@@ -66,13 +68,16 @@ class TestManagerBase:
66 68
                                      path='.', module=load_module[1])
67 69
         assert len(load_module[0].module_data) == 1
68 70
 
69
-    def test_storing_data_unloaded(self, load_module):
70
-        load_module[0].store_to_data(module_file=load_module[2],
71
-                                     path='.', module=load_module[1])
72
-        load_module[0].module_data[0]['module'] = None
73
-        load_module[0].store_to_data(module_file=load_module[2],
74
-                                     path='.', module=load_module[1], old_data={'module':None})
75
-        assert len(load_module[0].module_data) == 1
71
+    def test_storing_data_unloaded(self, create_module):
72
+        manager = managers.Manager()
73
+        manager.module_data = []
74
+        module = manager.load_module(create_module[0], '.')
75
+        manager.store_to_data(module_file=create_module[0],
76
+                              path='.', module=module)
77
+        manager.module_data[0]['module'] = None
78
+        manager.store_to_data(module_file=create_module[0],
79
+                              path='.', module=module, old_data={'module':None})
80
+        assert len(manager.module_data) == 1
76 81
 
77 82
     def test_storing_data(self, load_module):
78 83
         load_module[0].store_to_data(module_file=load_module[2],

Loading…
Cancel
Save