Skip to content

Commit 9385fbd

Browse files
authored
Merge pull request #414 from ISISComputingGroup/github_actions_run_pr_tests
GitHub actions run pr tests
2 parents 9f80708 + 5b8614c commit 9385fbd

File tree

17 files changed

+129
-526
lines changed

17 files changed

+129
-526
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: lint-and-test-nightly
2+
on:
3+
schedule:
4+
- cron: "0 0 * * *"
5+
6+
jobs:
7+
lint-and-test-nightly:
8+
uses: ./.github/workflows/lint-and-test.yml
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Lint-and-test
2+
on: [pull_request]
3+
jobs:
4+
call-workflow:
5+
uses: ISISComputingGroup/reusable-workflows/.github/workflows/linters.yml@main
6+
with:
7+
compare-branch: origin/master
8+
runs-on: windows-latest
9+
python-ver: '3.11'
10+
requirements-path: requirements-dev.txt
11+
tests:
12+
runs-on: "windows-latest"
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
- name: install requirements
19+
run: pip install -r requirements-dev.txt
20+
env:
21+
PIP_CONSTRAINT: "constraints.txt"
22+
- name: run tests (windows)
23+
run: python -m pytest --cov
24+

.github/workflows/linter.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

ArchiverAccess/run_tests.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

BlockServer/run_tests.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

BlockServerToKafka/run_tests.py

Lines changed: 0 additions & 54 deletions
This file was deleted.

BlockServerToKafka/test_modules/test_block_server_monitor.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,35 @@
2121
from BlockServerToKafka.block_server_monitor import BlockServerMonitor
2222

2323

24-
@patch("CaChannel.CaChannel")
2524
class TestBlockServerMonitor(unittest.TestCase):
2625
test_address = "TEST_ADDRESS"
2726
test_prefix = "TEST_PREFIX"
2827

29-
def setUp(self):
28+
@patch("CaChannel.CaChannel")
29+
@patch("CaChannel.CaChannel.searchw")
30+
@patch("CaChannel.CaChannel.add_masked_array_event")
31+
@patch("CaChannel.CaChannel.field_type")
32+
@patch("CaChannel.CaChannel.pend_event")
33+
def setUp(self, *args, **kwargs):
3034
self.mock_producer = MagicMock()
3135
self.bs_monitor = BlockServerMonitor(
3236
self.test_address, self.test_prefix, self.mock_producer
3337
)
3438

3539
def test_WHEN_convert_one_char_to_string_THEN_returns_character(
3640
self,
37-
mock_ca_channel,
3841
):
3942
c = "a"
4043
arr = [ord(c)]
4144
self.assertEqual(c, self.bs_monitor.convert_to_string(bytearray(arr)))
4245

43-
def test_WHEN_convert_many_chars_to_string_THEN_returns_characters(self, mock_ca_channel):
46+
def test_WHEN_convert_many_chars_to_string_THEN_returns_characters(self):
4447
chars = "hello world"
4548
arr = [ord(c) for c in chars]
4649
self.assertEqual(chars, self.bs_monitor.convert_to_string(bytearray(arr)))
4750

4851
def test_WHEN_convert_chars_with_null_at_end_THEN_nulls_removed(
4952
self,
50-
mock_ca_channel,
5153
):
5254
chars = "hello world"
5355
arr = [ord(c) for c in chars]
@@ -57,35 +59,31 @@ def test_WHEN_convert_chars_with_null_at_end_THEN_nulls_removed(
5759

5860
def test_WHEN_convert_chars_with_null_at_start_THEN_nulls_removed(
5961
self,
60-
mock_ca_channel,
6162
):
6263
chars = "hello world"
6364
arr = [ord(c) for c in chars]
6465
for i in range(3):
6566
arr.insert(0, 0)
6667
self.assertEqual(chars, self.bs_monitor.convert_to_string(bytearray(arr)))
6768

68-
def test_WHEN_convert_chars_with_nulls_in_centre_THEN_nulls_removed(self, mock_ca_channel):
69+
def test_WHEN_convert_chars_with_nulls_in_centre_THEN_nulls_removed(self):
6970
chars = "hello world"
7071
arr = [ord(c) for c in chars]
7172
arr.insert(4, 0)
7273
self.assertEqual(chars, self.bs_monitor.convert_to_string(bytearray(arr)))
7374

7475
def test_WHEN_convert_nulls_THEN_empty_string_returned(
7576
self,
76-
mock_ca_channel,
7777
):
7878
arr = [0] * 10
7979
self.assertEqual("", self.bs_monitor.convert_to_string(bytearray(arr)))
8080

81-
def test_GIVEN_no_previous_pvs_WHEN_update_config_called_THEN_producer_is_called(
82-
self, mock_ca_channel
83-
):
81+
def test_GIVEN_no_previous_pvs_WHEN_update_config_called_THEN_producer_is_called(self):
8482
self.bs_monitor.update_config(["BLOCK"])
8583
self.mock_producer.add_config.assert_called_once()
8684

8785
def test_GIVEN_no_previous_pvs_WHEN_update_config_called_THEN_producer_is_called_containing_block_name(
88-
self, mock_ca_channel
86+
self,
8987
):
9088
block = "BLOCK"
9189
self.bs_monitor.update_config([block])
@@ -94,15 +92,15 @@ def test_GIVEN_no_previous_pvs_WHEN_update_config_called_THEN_producer_is_called
9492
)
9593

9694
def test_GIVEN_previous_pvs_WHEN_update_config_called_with_same_pvs_THEN_producer_is_not_called(
97-
self, mock_ca_channel
95+
self,
9896
):
9997
block = "BLOCK"
10098
self.bs_monitor.update_config([block])
10199
self.bs_monitor.update_config([block])
102100
self.mock_producer.add_config.assert_called_once()
103101

104102
def test_GIVEN_previous_pvs_WHEN_update_config_called_with_different_pvs_THEN_producer_is_called(
105-
self, mock_ca_channel
103+
self,
106104
):
107105
self.bs_monitor.update_config(["OLD_BLOCK"])
108106
self.mock_producer.reset_mock()

ConfigVersionControl/run_tests.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)