Пример #1
0
    def process(self, msg):
        n_shipname = normalize_shipname_parts(msg.get('shipname'))['basename']
        if n_shipname:
            msg['n_shipname'] = n_shipname

        n_callsign = normalize_callsign(msg.get('callsign'))
        if n_callsign:
            msg['n_callsign'] = n_callsign

        imo = msg.get('imo')
        if imo_validator.is_valid(str(imo)):
            msg['n_imo'] = imo

        yield msg
Пример #2
0
def test_normalize_callsign_upcase():
    result = normalize_callsign("MixEd")
    assert result == "MIXED"
Пример #3
0
def test_normalize_callsign_starting_with_zero():
    result = normalize_callsign("0020300a")
    assert result == "20300A"
Пример #4
0
def test_normalize_callsign_1c():
    result = normalize_callsign("a")
    assert result == "A"
Пример #5
0
def test_normalize_callsign_none():
    result = normalize_callsign(None)
    assert result == None
Пример #6
0
def test_normalize_callsign_empty():
    result = normalize_callsign("")
    assert result == None
Пример #7
0
def test_normalize_callsign_spaces():
    result = normalize_callsign("  \tspaced  \nname      ")
    assert result == "SPACEDNAME"
Пример #8
0
def test_normalize_callsign_symbols():
    result = normalize_callsign("weird -+%()<>$;!&'`\\.#/")
    assert result == "WEIRD"