Пример #1
0
def test_init_from_url(mock_get):
    url = 'http://example.com/file.tsv'
    w = Whereabouts(url)
    assert w.url == url

    mock_get.assert_called_with(url)

    places = w.places('2014-07-14')
    assert places['London'] == ['Theodore Ruoff']
Пример #2
0
def test_init_from_url(mock_get):
    url = 'http://example.com/file.tsv'
    w = Whereabouts(url)
    assert w.url == url

    mock_get.assert_called_with(url)

    places = w.places('2014-07-14')
    assert places['London'] == ['Theodore Ruoff']
Пример #3
0
def test_init_from_args():
    w = Whereabouts()
    w.parse_tsv(data)

    places = w.places('2014-07-14')
    assert places['London'] == ['Theodore Ruoff']
    assert places['Croydon'] == ['Robert Roper']

    places = w.places('2014-07-16')
    assert places['Croydon'] == ['Theodore Ruoff', 'Robert Roper']
Пример #4
0
def test_order():
    w = Whereabouts()
    w.parse_tsv("""
name	2014-07-14
A	England
B	Working from home
C	Zoo
D	Conference
""")

    assert sorted(w.places('2014-07-14').keys()) == ['Conference', 'England', 'Working from home', 'Zoo']
Пример #5
0
def test_not_working():
    w = Whereabouts()
    w.parse_tsv("""
name	2014-07-14
A	Not working
B	HOLIDAY
C	Holiday
D	Leave
E	AWAY
F	Annual leave
""")

    assert sorted(w.places('2014-07-14').keys()) == ['Not working']
Пример #6
0
def test_order():
    w = Whereabouts()
    w.parse_tsv("""
name	2014-07-14
A	England
B	Working from home
C	Zoo
D	Conference
""")

    assert sorted(w.places('2014-07-14').keys()) == [
        'Conference', 'England', 'Working from home', 'Zoo'
    ]
Пример #7
0
def test_not_working():
    w = Whereabouts()
    w.parse_tsv("""
name	2014-07-14
A	Not working
B	HOLIDAY
C	Holiday
D	Leave
E	AWAY
F	Annual leave
""")

    assert sorted(w.places('2014-07-14').keys()) == ['Not working']
Пример #8
0
def test_trim():
    w = Whereabouts()
    w.parse_tsv("""
name	2014-07-14	2014-07-15
Theodore Ruoff	 London	Glasgow
Robert Roper	                     London	      London   
Rouxville Mark Lowe	                           London	      London   
""")

    places = w.places('2014-07-14')
    assert places.keys() == ['London']

    places = w.places('2014-07-15')
    assert sorted(places.keys()) == ['Glasgow', 'London']
Пример #9
0
def test_init_from_args():
    w = Whereabouts()
    w.parse_tsv(data)

    places = w.places('2014-07-14')
    assert places['London'] == ['Theodore Ruoff']
    assert places['Croydon'] == ['Robert Roper']

    places = w.places('2014-07-16')
    assert places['Croydon'] == ['Theodore Ruoff', 'Robert Roper']
Пример #10
0
def test_trim():
    w = Whereabouts()
    w.parse_tsv("""
name	2014-07-14	2014-07-15
Theodore Ruoff	 London	Glasgow
Robert Roper	                     London	      London   
Rouxville Mark Lowe	                           London	      London   
""")

    places = w.places('2014-07-14')
    assert places.keys() == ['London']

    places = w.places('2014-07-15')
    assert sorted(places.keys()) == ['Glasgow', 'London']