示例#1
0
def test_default_prefs():
    data = {'slug': 'my_addon'}
    fn = 'defaults/preferences/prefs.js'
    mx = MockXPI(fn)
    p._write_resource(fn, mx, data)
    mx.assert_file(fn)

    # Ensure that the correct output got written.
    output = p._get_resource(fn, data)
    expected = open(p._get_path(fn)).read().replace('%(slug)s', data['slug'])
    eq_(output.strip(), expected.strip())

    # Ensure that the file got written correctly to the XPI.
    mx.assert_data(fn, expected)
示例#2
0
def test_write_resource():
    """Test that data is properly written to the XPI manager."""
    rpath = p.RESOURCES_PATH
    p.RESOURCES_PATH = RESOURCES_PATH
    fn = 'test.txt'

    # Test that files with associated data are routed through _get_resource.
    mx = MockXPI(fn)
    p._write_resource(fn, mx, {'foo': 'bar'})
    mx.assert_file(fn)

    # Test that files without associated data are written with write_file.
    mx = MockXPI(fn)
    p._write_resource(fn, mx)
    mx.assert_file(fn)

    p.RESOURCES_PATH = rpath