예제 #1
0
def test_count_green(mock_get, mock_imread, mock_StringIO):

    testMap = Map(lat, lon)

    # Test that the number sum of the green pixels with values greater than
    # the values of both the red and blue pixels is zero for an empty image
    # (zeros everywhere)
    green = np.zeros(size)
    red = np.zeros(size)
    blue = np.zeros(size)
    testMap.pixels = np.dstack((red, green, blue))
    assert_equal(testMap.count_green(), 0)

    # Test that the sum of the green pixels with values greater than the
    # values of both the red and blue pixels is n*m for a n*m*3 array with the
    # value of green pixels equal to one and red/blue pixels equal to zero
    green = np.ones(size)
    testMap.pixels = np.dstack((red, green, blue))
    assert_equal(testMap.count_green(), size[0] * size[1])
예제 #2
0
def test_count_green(mock_string):
    with patch.object(matplotlib.image,'imread') as mock_get:
        with open(os.path.join(os.path.dirname(__file__),'fixtures','green.yaml')) as fixtures_file:
            fixtures=yaml.load(fixtures_file)
            for fixture in fixtures:
                mock_get.return_value = np.array(fixture.pop('pixles'))
                expected_count = fixture.pop('count_answer')
                trial_map = Map('junk','junk')
                actual_count = trial_map.count_green(1)
                assert_equal(expected_count,actual_count)