DevPlace CI / test (push) Failing after 44m45s
Continuous Delivery could never be turned off once a crop was planted. Add a one-shot per-plot "stop after harvest" flag (POST /game/plot/stop, Devii tool game_plot_stop, game_plots.stop_after_harvest), cleared by the next plant, autoreplant claim or Refactor. Autoreplant now also respects crop locks through the shared _crop_lock predicate. Plan and measurements in happyplanting.md. Also includes the pending community sync, node network and related work in the tree; the full suite passed (4999) with all of it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
import pytest
|
|
|
|
from devplacepy.services.nodes.addressclass import (
|
|
CLASS_DATACENTER,
|
|
CLASS_MOBILE,
|
|
CLASS_RESIDENTIAL,
|
|
CLASS_UNKNOWN,
|
|
DATACENTER_ASNS,
|
|
ELIGIBLE_CLASSES,
|
|
classify,
|
|
)
|
|
from devplacepy.services.nodes.spec import ASN_CLASSES
|
|
|
|
|
|
def test_the_classes_are_exactly_the_specified_ones():
|
|
assert set(ELIGIBLE_CLASSES) | {CLASS_DATACENTER, CLASS_UNKNOWN} == set(ASN_CLASSES)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"asn,org,expected",
|
|
[
|
|
(24940, "Hetzner Online GmbH", CLASS_DATACENTER),
|
|
(16509, "", CLASS_DATACENTER),
|
|
(64500, "Acme Web Hosting Ltd", CLASS_DATACENTER),
|
|
(64500, "Fast Cloud Services", CLASS_DATACENTER),
|
|
(64500, "Some VPN Provider", CLASS_DATACENTER),
|
|
(64500, "Data Center Holdings", CLASS_DATACENTER),
|
|
(21928, "T-Mobile USA, Inc.", CLASS_MOBILE),
|
|
(64500, "Example Wireless", CLASS_MOBILE),
|
|
(3320, "Deutsche Telekom AG", CLASS_RESIDENTIAL),
|
|
(1136, "KPN B.V.", CLASS_RESIDENTIAL),
|
|
(0, "", CLASS_UNKNOWN),
|
|
(None, None, CLASS_UNKNOWN),
|
|
("", "", CLASS_UNKNOWN),
|
|
],
|
|
)
|
|
def test_classification_table(asn, org, expected):
|
|
assert classify(asn, org) == expected
|
|
|
|
|
|
def test_keywords_match_whole_words_only():
|
|
assert classify(64500, "Hostingly Residential Broadband") == CLASS_RESIDENTIAL
|
|
assert classify(64500, "Cloudless Telecom") == CLASS_RESIDENTIAL
|
|
assert classify(64500, "Wirelesstown ISP") == CLASS_RESIDENTIAL
|
|
|
|
|
|
def test_a_known_asn_wins_over_a_residential_name():
|
|
assert 14061 in DATACENTER_ASNS
|
|
assert classify(14061, "Friendly Home Internet") == CLASS_DATACENTER
|
|
|
|
|
|
def test_garbage_asn_input_is_unknown_or_name_driven():
|
|
assert classify("not-a-number", "") == CLASS_UNKNOWN
|
|
assert classify("not-a-number", "Plain ISP") == CLASS_RESIDENTIAL
|