コード例 #1
0
def test_load_primitive_success():
    primitive = {'name': 'temp.primitive', 'primitive': 'temp.primitive'}

    with tempfile.TemporaryDirectory() as tempdir:
        primitives.add_primitives_path(tempdir)
        primitive_path = os.path.join(tempdir, 'temp.primitive.json')
        with open(primitive_path, 'w') as primitive_file:
            json.dump(primitive, primitive_file, indent=4)

        loaded = primitives.load_primitive('temp.primitive')

        assert primitive == loaded
コード例 #2
0
def test_add_primitives_path():
    primitives.add_primitives_path('tests')

    expected_path = os.path.abspath('tests')

    assert primitives._PRIMITIVES_PATHS == [expected_path, 'a', 'b']
コード例 #3
0
def test_add_primitives_path_exception():
    invalid_path = str(uuid.uuid4())

    with pytest.raises(ValueError):
        primitives.add_primitives_path(invalid_path)
コード例 #4
0
def test_add_primitives_path_do_nothing():
    primitives.add_primitives_path('a')

    assert primitives._PRIMITIVES_PATHS == ['a', 'b']