Skip to content
Extraits de code Groupes Projets
Valider 4b24143e rédigé par François De Keersmaeker's avatar François De Keersmaeker
Parcourir les fichiers

Unit tests: unittest -> pytest

parent 6dfd31d7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #59989 en échec
import os
from pathlib import Path
import unittest
import profile_translator_blocklist
# Paths
self_name = os.path.basename(__file__)
self_path = Path(os.path.abspath(__file__))
self_dir = self_path.parents[0]
class TestProfileTranslator(unittest.TestCase):
"""
Test class for the package `profile-translator`.
"""
def test_translate_policy(self):
"""
Test the function `translate_policy` from the package `profile-translator`.
"""
device = {
"name": "sample-device",
"ipv4": "192.168.1.2"
}
policy_dict = {
"protocols": {
"dns": {
"domain-name": "example.com",
"qtype": "A"
},
"udp": {
"dst-port": 53
},
"ipv4": {
"src": "self",
"dst": "192.168.1.1"
}
},
"bidirectional": True
}
profile_translator_blocklist.translate_policy(device, policy_dict)
def test_translate_profile(self):
"""
Test the function `translate_profile` from the package `profile-translator`.
"""
sample_profile = os.path.join(self_dir, 'profile.yaml')
profile_translator_blocklist.translate_profile(sample_profile)
### MAIN ###
if __name__ == '__main__':
unittest.main()
import os
from pathlib import Path
from profile_translator_blocklist import translate_policy, translate_profile
# Paths
self_name = os.path.basename(__file__)
self_path = Path(os.path.abspath(__file__))
self_dir = self_path.parents[0]
### TEST FUNCTIONS ###
def test_translate_policy() -> None:
"""
Test the function `translate_policy` from the package `profile-translator`.
"""
device = {
"name": "sample-device",
"ipv4": "192.168.1.2"
}
policy_dict = {
"protocols": {
"dns": {
"domain-name": "example.com",
"qtype": "A"
},
"udp": {
"dst-port": 53
},
"ipv4": {
"src": "self",
"dst": "192.168.1.1"
}
},
"bidirectional": True
}
translate_policy(device, policy_dict)
def test_translate_profile() -> None:
"""
Test the function `translate_profile` from the package `profile-translator`.
"""
sample_profile = os.path.join(self_dir, 'profile.yaml')
translate_profile(sample_profile)
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter