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