Compare commits
No commits in common. '462ce7eb998783eae6c08a5c535f487afedb8c85' and '48a12e4f37481b7260ada2b8b379b15507137029' have entirely different histories.
462ce7eb99
...
48a12e4f37
|
Before Width: | Height: | Size: 177 KiB After Width: | Height: | Size: 177 KiB |
|
Before Width: | Height: | Size: 223 KiB |
|
Before Width: | Height: | Size: 204 KiB |
|
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 32 KiB |
@ -1,7 +0,0 @@ |
|||||||
# Field position for data items |
|
||||||
ID = 0 |
|
||||||
FILE = 1 |
|
||||||
GEO = 2 |
|
||||||
TITLE = 3 |
|
||||||
DESCRIPTION = 4 |
|
||||||
POS = 5 |
|
||||||
@ -1,6 +0,0 @@ |
|||||||
# Universal geo pos tuple |
|
||||||
LAT = 0 |
|
||||||
LON = 1 |
|
||||||
|
|
||||||
X = 0 |
|
||||||
Y = 1 |
|
||||||
@ -1,130 +0,0 @@ |
|||||||
import pytest |
|
||||||
import main |
|
||||||
|
|
||||||
######### |
|
||||||
# In order to reduce the dependency of method shifting(), |
|
||||||
# the position is not explicitly checked. |
|
||||||
######### |
|
||||||
|
|
||||||
@pytest.fixture(autouse=True) |
|
||||||
def patch_log(monkeypatch): |
|
||||||
monkeypatch.setattr(main, "log", lambda msg: None) |
|
||||||
monkeypatch.setattr(main, "logvv", lambda msg: None) |
|
||||||
|
|
||||||
def test_single_item_no_match(): |
|
||||||
|
|
||||||
matrixdims = (6, 3) |
|
||||||
|
|
||||||
pos = (0,0) |
|
||||||
before = {1:pos} |
|
||||||
|
|
||||||
after = main.make_pos_free((2, 3), before, matrixdims) |
|
||||||
assert after[1] == pos |
|
||||||
|
|
||||||
|
|
||||||
def test_single_item_match_at_0_0(): |
|
||||||
|
|
||||||
pos = (0,0) |
|
||||||
before = {1:pos} |
|
||||||
|
|
||||||
matrixdims = (6, 3) |
|
||||||
after = main.make_pos_free(pos, before, matrixdims) |
|
||||||
assert after[1] != pos |
|
||||||
|
|
||||||
|
|
||||||
def test_single_item_match_at_horizont(): |
|
||||||
|
|
||||||
pos = (0, 1) |
|
||||||
before = {1:pos} |
|
||||||
|
|
||||||
# Y |
|
||||||
# 0 |
|
||||||
# 1 <--- Horizon |
|
||||||
# 2 |
|
||||||
matrixdims = (99, 2) |
|
||||||
after = main.make_pos_free(pos, before, matrixdims) |
|
||||||
assert after[1] != pos |
|
||||||
|
|
||||||
|
|
||||||
def test_single_item_match_at_upper(): |
|
||||||
|
|
||||||
pos = (0, 0) |
|
||||||
before = {1:pos} |
|
||||||
|
|
||||||
# Y |
|
||||||
# 0 |
|
||||||
# 1 <--- Horizon |
|
||||||
# 2 |
|
||||||
matrixdims = (99, 2) |
|
||||||
after = main.make_pos_free(pos, before, matrixdims) |
|
||||||
assert after[1] != pos |
|
||||||
|
|
||||||
|
|
||||||
def test_single_item_match_at_lower(): |
|
||||||
|
|
||||||
pos = (0, 2) |
|
||||||
before = {1:pos} |
|
||||||
|
|
||||||
# Y |
|
||||||
# 0 ^ |
|
||||||
# 1 <--- Horizon | Lower | Upper |
|
||||||
# 2 V |
|
||||||
matrixdims = (99, 2) |
|
||||||
after = main.make_pos_free(pos, before, matrixdims) |
|
||||||
assert after[1] != pos |
|
||||||
|
|
||||||
|
|
||||||
def test_first_item(): |
|
||||||
|
|
||||||
pos = (1,1) |
|
||||||
matrixdims = (6, 3) |
|
||||||
|
|
||||||
before = [] |
|
||||||
after = main.make_pos_free(pos, before, matrixdims) |
|
||||||
assert len(after) == 0 |
|
||||||
|
|
||||||
|
|
||||||
def test_check_direct_neighbours_upwards(): |
|
||||||
|
|
||||||
matrixdims = (1000, 1000) |
|
||||||
|
|
||||||
pos = (100,200) |
|
||||||
|
|
||||||
before = { |
|
||||||
1:(pos[main.P.X] , pos[main.P.Y] ), |
|
||||||
2:(pos[main.P.X] , pos[main.P.Y]-1 ), |
|
||||||
} |
|
||||||
|
|
||||||
after = main.make_pos_free(pos, before, matrixdims) |
|
||||||
|
|
||||||
for i in after: |
|
||||||
for j in after: |
|
||||||
if i == j: |
|
||||||
continue |
|
||||||
assert after[j] != after[i], f"i={i}, j={j}: Two items may not have the same position: {after[i]}" |
|
||||||
|
|
||||||
|
|
||||||
def test_multiple_item_no_match(): |
|
||||||
|
|
||||||
matrixdims = (6, 3) |
|
||||||
|
|
||||||
pos = (1,1) |
|
||||||
|
|
||||||
before = { |
|
||||||
1:(pos[main.P.X]+1, pos[main.P.Y] ), |
|
||||||
2:(pos[main.P.X]-1, pos[main.P.Y] ), |
|
||||||
3:(pos[main.P.X] , pos[main.P.Y]+1), |
|
||||||
4:(pos[main.P.X] , pos[main.P.Y]-1), |
|
||||||
5:(pos[main.P.X]+1, pos[main.P.Y]+1), |
|
||||||
6:(pos[main.P.X]+1, pos[main.P.Y]-1), |
|
||||||
7:(pos[main.P.X]-1, pos[main.P.Y]+1), |
|
||||||
8:(pos[main.P.X]-1, pos[main.P.Y]-1), |
|
||||||
} |
|
||||||
|
|
||||||
after = main.make_pos_free(pos, before, matrixdims) |
|
||||||
|
|
||||||
for i in after: |
|
||||||
for j in after: |
|
||||||
if i == j: |
|
||||||
continue |
|
||||||
assert after[j] != after[i], f"i={i}, j={j}: Two items may not have the same position: {after[i]}" |
|
||||||
@ -1,20 +0,0 @@ |
|||||||
import pytest |
|
||||||
import main |
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True) |
|
||||||
def patch_log(monkeypatch): |
|
||||||
monkeypatch.setattr(main, "log", lambda msg: None) |
|
||||||
monkeypatch.setattr(main, "logvv", lambda msg: None) |
|
||||||
|
|
||||||
def test_shifting_top(): |
|
||||||
|
|
||||||
assert main.shifting((2,3), (4,5)) == (2,4) |
|
||||||
|
|
||||||
def test_shifting_mid(): |
|
||||||
|
|
||||||
assert main.shifting((20,24), (21,49)) == (20,23) |
|
||||||
|
|
||||||
def test_shifting_botom(): |
|
||||||
|
|
||||||
assert main.shifting((20,26), (21,49)) == (20,27) |
|
||||||