mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-17 00:07:37 +02:00
pull env-specific tests from CI/CD and run locally only
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
python3 -m unittest -v
|
python3 -m unittest -v
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Running local-only tests:"
|
||||||
|
echo
|
||||||
|
|
||||||
|
python3 -m unittest tests.localtest_last -v
|
||||||
|
41
tests/localtest_last.py
Normal file
41
tests/localtest_last.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import os
|
||||||
|
import json
|
||||||
|
import unittest
|
||||||
|
import jc.parsers.last
|
||||||
|
|
||||||
|
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
|
||||||
|
class MyTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
# input
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-20.04/last-F.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.ubuntu_20_4_last_F = f.read()
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/last-wF.out'), 'r', encoding='utf-8') as f:
|
||||||
|
self.centos_7_7_last_wF = f.read()
|
||||||
|
|
||||||
|
# output
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/ubuntu-20.04/last-F.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.ubuntu_20_4_last_F_json = json.loads(f.read())
|
||||||
|
|
||||||
|
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/centos-7.7/last-wF.json'), 'r', encoding='utf-8') as f:
|
||||||
|
self.centos_7_7_last_wF_json = json.loads(f.read())
|
||||||
|
|
||||||
|
|
||||||
|
def test_last_F_ubuntu_20_4(self):
|
||||||
|
"""
|
||||||
|
Test 'last -F' on Ubuntu 20.4
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.last.parse(self.ubuntu_20_4_last_F, quiet=True), self.ubuntu_20_4_last_F_json)
|
||||||
|
|
||||||
|
def test_last_wF_centos_7_7(self):
|
||||||
|
"""
|
||||||
|
Test 'last -wF' on Centos 7.7
|
||||||
|
"""
|
||||||
|
self.assertEqual(jc.parsers.last.parse(self.centos_7_7_last_wF, quiet=True), self.centos_7_7_last_wF_json)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -131,11 +131,12 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.last.parse(self.ubuntu_18_4_last_w, quiet=True), self.ubuntu_18_4_last_w_json)
|
self.assertEqual(jc.parsers.last.parse(self.ubuntu_18_4_last_w, quiet=True), self.ubuntu_18_4_last_w_json)
|
||||||
|
|
||||||
def test_last_F_ubuntu_20_4(self):
|
# Run this test locally only since environment differences can cause test failures
|
||||||
"""
|
# def test_last_F_ubuntu_20_4(self):
|
||||||
Test 'last -F' on Ubuntu 20.4
|
# """
|
||||||
"""
|
# Test 'last -F' on Ubuntu 20.4
|
||||||
self.assertEqual(jc.parsers.last.parse(self.ubuntu_20_4_last_F, quiet=True), self.ubuntu_20_4_last_F_json)
|
# """
|
||||||
|
# self.assertEqual(jc.parsers.last.parse(self.ubuntu_20_4_last_F, quiet=True), self.ubuntu_20_4_last_F_json)
|
||||||
|
|
||||||
def test_last_fedora32(self):
|
def test_last_fedora32(self):
|
||||||
"""
|
"""
|
||||||
@ -155,11 +156,12 @@ class MyTests(unittest.TestCase):
|
|||||||
"""
|
"""
|
||||||
self.assertEqual(jc.parsers.last.parse(self.centos_7_7_last_crash, quiet=True), self.centos_7_7_last_crash_json)
|
self.assertEqual(jc.parsers.last.parse(self.centos_7_7_last_crash, quiet=True), self.centos_7_7_last_crash_json)
|
||||||
|
|
||||||
def test_last_wF_centos_7_7(self):
|
# Run this test locally only since environment differences can cause test failures
|
||||||
"""
|
# def test_last_wF_centos_7_7(self):
|
||||||
Test 'last -wF' on Centos 7.7
|
# """
|
||||||
"""
|
# Test 'last -wF' on Centos 7.7
|
||||||
self.assertEqual(jc.parsers.last.parse(self.centos_7_7_last_wF, quiet=True), self.centos_7_7_last_wF_json)
|
# """
|
||||||
|
# self.assertEqual(jc.parsers.last.parse(self.centos_7_7_last_wF, quiet=True), self.centos_7_7_last_wF_json)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user